| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 void AutocompleteControllerAndroid::DeleteSuggestion(JNIEnv* env, | 237 void AutocompleteControllerAndroid::DeleteSuggestion(JNIEnv* env, |
| 238 jobject obj, | 238 jobject obj, |
| 239 int selected_index) { | 239 int selected_index) { |
| 240 const AutocompleteResult& result = autocomplete_controller_->result(); | 240 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 241 const AutocompleteMatch& match = result.match_at(selected_index); | 241 const AutocompleteMatch& match = result.match_at(selected_index); |
| 242 if (match.SupportsDeletion()) | 242 if (match.SupportsDeletion()) |
| 243 autocomplete_controller_->DeleteMatch(match); | 243 autocomplete_controller_->DeleteMatch(match); |
| 244 } | 244 } |
| 245 | 245 |
| 246 ScopedJavaLocalRef<jstring> | 246 ScopedJavaLocalRef<jstring> AutocompleteControllerAndroid:: |
| 247 AutocompleteControllerAndroid::UpdateMatchDestinationURL( | 247 UpdateMatchDestinationURLWithQueryFormulationTime( |
| 248 JNIEnv* env, | 248 JNIEnv* env, |
| 249 jobject obj, | 249 jobject obj, |
| 250 jint selected_index, | 250 jint selected_index, |
| 251 jlong elapsed_time_since_input_change) { | 251 jlong elapsed_time_since_input_change) { |
| 252 // In rare cases, we navigate to cached matches and the underlying result | 252 // In rare cases, we navigate to cached matches and the underlying result |
| 253 // has already been cleared, in that case ignore the URL update. | 253 // has already been cleared, in that case ignore the URL update. |
| 254 if (autocomplete_controller_->result().empty()) | 254 if (autocomplete_controller_->result().empty()) |
| 255 return ScopedJavaLocalRef<jstring>(); | 255 return ScopedJavaLocalRef<jstring>(); |
| 256 | 256 |
| 257 AutocompleteMatch match( | 257 AutocompleteMatch match( |
| 258 autocomplete_controller_->result().match_at(selected_index)); | 258 autocomplete_controller_->result().match_at(selected_index)); |
| 259 autocomplete_controller_->UpdateMatchDestinationURL( | 259 autocomplete_controller_->UpdateMatchDestinationURLWithQueryFormulationTime( |
| 260 base::TimeDelta::FromMilliseconds(elapsed_time_since_input_change), | 260 base::TimeDelta::FromMilliseconds(elapsed_time_since_input_change), |
| 261 &match); | 261 &match); |
| 262 return ConvertUTF8ToJavaString(env, match.destination_url.spec()); | 262 return ConvertUTF8ToJavaString(env, match.destination_url.spec()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 ScopedJavaLocalRef<jobject> | 265 ScopedJavaLocalRef<jobject> |
| 266 AutocompleteControllerAndroid::GetTopSynchronousMatch(JNIEnv* env, | 266 AutocompleteControllerAndroid::GetTopSynchronousMatch(JNIEnv* env, |
| 267 jobject obj, | 267 jobject obj, |
| 268 jstring query) { | 268 jstring query) { |
| 269 return GetTopSynchronousResult(env, obj, query, false); | 269 return GetTopSynchronousResult(env, obj, query, false); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 return; | 550 return; |
| 551 | 551 |
| 552 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. | 552 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. |
| 553 new ZeroSuggestPrefetcher(profile); | 553 new ZeroSuggestPrefetcher(profile); |
| 554 } | 554 } |
| 555 | 555 |
| 556 // Register native methods | 556 // Register native methods |
| 557 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { | 557 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { |
| 558 return RegisterNativesImpl(env); | 558 return RegisterNativesImpl(env); |
| 559 } | 559 } |
| OLD | NEW |