Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_model.cc

Issue 5511007: Fix a browser crash when typing a disabled extension keyword in an (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/autocomplete_popup_model.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
6 6
7 #include "unicode/ubidi.h" 7 #include "unicode/ubidi.h"
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/autocomplete/autocomplete_edit.h" 10 #include "chrome/browser/autocomplete/autocomplete_edit.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 TemplateURLModel::CleanUserInputKeyword(match.fill_into_edit)); 215 TemplateURLModel::CleanUserInputKeyword(match.fill_into_edit));
216 if (keyword_hint.empty()) 216 if (keyword_hint.empty())
217 return false; 217 return false;
218 218
219 // Don't provide a hint if this keyword doesn't support replacement. 219 // Don't provide a hint if this keyword doesn't support replacement.
220 const TemplateURL* const template_url = 220 const TemplateURL* const template_url =
221 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint); 221 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint);
222 if (!TemplateURL::SupportsReplacement(template_url)) 222 if (!TemplateURL::SupportsReplacement(template_url))
223 return false; 223 return false;
224 224
225 // Don't provide a hint if this is an extension keyword not enabled for 225 // Don't provide a hint for inactive/disabled extension keywords.
226 // incognito mode (and if this is an incognito profile). 226 if (template_url->IsExtensionKeyword()) {
227 if (template_url->IsExtensionKeyword() && profile_->IsOffTheRecord()) {
228 const Extension* extension = profile_->GetExtensionsService()-> 227 const Extension* extension = profile_->GetExtensionsService()->
229 GetExtensionById(template_url->GetExtensionId(), false); 228 GetExtensionById(template_url->GetExtensionId(), false);
230 if (!profile_->GetExtensionsService()->IsIncognitoEnabled(extension)) 229 if (!extension ||
230 (profile_->IsOffTheRecord() &&
231 !profile_->GetExtensionsService()->IsIncognitoEnabled(extension)))
231 return false; 232 return false;
232 } 233 }
233 234
234 keyword->assign(keyword_hint); 235 keyword->assign(keyword_hint);
235 return true; 236 return true;
236 } 237 }
237 238
238 void AutocompletePopupModel::FinalizeInstantQuery(const std::wstring& text) { 239 void AutocompletePopupModel::FinalizeInstantQuery(const std::wstring& text) {
239 if (IsOpen()) { 240 if (IsOpen()) {
240 SearchProvider* search_provider = controller_->search_provider(); 241 SearchProvider* search_provider = controller_->search_provider();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 316 }
316 317
317 const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( 318 const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch(
318 const AutocompleteMatch& match) const { 319 const AutocompleteMatch& match) const {
319 if (!match.template_url || !match.template_url->IsExtensionKeyword()) 320 if (!match.template_url || !match.template_url->IsExtensionKeyword())
320 return NULL; 321 return NULL;
321 322
322 return &profile_->GetExtensionsService()->GetOmniboxPopupIcon( 323 return &profile_->GetExtensionsService()->GetOmniboxPopupIcon(
323 match.template_url->GetExtensionId()); 324 match.template_url->GetExtensionId());
324 } 325 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698