OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/search/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // the NTP. | 287 // the NTP. |
288 // However, in some tests, browser_ may be null. | 288 // However, in some tests, browser_ may be null. |
289 if (browser_) | 289 if (browser_) |
290 InstantServiceFactory::GetForProfile(browser_->profile()); | 290 InstantServiceFactory::GetForProfile(browser_->profile()); |
291 } | 291 } |
292 | 292 |
293 InstantController::~InstantController() { | 293 InstantController::~InstantController() { |
294 } | 294 } |
295 | 295 |
296 void InstantController::OnAutocompleteStart() { | 296 void InstantController::OnAutocompleteStart() { |
297 if (instant_tab_ && instant_tab_->supports_instant()) { | 297 if (UseTabForSuggestions() && instant_tab_->supports_instant()) { |
298 LOG_INSTANT_DEBUG_EVENT( | 298 LOG_INSTANT_DEBUG_EVENT( |
299 this, "OnAutocompleteStart: using InstantTab"); | 299 this, "OnAutocompleteStart: using InstantTab"); |
300 return; | 300 return; |
301 } | 301 } |
302 | 302 |
303 use_tab_for_suggestions_ = false; | |
304 | |
305 // Not using |instant_tab_|. Check if overlay is OK to use. | 303 // Not using |instant_tab_|. Check if overlay is OK to use. |
306 InstantFallbackReason fallback_reason = ShouldSwitchToLocalOverlay(); | 304 InstantFallbackReason fallback_reason = ShouldSwitchToLocalOverlay(); |
307 if (fallback_reason != INSTANT_FALLBACK_NONE) { | 305 if (fallback_reason != INSTANT_FALLBACK_NONE) { |
308 ResetOverlay(GetLocalInstantURL()); | 306 ResetOverlay(GetLocalInstantURL()); |
309 RecordFallbackReasonHistogram(fallback_reason); | 307 RecordFallbackReasonHistogram(fallback_reason); |
310 LOG_INSTANT_DEBUG_EVENT( | 308 LOG_INSTANT_DEBUG_EVENT( |
311 this, "OnAutocompleteStart: switching to local overlay"); | 309 this, "OnAutocompleteStart: switching to local overlay"); |
312 } else { | 310 } else { |
313 LOG_INSTANT_DEBUG_EVENT( | 311 LOG_INSTANT_DEBUG_EVENT( |
314 this, "OnAutocompleteStart: using existing overlay"); | 312 this, "OnAutocompleteStart: using existing overlay"); |
315 } | 313 } |
| 314 use_tab_for_suggestions_ = false; |
316 } | 315 } |
317 | 316 |
318 bool InstantController::Update(const AutocompleteMatch& match, | 317 bool InstantController::Update(const AutocompleteMatch& match, |
319 const string16& user_text, | 318 const string16& user_text, |
320 const string16& full_text, | 319 const string16& full_text, |
321 size_t selection_start, | 320 size_t selection_start, |
322 size_t selection_end, | 321 size_t selection_end, |
323 bool verbatim, | 322 bool verbatim, |
324 bool user_input_in_progress, | 323 bool user_input_in_progress, |
325 bool omnibox_popup_is_open, | 324 bool omnibox_popup_is_open, |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 result->transition = match.transition; | 1880 result->transition = match.transition; |
1882 result->relevance = match.relevance; | 1881 result->relevance = match.relevance; |
1883 result->autocomplete_match_index = autocomplete_match_index; | 1882 result->autocomplete_match_index = autocomplete_match_index; |
1884 | 1883 |
1885 DVLOG(1) << " " << result->relevance << " " | 1884 DVLOG(1) << " " << result->relevance << " " |
1886 << UTF8ToUTF16(AutocompleteMatchType::ToString(result->type)) << " " | 1885 << UTF8ToUTF16(AutocompleteMatchType::ToString(result->type)) << " " |
1887 << result->provider << " " << result->destination_url << " '" | 1886 << result->provider << " " << result->destination_url << " '" |
1888 << result->description << "' '" << result->search_query << "' " | 1887 << result->description << "' '" << result->search_query << "' " |
1889 << result->transition << " " << result->autocomplete_match_index; | 1888 << result->transition << " " << result->autocomplete_match_index; |
1890 } | 1889 } |
OLD | NEW |