OLD | NEW |
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" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 }; | 83 }; |
84 | 84 |
85 ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile) | 85 ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile) |
86 : controller_(new AutocompleteController( | 86 : controller_(new AutocompleteController( |
87 profile, TemplateURLServiceFactory::GetForProfile(profile), this, | 87 profile, TemplateURLServiceFactory::GetForProfile(profile), this, |
88 AutocompleteProvider::TYPE_ZERO_SUGGEST)) { | 88 AutocompleteProvider::TYPE_ZERO_SUGGEST)) { |
89 // Creating an arbitrary fake_request_source to avoid passing in an invalid | 89 // Creating an arbitrary fake_request_source to avoid passing in an invalid |
90 // AutocompleteInput object. | 90 // AutocompleteInput object. |
91 base::string16 fake_request_source(base::ASCIIToUTF16( | 91 base::string16 fake_request_source(base::ASCIIToUTF16( |
92 "http://www.foobarbazblah.com")); | 92 "http://www.foobarbazblah.com")); |
93 controller_->StartZeroSuggest(AutocompleteInput( | 93 controller_->StartOnOmniboxFocus(AutocompleteInput( |
94 fake_request_source, base::string16::npos, std::string(), | 94 fake_request_source, base::string16::npos, std::string(), |
95 GURL(fake_request_source), OmniboxEventProto::INVALID_SPEC, false, false, | 95 GURL(fake_request_source), OmniboxEventProto::INVALID_SPEC, false, false, |
96 true, true, ChromeAutocompleteSchemeClassifier(profile))); | 96 true, true, ChromeAutocompleteSchemeClassifier(profile))); |
97 // Delete ourselves after 10s. This is enough time to cache results or | 97 // Delete ourselves after 10s. This is enough time to cache results or |
98 // give up if the results haven't been received. | 98 // give up if the results haven't been received. |
99 expire_timer_.Start(FROM_HERE, | 99 expire_timer_.Start(FROM_HERE, |
100 base::TimeDelta::FromMilliseconds(10000), | 100 base::TimeDelta::FromMilliseconds(10000), |
101 this, &ZeroSuggestPrefetcher::SelfDestruct); | 101 this, &ZeroSuggestPrefetcher::SelfDestruct); |
102 } | 102 } |
103 | 103 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 return; | 556 return; |
557 | 557 |
558 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. | 558 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. |
559 new ZeroSuggestPrefetcher(profile); | 559 new ZeroSuggestPrefetcher(profile); |
560 } | 560 } |
561 | 561 |
562 // Register native methods | 562 // Register native methods |
563 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { | 563 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { |
564 return RegisterNativesImpl(env); | 564 return RegisterNativesImpl(env); |
565 } | 565 } |
OLD | NEW |