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

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

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Enabled pressing TAB to cycle through the Omnibox results, removed moving the caret to the Created 9 years, 8 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "unicode/ubidi.h" 9 #include "unicode/ubidi.h"
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match, 131 bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
132 string16* keyword) const { 132 string16* keyword) const {
133 // Assume we have no keyword until we find otherwise. 133 // Assume we have no keyword until we find otherwise.
134 keyword->clear(); 134 keyword->clear();
135 135
136 // If the current match is a keyword, return that as the selected keyword. 136 // If the current match is a keyword, return that as the selected keyword.
137 if (TemplateURL::SupportsReplacement(match.template_url)) { 137 if (TemplateURL::SupportsReplacement(match.template_url)) {
138 keyword->assign(match.template_url->keyword()); 138 keyword->assign(match.template_url->keyword());
139 match.keyword.assign(*keyword);
139 return false; 140 return false;
140 } 141 }
141 142
142 // See if the current match's fill_into_edit corresponds to a keyword. 143 // See if the current match's fill_into_edit corresponds to a keyword.
143 if (!profile_->GetTemplateURLModel()) 144 if (!profile_->GetTemplateURLModel())
144 return false; 145 return false;
145 profile_->GetTemplateURLModel()->Load(); 146 profile_->GetTemplateURLModel()->Load();
146 const string16 keyword_hint(TemplateURLModel::CleanUserInputKeyword( 147 const string16 keyword_hint(TemplateURLModel::CleanUserInputKeyword(
147 match.fill_into_edit)); 148 match.fill_into_edit));
148 if (keyword_hint.empty()) 149 if (keyword_hint.empty())
149 return false; 150 return false;
150 151
151 // Don't provide a hint if this keyword doesn't support replacement. 152 // Don't provide a hint if this keyword doesn't support replacement.
152 const TemplateURL* const template_url = 153 const TemplateURL* const template_url =
153 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint); 154 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint);
154 if (!TemplateURL::SupportsReplacement(template_url)) 155 if (!TemplateURL::SupportsReplacement(template_url))
155 return false; 156 return false;
156 157
157 // Don't provide a hint for inactive/disabled extension keywords. 158 // Don't provide a hint for inactive/disabled extension keywords.
158 if (template_url->IsExtensionKeyword()) { 159 if (template_url->IsExtensionKeyword()) {
159 const Extension* extension = profile_->GetExtensionService()-> 160 const Extension* extension = profile_->GetExtensionService()->
160 GetExtensionById(template_url->GetExtensionId(), false); 161 GetExtensionById(template_url->GetExtensionId(), false);
161 if (!extension || 162 if (!extension ||
162 (profile_->IsOffTheRecord() && 163 (profile_->IsOffTheRecord() &&
163 !profile_->GetExtensionService()->IsIncognitoEnabled(extension))) 164 !profile_->GetExtensionService()->IsIncognitoEnabled(extension)))
164 return false; 165 return false;
165 } 166 }
166 167
167 keyword->assign(keyword_hint); 168 keyword->assign(keyword_hint);
169 match.keyword.assign(keyword_hint);
168 return true; 170 return true;
169 } 171 }
170 172
171 void AutocompletePopupModel::Move(int count) { 173 void AutocompletePopupModel::Move(int count) {
172 const AutocompleteResult& result = this->result(); 174 const AutocompleteResult& result = this->result();
173 if (result.empty()) 175 if (result.empty())
174 return; 176 return;
175 177
176 // The user is using the keyboard to change the selection, so stop tracking 178 // The user is using the keyboard to change the selection, so stop tracking
177 // hover. 179 // hover.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 CHECK((selected_line_ != kNoMatch) || result.empty()); 234 CHECK((selected_line_ != kNoMatch) || result.empty());
233 manually_selected_match_.Clear(); 235 manually_selected_match_.Clear();
234 // If we're going to trim the window size to no longer include the hovered 236 // If we're going to trim the window size to no longer include the hovered
235 // line, turn hover off. Practically, this shouldn't happen, but it 237 // line, turn hover off. Practically, this shouldn't happen, but it
236 // doesn't hurt to be defensive. 238 // doesn't hurt to be defensive.
237 if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_)) 239 if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_))
238 SetHoveredLine(kNoMatch); 240 SetHoveredLine(kNoMatch);
239 241
240 view_->UpdatePopupAppearance(); 242 view_->UpdatePopupAppearance();
241 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698