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/keyword_provider.h" | 5 #include "components/omnibox/keyword_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "components/metrics/proto/omnibox_input_type.pb.h" | 13 #include "components/metrics/proto/omnibox_input_type.pb.h" |
14 #include "components/omnibox/autocomplete_match.h" | 14 #include "components/omnibox/autocomplete_match.h" |
| 15 #include "components/omnibox/autocomplete_provider_client.h" |
15 #include "components/omnibox/autocomplete_provider_listener.h" | 16 #include "components/omnibox/autocomplete_provider_listener.h" |
16 #include "components/omnibox/keyword_extensions_delegate.h" | 17 #include "components/omnibox/keyword_extensions_delegate.h" |
17 #include "components/search_engines/template_url.h" | 18 #include "components/search_engines/template_url.h" |
18 #include "components/search_engines/template_url_service.h" | 19 #include "components/search_engines/template_url_service.h" |
19 #include "grit/components_strings.h" | 20 #include "grit/components_strings.h" |
20 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 | 24 |
24 namespace { | 25 namespace { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (delegate_) | 63 if (delegate_) |
63 delegate_->MaybeEndExtensionKeywordMode(); | 64 delegate_->MaybeEndExtensionKeywordMode(); |
64 } | 65 } |
65 | 66 |
66 void ScopedEndExtensionKeywordMode::StayInKeywordMode() { | 67 void ScopedEndExtensionKeywordMode::StayInKeywordMode() { |
67 delegate_ = NULL; | 68 delegate_ = NULL; |
68 } | 69 } |
69 | 70 |
70 } // namespace | 71 } // namespace |
71 | 72 |
72 KeywordProvider::KeywordProvider( | 73 KeywordProvider::KeywordProvider(AutocompleteProviderClient* client, |
73 AutocompleteProviderListener* listener, | 74 AutocompleteProviderListener* listener) |
74 TemplateURLService* model) | |
75 : AutocompleteProvider(AutocompleteProvider::TYPE_KEYWORD), | 75 : AutocompleteProvider(AutocompleteProvider::TYPE_KEYWORD), |
76 listener_(listener), | 76 listener_(listener), |
77 model_(model) { | 77 model_(client->GetTemplateURLService()), |
| 78 extensions_delegate_(client->GetKeywordExtensionsDelegate(this)) { |
78 } | 79 } |
79 | 80 |
80 // static | 81 // static |
81 base::string16 KeywordProvider::SplitKeywordFromInput( | 82 base::string16 KeywordProvider::SplitKeywordFromInput( |
82 const base::string16& input, | 83 const base::string16& input, |
83 bool trim_leading_whitespace, | 84 bool trim_leading_whitespace, |
84 base::string16* remaining_input) { | 85 base::string16* remaining_input) { |
85 // Find end of first token. The AutocompleteController has trimmed leading | 86 // Find end of first token. The AutocompleteController has trimmed leading |
86 // whitespace, so we need not skip over that. | 87 // whitespace, so we need not skip over that. |
87 const size_t first_white(input.find_first_of(base::kWhitespaceUTF16)); | 88 const size_t first_white(input.find_first_of(base::kWhitespaceUTF16)); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 ACMatchClassification::NONE, &match->contents_class); | 470 ACMatchClassification::NONE, &match->contents_class); |
470 } | 471 } |
471 } | 472 } |
472 | 473 |
473 TemplateURLService* KeywordProvider::GetTemplateURLService() const { | 474 TemplateURLService* KeywordProvider::GetTemplateURLService() const { |
474 // Make sure the model is loaded. This is cheap and quickly bails out if | 475 // Make sure the model is loaded. This is cheap and quickly bails out if |
475 // the model is already loaded. | 476 // the model is already loaded. |
476 model_->Load(); | 477 model_->Load(); |
477 return model_; | 478 return model_; |
478 } | 479 } |
OLD | NEW |