Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/app_list/search/omnibox_provider.h" | 5 #include "chrome/browser/ui/app_list/search/omnibox_provider.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 7 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 8 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 9 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 11 #include "chrome/browser/autocomplete/search_provider.h" | |
| 12 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 13 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" | 12 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" |
| 14 #include "chrome/browser/ui/browser_navigator.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
| 15 #include "components/autocomplete/autocomplete_input.h" | 14 #include "components/autocomplete/autocomplete_input.h" |
| 16 #include "components/metrics/proto/omnibox_event.pb.h" | 15 #include "components/metrics/proto/omnibox_event.pb.h" |
| 17 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 19 | 18 |
| 20 namespace app_list { | 19 namespace app_list { |
| 21 | 20 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 tags->push_back(SearchResult::Tag( | 61 tags->push_back(SearchResult::Tag( |
| 63 tag_styles, tag_start, text.length())); | 62 tag_styles, tag_start, text.length())); |
| 64 } | 63 } |
| 65 } | 64 } |
| 66 | 65 |
| 67 class OmniboxResult : public ChromeSearchResult { | 66 class OmniboxResult : public ChromeSearchResult { |
| 68 public: | 67 public: |
| 69 OmniboxResult(Profile* profile, const AutocompleteMatch& match) | 68 OmniboxResult(Profile* profile, const AutocompleteMatch& match) |
| 70 : profile_(profile), | 69 : profile_(profile), |
| 71 match_(match) { | 70 match_(match) { |
| 71 if (match_.search_terms_args) | |
| 72 match_.search_terms_args->from_app_list = true; | |
|
Peter Kasting
2014/07/17 18:11:26
Does this actually work? I worry that we may not
hashimoto
2014/07/18 09:54:14
That's a valid concern.
I should have been aware o
Peter Kasting
2014/07/18 17:37:06
I think it would be safer to actually call UpdateM
hashimoto
2014/07/22 10:33:07
I think UpdateMatchDestinationURL() cannot be used
Peter Kasting
2014/07/22 18:44:52
If there's a way to refactor the existing code so
hashimoto
2014/07/23 10:30:42
Added a new method to AutocompleteController.
| |
| 72 set_id(match.destination_url.spec()); | 73 set_id(match.destination_url.spec()); |
| 73 | 74 |
| 74 // Derive relevance from omnibox relevance and normalize it to [0, 1]. | 75 // Derive relevance from omnibox relevance and normalize it to [0, 1]. |
| 75 // The magic number 1500 is the highest score of an omnibox result. | 76 // The magic number 1500 is the highest score of an omnibox result. |
| 76 // See comments in autocomplete_provider.h. | 77 // See comments in autocomplete_provider.h. |
| 77 set_relevance(match.relevance / 1500.0); | 78 set_relevance(match.relevance / 1500.0); |
| 78 | 79 |
| 79 UpdateIcon(); | 80 UpdateIcon(); |
| 80 UpdateTitleAndDetails(); | 81 UpdateTitleAndDetails(); |
| 81 } | 82 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 } // namespace | 135 } // namespace |
| 135 | 136 |
| 136 OmniboxProvider::OmniboxProvider(Profile* profile) | 137 OmniboxProvider::OmniboxProvider(Profile* profile) |
| 137 : profile_(profile), | 138 : profile_(profile), |
| 138 controller_(new AutocompleteController( | 139 controller_(new AutocompleteController( |
| 139 profile, | 140 profile, |
| 140 TemplateURLServiceFactory::GetForProfile(profile), | 141 TemplateURLServiceFactory::GetForProfile(profile), |
| 141 this, | 142 this, |
| 142 AutocompleteClassifier::kDefaultOmniboxProviders & | 143 AutocompleteClassifier::kDefaultOmniboxProviders & |
| 143 ~AutocompleteProvider::TYPE_ZERO_SUGGEST)) { | 144 ~AutocompleteProvider::TYPE_ZERO_SUGGEST)) { |
| 144 controller_->search_provider()->set_in_app_list(); | |
| 145 } | 145 } |
| 146 | 146 |
| 147 OmniboxProvider::~OmniboxProvider() {} | 147 OmniboxProvider::~OmniboxProvider() {} |
| 148 | 148 |
| 149 void OmniboxProvider::Start(const base::string16& query) { | 149 void OmniboxProvider::Start(const base::string16& query) { |
| 150 controller_->Start(AutocompleteInput( | 150 controller_->Start(AutocompleteInput( |
| 151 query, base::string16::npos, base::string16(), GURL(), | 151 query, base::string16::npos, base::string16(), GURL(), |
| 152 metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, | 152 metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, |
| 153 ChromeAutocompleteSchemeClassifier(profile_))); | 153 ChromeAutocompleteSchemeClassifier(profile_))); |
| 154 } | 154 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 168 Add(scoped_ptr<SearchResult>(new OmniboxResult(profile_, *it))); | 168 Add(scoped_ptr<SearchResult>(new OmniboxResult(profile_, *it))); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 void OmniboxProvider::OnResultChanged(bool default_match_changed) { | 172 void OmniboxProvider::OnResultChanged(bool default_match_changed) { |
| 173 const AutocompleteResult& result = controller_->result(); | 173 const AutocompleteResult& result = controller_->result(); |
| 174 PopulateFromACResult(result); | 174 PopulateFromACResult(result); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace app_list | 177 } // namespace app_list |
| OLD | NEW |