Index: chrome/browser/autocomplete/autocomplete_popup_model.cc |
=================================================================== |
--- chrome/browser/autocomplete/autocomplete_popup_model.cc (revision 81359) |
+++ chrome/browser/autocomplete/autocomplete_popup_model.cc (working copy) |
@@ -100,8 +100,6 @@ |
// Update the edit with the new data for this match. |
// TODO(pkasting): If |selected_line_| moves to the controller, this can be |
// eliminated and just become a call to the observer on the edit. |
- string16 keyword; |
- const bool is_keyword_hint = GetKeywordForMatch(match, &keyword); |
if (reset_to_default) { |
string16 inline_autocomplete_text; |
if ((match.inline_autocomplete_offset != string16::npos) && |
@@ -110,10 +108,10 @@ |
match.fill_into_edit.substr(match.inline_autocomplete_offset); |
} |
edit_model_->OnPopupDataChanged(inline_autocomplete_text, NULL, |
- keyword, is_keyword_hint); |
+ match.keyword, match.has_keyword_hint()); |
} else { |
edit_model_->OnPopupDataChanged(match.fill_into_edit, ¤t_destination, |
- keyword, is_keyword_hint); |
+ match.keyword, match.has_keyword_hint()); |
} |
// Repaint old and new selected lines immediately, so that the edit doesn't |
@@ -128,53 +126,6 @@ |
view_->OnDragCanceled(); |
} |
-bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match, |
- string16* keyword) const { |
- // If the current match is a keyword, return that as the selected keyword. |
- if (TemplateURL::SupportsReplacement(match.template_url)) { |
- keyword->assign(match.template_url->keyword()); |
- return false; |
- } |
- |
- // See if the current match's fill_into_edit corresponds to a keyword. |
- return GetKeywordForText(match.fill_into_edit, keyword); |
-} |
- |
-bool AutocompletePopupModel::GetKeywordForText(const string16& text, |
- string16* keyword) const { |
- // Creates keyword_hint first in case |keyword| is a pointer to |text|. |
- const string16 keyword_hint(TemplateURLModel::CleanUserInputKeyword(text)); |
- |
- // Assume we have no keyword until we find otherwise. |
- keyword->clear(); |
- |
- if (keyword_hint.empty()) |
- return false; |
- if (!profile_->GetTemplateURLModel()) |
- return false; |
- profile_->GetTemplateURLModel()->Load(); |
- |
- // Don't provide a hint if this keyword doesn't support replacement. |
- const TemplateURL* const template_url = |
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint); |
- if (!TemplateURL::SupportsReplacement(template_url)) |
- return false; |
- |
- // Don't provide a hint for inactive/disabled extension keywords. |
- if (template_url->IsExtensionKeyword()) { |
- const Extension* extension = profile_->GetExtensionService()-> |
- GetExtensionById(template_url->GetExtensionId(), false); |
- if (!extension || |
- (profile_->IsOffTheRecord() && |
- !profile_->GetExtensionService()-> |
- IsIncognitoEnabled(extension->id()))) |
- return false; |
- } |
- |
- keyword->assign(keyword_hint); |
- return true; |
-} |
- |
void AutocompletePopupModel::Move(int count) { |
const AutocompleteResult& result = this->result(); |
if (result.empty()) |
@@ -224,11 +175,13 @@ |
const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch( |
const AutocompleteMatch& match) const { |
- if (!match.template_url || !match.template_url->IsExtensionKeyword()) |
+ if (!match.keyword_url || |
+ (match.keyword_state == AutocompleteMatch::KEYWORD && |
+ !match.keyword_url->IsExtensionKeyword())) |
return NULL; |
return &profile_->GetExtensionService()->GetOmniboxPopupIcon( |
- match.template_url->GetExtensionId()); |
+ match.keyword_url->GetExtensionId()); |
} |
void AutocompletePopupModel::OnResultChanged() { |