| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/browser/keyword_provider.h" | 5 #include "components/omnibox/browser/keyword_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/trace_event/trace_event.h" | |
| 15 #include "components/metrics/proto/omnibox_input_type.pb.h" | 14 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 16 #include "components/omnibox/browser/autocomplete_match.h" | 15 #include "components/omnibox/browser/autocomplete_match.h" |
| 17 #include "components/omnibox/browser/autocomplete_provider_client.h" | 16 #include "components/omnibox/browser/autocomplete_provider_client.h" |
| 18 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 17 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
| 19 #include "components/omnibox/browser/keyword_extensions_delegate.h" | 18 #include "components/omnibox/browser/keyword_extensions_delegate.h" |
| 20 #include "components/omnibox/browser/omnibox_field_trial.h" | 19 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 21 #include "components/omnibox/browser/search_provider.h" | 20 #include "components/omnibox/browser/search_provider.h" |
| 22 #include "components/search_engines/template_url.h" | 21 #include "components/search_engines/template_url.h" |
| 23 #include "components/search_engines/template_url_service.h" | 22 #include "components/search_engines/template_url_service.h" |
| 24 #include "grit/components_strings.h" | 23 #include "grit/components_strings.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 const AutocompleteInput& input) { | 201 const AutocompleteInput& input) { |
| 203 // A verbatim match is allowed to be the default match. | 202 // A verbatim match is allowed to be the default match. |
| 204 return CreateAutocompleteMatch( | 203 return CreateAutocompleteMatch( |
| 205 GetTemplateURLService()->GetTemplateURLForKeyword(keyword), | 204 GetTemplateURLService()->GetTemplateURLForKeyword(keyword), |
| 206 keyword.length(), input, keyword.length(), | 205 keyword.length(), input, keyword.length(), |
| 207 SplitReplacementStringFromInput(text, true), true, 0); | 206 SplitReplacementStringFromInput(text, true), true, 0); |
| 208 } | 207 } |
| 209 | 208 |
| 210 void KeywordProvider::Start(const AutocompleteInput& input, | 209 void KeywordProvider::Start(const AutocompleteInput& input, |
| 211 bool minimal_changes) { | 210 bool minimal_changes) { |
| 212 TRACE_EVENT0("omnibox", "KeywordProvider::Start"); | |
| 213 // This object ensures we end keyword mode if we exit the function without | 211 // This object ensures we end keyword mode if we exit the function without |
| 214 // toggling keyword mode to on. | 212 // toggling keyword mode to on. |
| 215 ScopedEndExtensionKeywordMode keyword_mode_toggle(extensions_delegate_.get()); | 213 ScopedEndExtensionKeywordMode keyword_mode_toggle(extensions_delegate_.get()); |
| 216 | 214 |
| 217 matches_.clear(); | 215 matches_.clear(); |
| 218 | 216 |
| 219 if (!minimal_changes) { | 217 if (!minimal_changes) { |
| 220 done_ = true; | 218 done_ = true; |
| 221 | 219 |
| 222 // Input has changed. Increment the input ID so that we can discard any | 220 // Input has changed. Increment the input ID so that we can discard any |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 ACMatchClassification::NONE, &match->contents_class); | 496 ACMatchClassification::NONE, &match->contents_class); |
| 499 } | 497 } |
| 500 } | 498 } |
| 501 | 499 |
| 502 TemplateURLService* KeywordProvider::GetTemplateURLService() const { | 500 TemplateURLService* KeywordProvider::GetTemplateURLService() const { |
| 503 // Make sure the model is loaded. This is cheap and quickly bails out if | 501 // Make sure the model is loaded. This is cheap and quickly bails out if |
| 504 // the model is already loaded. | 502 // the model is already loaded. |
| 505 model_->Load(); | 503 model_->Load(); |
| 506 return model_; | 504 return model_; |
| 507 } | 505 } |
| OLD | NEW |