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

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

Issue 66073: Makes the omnibox show past searches and suggestions for keywords.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" 8 #include "chrome/browser/autocomplete/autocomplete_edit.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_view.h"
10 #include "chrome/browser/net/dns_global.h" 10 #include "chrome/browser/net/dns_global.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 *alternate_nav_url = result.GetAlternateNavURL(controller_->input(), match); 205 *alternate_nav_url = result.GetAlternateNavURL(controller_->input(), match);
206 return match->destination_url; 206 return match->destination_url;
207 } 207 }
208 208
209 bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match, 209 bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
210 std::wstring* keyword) const { 210 std::wstring* keyword) const {
211 // Assume we have no keyword until we find otherwise. 211 // Assume we have no keyword until we find otherwise.
212 keyword->clear(); 212 keyword->clear();
213 213
214 // If the current match is a keyword, return that as the selected keyword. 214 // If the current match is a keyword, return that as the selected keyword.
215 if (match.template_url && match.template_url->url() && 215 if (TemplateURL::SupportsReplacement(match.template_url)) {
216 match.template_url->url()->SupportsReplacement()) {
217 keyword->assign(match.template_url->keyword()); 216 keyword->assign(match.template_url->keyword());
218 return false; 217 return false;
219 } 218 }
220 219
221 // See if the current match's fill_into_edit corresponds to a keyword. 220 // See if the current match's fill_into_edit corresponds to a keyword.
222 if (!profile_->GetTemplateURLModel()) 221 if (!profile_->GetTemplateURLModel())
223 return false; 222 return false;
224 profile_->GetTemplateURLModel()->Load(); 223 profile_->GetTemplateURLModel()->Load();
225 const std::wstring keyword_hint( 224 const std::wstring keyword_hint(
226 TemplateURLModel::CleanUserInputKeyword(match.fill_into_edit)); 225 TemplateURLModel::CleanUserInputKeyword(match.fill_into_edit));
227 if (keyword_hint.empty()) 226 if (keyword_hint.empty())
228 return false; 227 return false;
229 228
230 // Don't provide a hint if this keyword doesn't support replacement. 229 // Don't provide a hint if this keyword doesn't support replacement.
231 const TemplateURL* const template_url = 230 const TemplateURL* const template_url =
232 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint); 231 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint);
233 if (!template_url || !template_url->url() || 232 if (!TemplateURL::SupportsReplacement(template_url))
234 !template_url->url()->SupportsReplacement())
235 return false; 233 return false;
236 234
237 keyword->assign(keyword_hint); 235 keyword->assign(keyword_hint);
238 return true; 236 return true;
239 } 237 }
240 238
241 AutocompleteLog* AutocompletePopupModel::GetAutocompleteLog() { 239 AutocompleteLog* AutocompletePopupModel::GetAutocompleteLog() {
242 return new AutocompleteLog(controller_->input().text(), 240 return new AutocompleteLog(controller_->input().text(),
243 controller_->input().type(), selected_line_, 0, controller_->result()); 241 controller_->input().type(), selected_line_, 0, controller_->result());
244 } 242 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 340 }
343 edit_model_->OnPopupDataChanged(inline_autocomplete_text, false, keyword, 341 edit_model_->OnPopupDataChanged(inline_autocomplete_text, false, keyword,
344 is_keyword_hint, type); 342 is_keyword_hint, type);
345 return; 343 return;
346 } 344 }
347 345
348 default: 346 default:
349 NOTREACHED(); 347 NOTREACHED();
350 } 348 }
351 } 349 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.h ('k') | chrome/browser/autocomplete/keyword_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698