OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/autocomplete/keyword_provider.h" | 5 #include "chrome/browser/autocomplete/keyword_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
14 #include "chrome/browser/extensions/extension_omnibox_api.h" | 14 #include "chrome/browser/extensions/extension_omnibox_api.h" |
15 #include "chrome/browser/extensions/extensions_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search_engines/template_url.h" | 17 #include "chrome/browser/search_engines/template_url.h" |
18 #include "chrome/browser/search_engines/template_url_model.h" | 18 #include "chrome/browser/search_engines/template_url_model.h" |
19 #include "chrome/common/notification_service.h" | 19 #include "chrome/common/notification_service.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
23 | 23 |
24 // Helper functor for Start(), for ending keyword mode unless explicitly told | 24 // Helper functor for Start(), for ending keyword mode unless explicitly told |
25 // otherwise. | 25 // otherwise. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 model->FindMatchingKeywords(keyword, !remaining_input.empty(), | 175 model->FindMatchingKeywords(keyword, !remaining_input.empty(), |
176 &keyword_matches); | 176 &keyword_matches); |
177 | 177 |
178 // Prune any extension keywords that are disallowed in incognito mode (if | 178 // Prune any extension keywords that are disallowed in incognito mode (if |
179 // we're incognito), or disabled. | 179 // we're incognito), or disabled. |
180 for (std::vector<std::wstring>::iterator i(keyword_matches.begin()); | 180 for (std::vector<std::wstring>::iterator i(keyword_matches.begin()); |
181 i != keyword_matches.end(); ) { | 181 i != keyword_matches.end(); ) { |
182 const TemplateURL* template_url(model->GetTemplateURLForKeyword(*i)); | 182 const TemplateURL* template_url(model->GetTemplateURLForKeyword(*i)); |
183 if (profile_ && | 183 if (profile_ && |
184 !input.synchronous_only() && template_url->IsExtensionKeyword()) { | 184 !input.synchronous_only() && template_url->IsExtensionKeyword()) { |
185 ExtensionsService* service = profile_->GetExtensionsService(); | 185 ExtensionService* service = profile_->GetExtensionService(); |
186 const Extension* extension = service->GetExtensionById( | 186 const Extension* extension = service->GetExtensionById( |
187 template_url->GetExtensionId(), false); | 187 template_url->GetExtensionId(), false); |
188 bool enabled = extension && (!profile_->IsOffTheRecord() || | 188 bool enabled = extension && (!profile_->IsOffTheRecord() || |
189 service->IsIncognitoEnabled(extension)); | 189 service->IsIncognitoEnabled(extension)); |
190 if (!enabled) { | 190 if (!enabled) { |
191 i = keyword_matches.erase(i); | 191 i = keyword_matches.erase(i); |
192 continue; | 192 continue; |
193 } | 193 } |
194 } | 194 } |
195 ++i; | 195 ++i; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 } | 520 } |
521 | 521 |
522 void KeywordProvider::MaybeEndExtensionKeywordMode() { | 522 void KeywordProvider::MaybeEndExtensionKeywordMode() { |
523 if (!current_keyword_extension_id_.empty()) { | 523 if (!current_keyword_extension_id_.empty()) { |
524 ExtensionOmniboxEventRouter::OnInputCancelled( | 524 ExtensionOmniboxEventRouter::OnInputCancelled( |
525 profile_, current_keyword_extension_id_); | 525 profile_, current_keyword_extension_id_); |
526 | 526 |
527 current_keyword_extension_id_.clear(); | 527 current_keyword_extension_id_.clear(); |
528 } | 528 } |
529 } | 529 } |
OLD | NEW |