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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 void AutocompleteControllerAndroid::OnResultChanged( | 331 void AutocompleteControllerAndroid::OnResultChanged( |
332 bool default_match_changed) { | 332 bool default_match_changed) { |
333 if (!autocomplete_controller_) | 333 if (!autocomplete_controller_) |
334 return; | 334 return; |
335 | 335 |
336 const AutocompleteResult& result = autocomplete_controller_->result(); | 336 const AutocompleteResult& result = autocomplete_controller_->result(); |
337 const AutocompleteResult::const_iterator default_match( | 337 const AutocompleteResult::const_iterator default_match( |
338 result.default_match()); | 338 result.default_match()); |
339 if ((default_match != result.end()) && default_match_changed && | 339 if ((default_match != result.end()) && default_match_changed && |
340 chrome::IsInstantExtendedAPIEnabled() && | 340 search::IsInstantExtendedAPIEnabled() && |
341 chrome::ShouldPrefetchSearchResults()) { | 341 search::ShouldPrefetchSearchResults()) { |
342 InstantSuggestion prefetch_suggestion; | 342 InstantSuggestion prefetch_suggestion; |
343 // If the default match should be prefetched, do that. | 343 // If the default match should be prefetched, do that. |
344 if (SearchProvider::ShouldPrefetch(*default_match)) { | 344 if (SearchProvider::ShouldPrefetch(*default_match)) { |
345 prefetch_suggestion.text = default_match->contents; | 345 prefetch_suggestion.text = default_match->contents; |
346 prefetch_suggestion.metadata = | 346 prefetch_suggestion.metadata = |
347 SearchProvider::GetSuggestMetadata(*default_match); | 347 SearchProvider::GetSuggestMetadata(*default_match); |
348 } | 348 } |
349 // Send the prefetch suggestion unconditionally to the Instant search base | 349 // Send the prefetch suggestion unconditionally to the Instant search base |
350 // page. If there is no suggestion to prefetch, we need to send a blank | 350 // page. If there is no suggestion to prefetch, we need to send a blank |
351 // query to clear the prefetched results. | 351 // query to clear the prefetched results. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 return; | 554 return; |
555 | 555 |
556 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. | 556 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. |
557 new ZeroSuggestPrefetcher(profile); | 557 new ZeroSuggestPrefetcher(profile); |
558 } | 558 } |
559 | 559 |
560 // Register native methods | 560 // Register native methods |
561 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { | 561 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { |
562 return RegisterNativesImpl(env); | 562 return RegisterNativesImpl(env); |
563 } | 563 } |
OLD | NEW |