| 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/chrome_autocomplete_scheme_classifier.h" | 9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 11 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 12 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 12 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 13 #include "chrome/browser/ui/app_list/search/search_util.h" | 13 #include "chrome/browser/ui/app_list/search/search_util.h" |
| 14 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
| 15 #include "components/metrics/proto/omnibox_event.pb.h" | 15 #include "components/metrics/proto/omnibox_event.pb.h" |
| 16 #include "components/omnibox/autocomplete_input.h" | 16 #include "components/omnibox/autocomplete_input.h" |
| 17 #include "components/omnibox/autocomplete_match.h" | 17 #include "components/omnibox/autocomplete_match.h" |
| 18 #include "components/omnibox/autocomplete_match_type.h" |
| 18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 19 #include "ui/app_list/search_result.h" | 20 #include "ui/app_list/search_result.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 | 22 |
| 22 namespace app_list { | 23 namespace app_list { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 int ACMatchStyleToTagStyle(int styles) { | 27 int ACMatchStyleToTagStyle(int styles) { |
| 27 int tag_styles = 0; | 28 int tag_styles = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 84 } |
| 84 set_id(match_.destination_url.spec()); | 85 set_id(match_.destination_url.spec()); |
| 85 | 86 |
| 86 // Derive relevance from omnibox relevance and normalize it to [0, 1]. | 87 // Derive relevance from omnibox relevance and normalize it to [0, 1]. |
| 87 // The magic number 1500 is the highest score of an omnibox result. | 88 // The magic number 1500 is the highest score of an omnibox result. |
| 88 // See comments in autocomplete_provider.h. | 89 // See comments in autocomplete_provider.h. |
| 89 set_relevance(match_.relevance / 1500.0); | 90 set_relevance(match_.relevance / 1500.0); |
| 90 | 91 |
| 91 UpdateIcon(); | 92 UpdateIcon(); |
| 92 UpdateTitleAndDetails(); | 93 UpdateTitleAndDetails(); |
| 94 |
| 95 // The raw "what you typed" search results should be promoted and |
| 96 // automatically selected by voice queries. If a "history" result exactly |
| 97 // matches what you typed, then the omnibox will not produce a "what you |
| 98 // typed" result; therefore, we must also flag "history" results as voice |
| 99 // results if they exactly match the query. |
| 100 if (match_.type == AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED || |
| 101 (match_.type == AutocompleteMatchType::SEARCH_HISTORY && |
| 102 match_.contents == match_.search_terms_args->original_query)) { |
| 103 set_voice_result(true); |
| 104 } |
| 93 } | 105 } |
| 94 ~OmniboxResult() override {} | 106 ~OmniboxResult() override {} |
| 95 | 107 |
| 96 // SearchResult overrides: | 108 // SearchResult overrides: |
| 97 void Open(int event_flags) override { | 109 void Open(int event_flags) override { |
| 98 RecordHistogram(OMNIBOX_SEARCH_RESULT); | 110 RecordHistogram(OMNIBOX_SEARCH_RESULT); |
| 99 list_controller_->OpenURL(profile_, | 111 list_controller_->OpenURL(profile_, |
| 100 match_.destination_url, | 112 match_.destination_url, |
| 101 match_.transition, | 113 match_.transition, |
| 102 ui::DispositionFromEventFlags(event_flags)); | 114 ui::DispositionFromEventFlags(event_flags)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 new OmniboxResult(profile_, list_controller_, controller_.get(), *it))); | 194 new OmniboxResult(profile_, list_controller_, controller_.get(), *it))); |
| 183 } | 195 } |
| 184 } | 196 } |
| 185 | 197 |
| 186 void OmniboxProvider::OnResultChanged(bool default_match_changed) { | 198 void OmniboxProvider::OnResultChanged(bool default_match_changed) { |
| 187 const AutocompleteResult& result = controller_->result(); | 199 const AutocompleteResult& result = controller_->result(); |
| 188 PopulateFromACResult(result); | 200 PopulateFromACResult(result); |
| 189 } | 201 } |
| 190 | 202 |
| 191 } // namespace app_list | 203 } // namespace app_list |
| OLD | NEW |