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

Unified Diff: athena/main/url_search_provider.cc

Issue 584263002: Use ChromeAutocompleteSchemeClassifier for Athena on Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 3 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 | « athena/content/shell/scheme_classifier_factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/main/url_search_provider.cc
diff --git a/athena/main/url_search_provider.cc b/athena/main/url_search_provider.cc
index 39819bd9a9b0a2058691c27461a6c616f650b363..5fcea5a0efd6031949cf1b953f75a91f7ac9601c 100644
--- a/athena/main/url_search_provider.cc
+++ b/athena/main/url_search_provider.cc
@@ -6,13 +6,13 @@
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
+#include "athena/content/public/scheme_classifier_factory.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "components/omnibox/autocomplete_input.h"
#include "components/omnibox/autocomplete_provider_client.h"
-#include "components/omnibox/autocomplete_scheme_classifier.h"
#include "components/omnibox/search_provider.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url_service.h"
@@ -39,21 +39,6 @@ class AthenaSearchTermsData : public SearchTermsData {
}
};
-// The AutocompleteSchemeClassifier implementation for Athena.
-// TODO(mukai): Introduce supports of normal schemes like about: or blob:
-class AthenaSchemeClassifier : public AutocompleteSchemeClassifier {
- public:
- AthenaSchemeClassifier() {}
-
- // AutocompleteSchemeClassifier:
- virtual metrics::OmniboxInputType::Type GetInputTypeForScheme(
- const std::string& scheme) const OVERRIDE {
- if (net::URLRequest::IsHandledProtocol(scheme))
- return metrics::OmniboxInputType::URL;
- return metrics::OmniboxInputType::INVALID;
- }
-};
-
// The templateURLServiceClient for Athena. Mainly for the interaction with
// history module (see chrome/browser/search_engines for Chrome implementation).
// TODO(mukai): Implement the contents of this class when it's necessary.
@@ -82,7 +67,8 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient {
public:
explicit AthenaAutocompleteProviderClient(
content::BrowserContext* browser_context)
- : browser_context_(browser_context) {}
+ : browser_context_(browser_context),
+ scheme_classifier_(CreateSchemeClassifier(browser_context)) {}
virtual ~AthenaAutocompleteProviderClient() {}
virtual net::URLRequestContextGetter* RequestContext() OVERRIDE {
@@ -98,7 +84,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient {
virtual bool SearchSuggestEnabled() OVERRIDE { return true; }
virtual bool ShowBookmarkBar() OVERRIDE { return false; }
virtual const AutocompleteSchemeClassifier& SchemeClassifier() OVERRIDE {
- return scheme_classifier_;
+ return *scheme_classifier_;
}
virtual void Classify(
const base::string16& text,
@@ -116,7 +102,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient {
private:
content::BrowserContext* browser_context_;
- AthenaSchemeClassifier scheme_classifier_;
+ scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier_;
DISALLOW_COPY_AND_ASSIGN(AthenaAutocompleteProviderClient);
};
@@ -246,6 +232,8 @@ UrlSearchProvider::~UrlSearchProvider() {
void UrlSearchProvider::Start(const base::string16& query) {
const bool minimal_changes = query == input_.text();
+ scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier(
+ CreateSchemeClassifier(browser_context_));
input_ = AutocompleteInput(query,
base::string16::npos /* cursor_position */,
base::string16() /* desired_tld */,
@@ -255,20 +243,12 @@ void UrlSearchProvider::Start(const base::string16& query) {
false /* prefer_keyword */,
true /* allow_extract_keyword_match */,
true /* want_asynchronous_matches */,
- AthenaSchemeClassifier());
-
- provider_->Start(input_, minimal_changes);
-}
+ *scheme_classifier);
-void UrlSearchProvider::Stop() {
- provider_->Stop(false);
-}
-
-void UrlSearchProvider::OnProviderUpdate(bool updated_matches) {
- if (!updated_matches)
- return;
-
- ClearResults();
+ // Clearing results here may cause unexpected results.
+ // TODO(mukai): fix this by fixing crbug.com/415500
+ if (!minimal_changes)
+ ClearResults();
if (input_.type() == metrics::OmniboxInputType::URL) {
// TODO(hashimoto): Componentize HistoryURLProvider and remove this code.
@@ -281,6 +261,17 @@ void UrlSearchProvider::OnProviderUpdate(bool updated_matches) {
browser_context_, what_you_typed_match)));
}
+ provider_->Start(input_, minimal_changes);
+}
+
+void UrlSearchProvider::Stop() {
+ provider_->Stop(false);
+}
+
+void UrlSearchProvider::OnProviderUpdate(bool updated_matches) {
+ if (!updated_matches)
+ return;
+
const ACMatches& matches = provider_->matches();
for (ACMatches::const_iterator it = matches.begin(); it != matches.end();
++it) {
« no previous file with comments | « athena/content/shell/scheme_classifier_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698