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

Unified Diff: chrome/browser/autocomplete/keyword_provider.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.h ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/keyword_provider.cc
===================================================================
--- chrome/browser/autocomplete/keyword_provider.cc (revision 13665)
+++ chrome/browser/autocomplete/keyword_provider.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -61,14 +61,29 @@
} // namespace
+// static
+const TemplateURL* KeywordProvider::GetSubstitutingTemplateURLForInput(
+ Profile* profile,
+ const AutocompleteInput& input,
+ std::wstring* remaining_input) {
+ std::wstring keyword;
+ if (!ExtractKeywordFromInput(input, &keyword, remaining_input))
+ return NULL;
+
+ // Make sure the model is loaded. This is cheap and quickly bails out if
+ // the model is already loaded.
+ TemplateURLModel* model = profile->GetTemplateURLModel();
+ DCHECK(model);
+ model->Load();
+
+ const TemplateURL* template_url = model->GetTemplateURLForKeyword(keyword);
+ return TemplateURL::SupportsReplacement(template_url) ? template_url : NULL;
+}
+
void KeywordProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
- return;
-
// Split user input into a keyword and some query input.
//
// We want to suggest keywords even when users have started typing URLs, on
@@ -82,10 +97,8 @@
// keywords, we might suggest keywords that haven't even been partially typed,
// if the user uses them enough and isn't obviously typing something else. In
// this case we'd consider all input here to be query input.
- std::wstring remaining_input;
- std::wstring keyword(TemplateURLModel::CleanUserInputKeyword(
- SplitKeywordFromInput(input.text(), &remaining_input)));
- if (keyword.empty())
+ std::wstring keyword, remaining_input;
+ if (!ExtractKeywordFromInput(input, &keyword, &remaining_input))
return;
// Make sure the model is loaded. This is cheap and quickly bails out if
@@ -134,6 +147,19 @@
}
// static
+bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
+ std::wstring* keyword,
+ std::wstring* remaining_input) {
+ if ((input.type() == AutocompleteInput::INVALID) ||
+ (input.type() == AutocompleteInput::FORCED_QUERY))
+ return false;
+
+ *keyword = TemplateURLModel::CleanUserInputKeyword(
+ SplitKeywordFromInput(input.text(), remaining_input));
+ return !keyword->empty();
+}
+
+// static
std::wstring KeywordProvider::SplitKeywordFromInput(
const std::wstring& input,
std::wstring* remaining_input) {
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.h ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698