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

Unified Diff: chrome/browser/autocomplete/keyword_provider.h

Issue 2078021: First pass at experimental omnibox API. There are plenty of rough edges and (Closed)
Patch Set: no prefer_keyword Created 10 years, 7 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/autocomplete_edit.cc ('k') | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/keyword_provider.h
diff --git a/chrome/browser/autocomplete/keyword_provider.h b/chrome/browser/autocomplete/keyword_provider.h
index adf81d8da5f7b6fafecd36af8066499ef32c6a58..6fb744b304813a58a83c0d24c5795eb1f4a36f3b 100644
--- a/chrome/browser/autocomplete/keyword_provider.h
+++ b/chrome/browser/autocomplete/keyword_provider.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
//
@@ -18,6 +18,7 @@
#include <string>
#include "chrome/browser/autocomplete/autocomplete.h"
+#include "chrome/common/notification_registrar.h"
class Profile;
class TemplateURL;
@@ -45,7 +46,9 @@ class TemplateURLModel;
// action "[keyword] %s". If the user has typed a (possibly partial) keyword
// but no search terms, the suggested result is shown greyed out, with
// "<enter term(s)>" as the substituted input, and does nothing when selected.
-class KeywordProvider : public AutocompleteProvider {
+class KeywordProvider :
+ public AutocompleteProvider,
+ public NotificationObserver {
public:
KeywordProvider(ACProviderListener* listener, Profile* profile);
// For testing.
@@ -103,17 +106,39 @@ class KeywordProvider : public AutocompleteProvider {
bool no_query_text_needed);
// Creates a fully marked-up AutocompleteMatch from the user's input.
+ // If |relevance| is negative, calculate a relevance based on heuristics.
AutocompleteMatch CreateAutocompleteMatch(
TemplateURLModel* model,
const std::wstring keyword,
const AutocompleteInput& input,
size_t prefix_length,
- const std::wstring& remaining_input);
+ const std::wstring& remaining_input,
+ int relevance);
+
+ // NotificationObserver interface.
+ void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
// Model for the keywords. This is only non-null when testing, otherwise the
// TemplateURLModel from the Profile is used.
TemplateURLModel* model_;
+ // Identifies the current input state. This is incremented each time the
+ // autocomplete edit's input changes in any way. It is used to tell whether
+ // suggest results from the extension are current.
+ int current_input_id_;
+
+ // The input state at the time we last asked the extension for suggest
+ // results.
+ AutocompleteInput extension_suggest_last_input_;
+
+ // We remember the last suggestions we've received from the extension in case
+ // we need to reset our matches without asking the extension again.
+ std::vector<AutocompleteMatch> extension_suggest_matches_;
+
+ NotificationRegistrar registrar_;
+
DISALLOW_EVIL_CONSTRUCTORS(KeywordProvider);
};
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit.cc ('k') | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698