| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 /** | 66 /** |
| 67 * A prefetcher class responsible for triggering zero suggest prefetch. | 67 * A prefetcher class responsible for triggering zero suggest prefetch. |
| 68 * The prefetch occurs as a side-effect of calling OnOmniboxFocused() on | 68 * The prefetch occurs as a side-effect of calling OnOmniboxFocused() on |
| 69 * the AutocompleteController object. | 69 * the AutocompleteController object. |
| 70 */ | 70 */ |
| 71 class ZeroSuggestPrefetcher : public AutocompleteControllerDelegate { | 71 class ZeroSuggestPrefetcher : public AutocompleteControllerDelegate { |
| 72 public: | 72 public: |
| 73 explicit ZeroSuggestPrefetcher(Profile* profile); | 73 explicit ZeroSuggestPrefetcher(Profile* profile); |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 virtual ~ZeroSuggestPrefetcher(); | 76 ~ZeroSuggestPrefetcher() override; |
| 77 void SelfDestruct(); | 77 void SelfDestruct(); |
| 78 | 78 |
| 79 // AutocompleteControllerDelegate: | 79 // AutocompleteControllerDelegate: |
| 80 virtual void OnResultChanged(bool default_match_changed) override; | 80 void OnResultChanged(bool default_match_changed) override; |
| 81 | 81 |
| 82 scoped_ptr<AutocompleteController> controller_; | 82 scoped_ptr<AutocompleteController> controller_; |
| 83 base::OneShotTimer<ZeroSuggestPrefetcher> expire_timer_; | 83 base::OneShotTimer<ZeroSuggestPrefetcher> expire_timer_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile) | 86 ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile) |
| 87 : controller_(new AutocompleteController( | 87 : controller_(new AutocompleteController( |
| 88 profile, TemplateURLServiceFactory::GetForProfile(profile), this, | 88 profile, TemplateURLServiceFactory::GetForProfile(profile), this, |
| 89 AutocompleteProvider::TYPE_ZERO_SUGGEST)) { | 89 AutocompleteProvider::TYPE_ZERO_SUGGEST)) { |
| 90 // Creating an arbitrary fake_request_source to avoid passing in an invalid | 90 // Creating an arbitrary fake_request_source to avoid passing in an invalid |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 return; | 549 return; |
| 550 | 550 |
| 551 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. | 551 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. |
| 552 new ZeroSuggestPrefetcher(profile); | 552 new ZeroSuggestPrefetcher(profile); |
| 553 } | 553 } |
| 554 | 554 |
| 555 // Register native methods | 555 // Register native methods |
| 556 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { | 556 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { |
| 557 return RegisterNativesImpl(env); | 557 return RegisterNativesImpl(env); |
| 558 } | 558 } |
| OLD | NEW |