| 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/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" |
| 11 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 13 #include "chrome/browser/autocomplete/search_provider.h" | 13 #include "chrome/browser/autocomplete/search_provider.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/extensions/extensions_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/search_engines/template_url.h" | 16 #include "chrome/browser/search_engines/template_url.h" |
| 17 #include "chrome/browser/search_engines/template_url_model.h" | 17 #include "chrome/browser/search_engines/template_url_model.h" |
| 18 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
| 19 #include "gfx/rect.h" | 19 #include "gfx/rect.h" |
| 20 | 20 |
| 21 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
| 22 // AutocompletePopupModel | 22 // AutocompletePopupModel |
| 23 | 23 |
| 24 AutocompletePopupModel::AutocompletePopupModel( | 24 AutocompletePopupModel::AutocompletePopupModel( |
| 25 AutocompletePopupView* popup_view, | 25 AutocompletePopupView* popup_view, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 for inactive/disabled extension keywords. | 225 // Don't provide a hint for inactive/disabled extension keywords. |
| 226 if (template_url->IsExtensionKeyword()) { | 226 if (template_url->IsExtensionKeyword()) { |
| 227 const Extension* extension = profile_->GetExtensionsService()-> | 227 const Extension* extension = profile_->GetExtensionService()-> |
| 228 GetExtensionById(template_url->GetExtensionId(), false); | 228 GetExtensionById(template_url->GetExtensionId(), false); |
| 229 if (!extension || | 229 if (!extension || |
| 230 (profile_->IsOffTheRecord() && | 230 (profile_->IsOffTheRecord() && |
| 231 !profile_->GetExtensionsService()->IsIncognitoEnabled(extension))) | 231 !profile_->GetExtensionService()->IsIncognitoEnabled(extension))) |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| 234 | 234 |
| 235 keyword->assign(keyword_hint); | 235 keyword->assign(keyword_hint); |
| 236 return true; | 236 return true; |
| 237 } | 237 } |
| 238 | 238 |
| 239 void AutocompletePopupModel::FinalizeInstantQuery( | 239 void AutocompletePopupModel::FinalizeInstantQuery( |
| 240 const std::wstring& input_text, | 240 const std::wstring& input_text, |
| 241 const std::wstring& suggest_text) { | 241 const std::wstring& suggest_text) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 view_->UpdatePopupAppearance(); | 315 view_->UpdatePopupAppearance(); |
| 316 edit_model_->ResultsUpdated(); | 316 edit_model_->ResultsUpdated(); |
| 317 edit_model_->PopupBoundsChangedTo(view_->GetTargetBounds()); | 317 edit_model_->PopupBoundsChangedTo(view_->GetTargetBounds()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( | 320 const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( |
| 321 const AutocompleteMatch& match) const { | 321 const AutocompleteMatch& match) const { |
| 322 if (!match.template_url || !match.template_url->IsExtensionKeyword()) | 322 if (!match.template_url || !match.template_url->IsExtensionKeyword()) |
| 323 return NULL; | 323 return NULL; |
| 324 | 324 |
| 325 return &profile_->GetExtensionsService()->GetOmniboxPopupIcon( | 325 return &profile_->GetExtensionService()->GetOmniboxPopupIcon( |
| 326 match.template_url->GetExtensionId()); | 326 match.template_url->GetExtensionId()); |
| 327 } | 327 } |
| OLD | NEW |