| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 using base::android::ConvertUTF16ToJavaString; | 58 using base::android::ConvertUTF16ToJavaString; |
| 59 using base::android::JavaParamRef; | 59 using base::android::JavaParamRef; |
| 60 using base::android::JavaRef; | 60 using base::android::JavaRef; |
| 61 using base::android::ScopedJavaLocalRef; | 61 using base::android::ScopedJavaLocalRef; |
| 62 using base::android::ToJavaIntArray; | 62 using base::android::ToJavaIntArray; |
| 63 using bookmarks::BookmarkModel; | 63 using bookmarks::BookmarkModel; |
| 64 using metrics::OmniboxEventProto; | 64 using metrics::OmniboxEventProto; |
| 65 | 65 |
| 66 namespace { | 66 namespace { |
| 67 | 67 |
| 68 const int kAndroidAutocompleteProviders = | |
| 69 AutocompleteClassifier::kDefaultOmniboxProviders; | |
| 70 | |
| 71 /** | 68 /** |
| 72 * A prefetcher class responsible for triggering zero suggest prefetch. | 69 * A prefetcher class responsible for triggering zero suggest prefetch. |
| 73 * The prefetch occurs as a side-effect of calling OnOmniboxFocused() on | 70 * The prefetch occurs as a side-effect of calling OnOmniboxFocused() on |
| 74 * the AutocompleteController object. | 71 * the AutocompleteController object. |
| 75 */ | 72 */ |
| 76 class ZeroSuggestPrefetcher : public AutocompleteControllerDelegate { | 73 class ZeroSuggestPrefetcher : public AutocompleteControllerDelegate { |
| 77 public: | 74 public: |
| 78 explicit ZeroSuggestPrefetcher(Profile* profile); | 75 explicit ZeroSuggestPrefetcher(Profile* profile); |
| 79 | 76 |
| 80 private: | 77 private: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // We don't want to trigger deletion here because this is being called by the | 117 // We don't want to trigger deletion here because this is being called by the |
| 121 // AutocompleteController object. | 118 // AutocompleteController object. |
| 122 } | 119 } |
| 123 | 120 |
| 124 } // namespace | 121 } // namespace |
| 125 | 122 |
| 126 AutocompleteControllerAndroid::AutocompleteControllerAndroid(Profile* profile) | 123 AutocompleteControllerAndroid::AutocompleteControllerAndroid(Profile* profile) |
| 127 : autocomplete_controller_(new AutocompleteController( | 124 : autocomplete_controller_(new AutocompleteController( |
| 128 base::WrapUnique(new ChromeAutocompleteProviderClient(profile)), | 125 base::WrapUnique(new ChromeAutocompleteProviderClient(profile)), |
| 129 this, | 126 this, |
| 130 kAndroidAutocompleteProviders)), | 127 AutocompleteClassifier::DefaultOmniboxProviders())), |
| 131 inside_synchronous_start_(false), | 128 inside_synchronous_start_(false), |
| 132 profile_(profile) {} | 129 profile_(profile) {} |
| 133 | 130 |
| 134 void AutocompleteControllerAndroid::Start( | 131 void AutocompleteControllerAndroid::Start( |
| 135 JNIEnv* env, | 132 JNIEnv* env, |
| 136 const JavaRef<jobject>& obj, | 133 const JavaRef<jobject>& obj, |
| 137 const JavaRef<jstring>& j_text, | 134 const JavaRef<jstring>& j_text, |
| 138 jint j_cursor_pos, | 135 jint j_cursor_pos, |
| 139 const JavaRef<jstring>& j_desired_tld, | 136 const JavaRef<jstring>& j_desired_tld, |
| 140 const JavaRef<jstring>& j_current_url, | 137 const JavaRef<jstring>& j_current_url, |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 return; | 594 return; |
| 598 | 595 |
| 599 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. | 596 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. |
| 600 new ZeroSuggestPrefetcher(profile); | 597 new ZeroSuggestPrefetcher(profile); |
| 601 } | 598 } |
| 602 | 599 |
| 603 // Register native methods | 600 // Register native methods |
| 604 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { | 601 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { |
| 605 return RegisterNativesImpl(env); | 602 return RegisterNativesImpl(env); |
| 606 } | 603 } |
| OLD | NEW |