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/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 "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return string16(); | 165 return string16(); |
166 | 166 |
167 // Don't provide a keyword if it doesn't support replacement. | 167 // Don't provide a keyword if it doesn't support replacement. |
168 const TemplateURL* const template_url = | 168 const TemplateURL* const template_url = |
169 url_service->GetTemplateURLForKeyword(keyword); | 169 url_service->GetTemplateURLForKeyword(keyword); |
170 if (!template_url || !template_url->SupportsReplacement()) | 170 if (!template_url || !template_url->SupportsReplacement()) |
171 return string16(); | 171 return string16(); |
172 | 172 |
173 // Don't provide a keyword for inactive/disabled extension keywords. | 173 // Don't provide a keyword for inactive/disabled extension keywords. |
174 if (template_url->IsExtensionKeyword()) { | 174 if (template_url->IsExtensionKeyword()) { |
175 const Extension* extension = profile_->GetExtensionService()-> | 175 const extensions::Extension* extension = profile_->GetExtensionService()-> |
176 GetExtensionById(template_url->GetExtensionId(), false); | 176 GetExtensionById(template_url->GetExtensionId(), false); |
177 if (!extension || | 177 if (!extension || |
178 (profile_->IsOffTheRecord() && | 178 (profile_->IsOffTheRecord() && |
179 !profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()))) | 179 !profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()))) |
180 return string16(); | 180 return string16(); |
181 } | 181 } |
182 | 182 |
183 return keyword; | 183 return keyword; |
184 } | 184 } |
185 | 185 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 &keyword_matches); | 242 &keyword_matches); |
243 | 243 |
244 for (std::vector<string16>::iterator i(keyword_matches.begin()); | 244 for (std::vector<string16>::iterator i(keyword_matches.begin()); |
245 i != keyword_matches.end(); ) { | 245 i != keyword_matches.end(); ) { |
246 const TemplateURL* template_url = model->GetTemplateURLForKeyword(*i); | 246 const TemplateURL* template_url = model->GetTemplateURLForKeyword(*i); |
247 | 247 |
248 // Prune any extension keywords that are disallowed in incognito mode (if | 248 // Prune any extension keywords that are disallowed in incognito mode (if |
249 // we're incognito), or disabled. | 249 // we're incognito), or disabled. |
250 if (profile_ && template_url->IsExtensionKeyword()) { | 250 if (profile_ && template_url->IsExtensionKeyword()) { |
251 ExtensionService* service = profile_->GetExtensionService(); | 251 ExtensionService* service = profile_->GetExtensionService(); |
252 const Extension* extension = service->GetExtensionById( | 252 const extensions::Extension* extension = service->GetExtensionById( |
253 template_url->GetExtensionId(), false); | 253 template_url->GetExtensionId(), false); |
254 bool enabled = | 254 bool enabled = |
255 extension && (!profile_->IsOffTheRecord() || | 255 extension && (!profile_->IsOffTheRecord() || |
256 service->IsIncognitoEnabled(extension->id())); | 256 service->IsIncognitoEnabled(extension->id())); |
257 if (!enabled) { | 257 if (!enabled) { |
258 i = keyword_matches.erase(i); | 258 i = keyword_matches.erase(i); |
259 continue; | 259 continue; |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 580 } |
581 | 581 |
582 void KeywordProvider::MaybeEndExtensionKeywordMode() { | 582 void KeywordProvider::MaybeEndExtensionKeywordMode() { |
583 if (!current_keyword_extension_id_.empty()) { | 583 if (!current_keyword_extension_id_.empty()) { |
584 extensions::ExtensionOmniboxEventRouter::OnInputCancelled( | 584 extensions::ExtensionOmniboxEventRouter::OnInputCancelled( |
585 profile_, current_keyword_extension_id_); | 585 profile_, current_keyword_extension_id_); |
586 | 586 |
587 current_keyword_extension_id_.clear(); | 587 current_keyword_extension_id_.clear(); |
588 } | 588 } |
589 } | 589 } |
OLD | NEW |