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

Unified Diff: chrome/browser/autocomplete/autocomplete_controller.cc

Issue 10832256: Experimental AutocompleteProvider for zerosuggest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix constant name. Created 8 years, 4 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
Index: chrome/browser/autocomplete/autocomplete_controller.cc
diff --git a/chrome/browser/autocomplete/autocomplete_controller.cc b/chrome/browser/autocomplete/autocomplete_controller.cc
index 8bfa3518cefe099f0094e51434f635d30221a354..ba6c306be243d7db36ef0f59d4043fb6196ed88c 100644
--- a/chrome/browser/autocomplete/autocomplete_controller.cc
+++ b/chrome/browser/autocomplete/autocomplete_controller.cc
@@ -7,6 +7,7 @@
#include <set>
#include <string>
+#include "base/command_line.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
@@ -22,9 +23,11 @@
#include "chrome/browser/autocomplete/keyword_provider.h"
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/autocomplete/shortcuts_provider.h"
+#include "chrome/browser/autocomplete/zero_suggest_provider.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -76,6 +79,7 @@ AutocompleteController::AutocompleteController(
AutocompleteControllerDelegate* delegate)
: delegate_(delegate),
keyword_provider_(NULL),
+ zero_suggest_provider_(NULL),
done_(true),
in_start_(false),
profile_(profile) {
@@ -101,6 +105,13 @@ AutocompleteController::AutocompleteController(
providers_.push_back(new HistoryContentsProvider(this, profile, hqp_enabled));
providers_.push_back(new BuiltinProvider(this, profile));
providers_.push_back(new ExtensionAppProvider(this, profile));
+ // Create ZeroSuggest if its switch is present.
+ CommandLine* cl = CommandLine::ForCurrentProcess();
+ if (cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) {
+ zero_suggest_provider_ = new ZeroSuggestProvider(this, profile,
+ cl->GetSwitchValueASCII(switches::kExperimentalZeroSuggestURLPrefix));
+ providers_.push_back(zero_suggest_provider_);
+ }
for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i)
(*i)->AddRef();
}
@@ -189,6 +200,18 @@ void AutocompleteController::Stop(bool clear_result) {
}
}
+void AutocompleteController::StartZeroSuggest(
+ const GURL& url,
+ const string16& user_text) {
+ if (zero_suggest_provider_ != NULL)
+ zero_suggest_provider_->StartZeroSuggest(url, user_text);
+}
+
+void AutocompleteController::StopZeroSuggest() {
+ if (zero_suggest_provider_ != NULL)
+ zero_suggest_provider_->Stop(false);
+}
+
void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) {
DCHECK(match.deletable);
match.provider->DeleteMatch(match); // This may synchronously call back to

Powered by Google App Engine
This is Rietveld 408576698