| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webui/omnibox/omnibox_ui_handler.h" | 5 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 17 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 19 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 20 #include "chrome/browser/history/history_service.h" | 20 #include "chrome/browser/history/history_service.h" |
| 21 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
| 22 #include "chrome/browser/history/url_database.h" | 22 #include "chrome/browser/history/url_database.h" |
| 23 #include "chrome/browser/search/search.h" | 23 #include "chrome/browser/search/search.h" |
| 24 #include "chrome/browser/search_engines/template_url.h" | 24 #include "chrome/browser/search_engines/template_url.h" |
| 25 #include "components/metrics/proto/omnibox_event.pb.h" |
| 25 #include "content/public/browser/web_ui.h" | 26 #include "content/public/browser/web_ui.h" |
| 26 #include "mojo/common/common_type_converters.h" | 27 #include "mojo/common/common_type_converters.h" |
| 27 | 28 |
| 28 namespace mojo { | 29 namespace mojo { |
| 29 | 30 |
| 30 template <> | 31 template <> |
| 31 class TypeConverter<mojo::Array<AutocompleteAdditionalInfoPtr>, | 32 class TypeConverter<mojo::Array<AutocompleteAdditionalInfoPtr>, |
| 32 AutocompleteMatch::AdditionalInfo> { | 33 AutocompleteMatch::AdditionalInfo> { |
| 33 public: | 34 public: |
| 34 static mojo::Array<AutocompleteAdditionalInfoPtr> ConvertFrom( | 35 static mojo::Array<AutocompleteAdditionalInfoPtr> ConvertFrom( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // variable (or something else) and some providers will short-circuit | 166 // variable (or something else) and some providers will short-circuit |
| 166 // important logic and return stale results. In short, we want the | 167 // important logic and return stale results. In short, we want the |
| 167 // actual results to not depend on the state of the previous request. | 168 // actual results to not depend on the state of the previous request. |
| 168 ResetController(); | 169 ResetController(); |
| 169 time_omnibox_started_ = base::Time::Now(); | 170 time_omnibox_started_ = base::Time::Now(); |
| 170 input_ = AutocompleteInput( | 171 input_ = AutocompleteInput( |
| 171 input_string.To<base::string16>(), | 172 input_string.To<base::string16>(), |
| 172 cursor_position, | 173 cursor_position, |
| 173 base::string16(), // user's desired tld (top-level domain) | 174 base::string16(), // user's desired tld (top-level domain) |
| 174 GURL(), | 175 GURL(), |
| 175 static_cast<AutocompleteInput::PageClassification>( | 176 static_cast<metrics::OmniboxEventProto::PageClassification>( |
| 176 page_classification), | 177 page_classification), |
| 177 prevent_inline_autocomplete, | 178 prevent_inline_autocomplete, |
| 178 prefer_keyword, | 179 prefer_keyword, |
| 179 true, // allow exact keyword matches | 180 true, // allow exact keyword matches |
| 180 true); | 181 true); |
| 181 controller_->Start(input_); // want all matches | 182 controller_->Start(input_); // want all matches |
| 182 } | 183 } |
| 183 | 184 |
| 184 void OmniboxUIHandler::ResetController() { | 185 void OmniboxUIHandler::ResetController() { |
| 185 controller_.reset(new AutocompleteController(profile_, this, | 186 controller_.reset(new AutocompleteController(profile_, this, |
| 186 AutocompleteClassifier::kDefaultOmniboxProviders)); | 187 AutocompleteClassifier::kDefaultOmniboxProviders)); |
| 187 } | 188 } |
| OLD | NEW |