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

Side by Side Diff: chrome/browser/android/omnibox/autocomplete_controller_android.cc

Issue 1192373002: Prepare AutocompleteController for componentization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@componentize_zero_suggest_provider
Patch Set: Remove stale include Created 5 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/android/omnibox/autocomplete_controller_android.h" 5 #include "chrome/browser/android/omnibox/autocomplete_controller_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
16 #include "chrome/browser/autocomplete/autocomplete_controller.h" 16 #include "chrome/browser/autocomplete/autocomplete_controller.h"
17 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 18 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" 19 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 20 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/profiles/incognito_helpers.h" 23 #include "chrome/browser/profiles/incognito_helpers.h"
23 #include "chrome/browser/profiles/profile_android.h" 24 #include "chrome/browser/profiles/profile_android.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/search/search.h" 26 #include "chrome/browser/search/search.h"
26 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 79
79 // AutocompleteControllerDelegate: 80 // AutocompleteControllerDelegate:
80 void OnResultChanged(bool default_match_changed) override; 81 void OnResultChanged(bool default_match_changed) override;
81 82
82 scoped_ptr<AutocompleteController> controller_; 83 scoped_ptr<AutocompleteController> controller_;
83 base::OneShotTimer<ZeroSuggestPrefetcher> expire_timer_; 84 base::OneShotTimer<ZeroSuggestPrefetcher> expire_timer_;
84 }; 85 };
85 86
86 ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile) 87 ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile)
87 : controller_(new AutocompleteController( 88 : controller_(new AutocompleteController(
88 profile, TemplateURLServiceFactory::GetForProfile(profile), this, 89 make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)),
90 this,
89 AutocompleteProvider::TYPE_ZERO_SUGGEST)) { 91 AutocompleteProvider::TYPE_ZERO_SUGGEST)) {
90 // Creating an arbitrary fake_request_source to avoid passing in an invalid 92 // Creating an arbitrary fake_request_source to avoid passing in an invalid
91 // AutocompleteInput object. 93 // AutocompleteInput object.
92 base::string16 fake_request_source(base::ASCIIToUTF16( 94 base::string16 fake_request_source(base::ASCIIToUTF16(
93 "http://www.foobarbazblah.com")); 95 "http://www.foobarbazblah.com"));
94 controller_->Start(AutocompleteInput( 96 controller_->Start(AutocompleteInput(
95 fake_request_source, base::string16::npos, std::string(), 97 fake_request_source, base::string16::npos, std::string(),
96 GURL(fake_request_source), OmniboxEventProto::INVALID_SPEC, false, false, 98 GURL(fake_request_source), OmniboxEventProto::INVALID_SPEC, false, false,
97 true, true, true, ChromeAutocompleteSchemeClassifier(profile))); 99 true, true, true, ChromeAutocompleteSchemeClassifier(profile)));
98 // Delete ourselves after 10s. This is enough time to cache results or 100 // Delete ourselves after 10s. This is enough time to cache results or
(...skipping 13 matching lines...) Expand all
112 void ZeroSuggestPrefetcher::OnResultChanged(bool default_match_changed) { 114 void ZeroSuggestPrefetcher::OnResultChanged(bool default_match_changed) {
113 // Nothing to do here, the results have been cached. 115 // Nothing to do here, the results have been cached.
114 // We don't want to trigger deletion here because this is being called by the 116 // We don't want to trigger deletion here because this is being called by the
115 // AutocompleteController object. 117 // AutocompleteController object.
116 } 118 }
117 119
118 } // namespace 120 } // namespace
119 121
120 AutocompleteControllerAndroid::AutocompleteControllerAndroid(Profile* profile) 122 AutocompleteControllerAndroid::AutocompleteControllerAndroid(Profile* profile)
121 : autocomplete_controller_(new AutocompleteController( 123 : autocomplete_controller_(new AutocompleteController(
122 profile, TemplateURLServiceFactory::GetForProfile(profile), this, 124 make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)),
125 this,
123 kAndroidAutocompleteProviders)), 126 kAndroidAutocompleteProviders)),
124 inside_synchronous_start_(false), 127 inside_synchronous_start_(false),
125 profile_(profile) { 128 profile_(profile) {
126 } 129 }
127 130
128 void AutocompleteControllerAndroid::Start(JNIEnv* env, 131 void AutocompleteControllerAndroid::Start(JNIEnv* env,
129 jobject obj, 132 jobject obj,
130 jstring j_text, 133 jstring j_text,
131 jint j_cursor_pos, 134 jint j_cursor_pos,
132 jstring j_desired_tld, 135 jstring j_desired_tld,
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 return; 554 return;
552 555
553 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. 556 // ZeroSuggestPrefetcher deletes itself after it's done prefetching.
554 new ZeroSuggestPrefetcher(profile); 557 new ZeroSuggestPrefetcher(profile);
555 } 558 }
556 559
557 // Register native methods 560 // Register native methods
558 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { 561 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) {
559 return RegisterNativesImpl(env); 562 return RegisterNativesImpl(env);
560 } 563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698