Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/ui/search/instant_controller.cc

Issue 17391005: Remove Instant hooks from SearchProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // suggestion or reset the existing "gray text". 528 // suggestion or reset the existing "gray text".
529 browser_->SetInstantSuggestion(last_suggestion_); 529 browser_->SetInstantSuggestion(last_suggestion_);
530 530
531 // Record the time of the first keypress for logging histograms. 531 // Record the time of the first keypress for logging histograms.
532 if (!first_interaction_time_recorded_ && first_interaction_time_.is_null()) 532 if (!first_interaction_time_recorded_ && first_interaction_time_.is_null())
533 first_interaction_time_ = base::Time::Now(); 533 first_interaction_time_ = base::Time::Now();
534 534
535 return true; 535 return true;
536 } 536 }
537 537
538 bool InstantController::WillFetchCompletions() const {
539 if (!extended_enabled())
540 return false;
541
542 return !UsingLocalPage();
543 }
544
545 scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() { 538 scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() {
546 if (!extended_enabled() || !browser_->profile() || 539 if (!extended_enabled() || !browser_->profile() ||
547 browser_->profile()->IsOffTheRecord()) 540 browser_->profile()->IsOffTheRecord())
548 return scoped_ptr<content::WebContents>(); 541 return scoped_ptr<content::WebContents>();
549 542
550 LOG_INSTANT_DEBUG_EVENT(this, "ReleaseNTPContents"); 543 LOG_INSTANT_DEBUG_EVENT(this, "ReleaseNTPContents");
551 544
552 if (ShouldSwitchToLocalNTP()) 545 if (ShouldSwitchToLocalNTP())
553 ResetNTP(GetLocalInstantURL()); 546 ResetNTP(GetLocalInstantURL());
554 547
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 return; 596 return;
604 597
605 if (!UseTabForSuggestions() && !overlay_) 598 if (!UseTabForSuggestions() && !overlay_)
606 return; 599 return;
607 600
608 // The omnibox sends suggestions when its possibly imaginary popup closes 601 // The omnibox sends suggestions when its possibly imaginary popup closes
609 // as it stops autocomplete. Ignore these. 602 // as it stops autocomplete. Ignore these.
610 if (omnibox_focus_state_ == OMNIBOX_FOCUS_NONE) 603 if (omnibox_focus_state_ == OMNIBOX_FOCUS_NONE)
611 return; 604 return;
612 605
613 for (ACProviders::const_iterator provider = providers.begin();
614 provider != providers.end(); ++provider) {
615 const bool from_search_provider =
616 (*provider)->type() == AutocompleteProvider::TYPE_SEARCH;
617
618 // TODO(jeremycho): Pass search_provider() as a parameter to this function
619 // and remove the static cast.
620 const bool provider_done = from_search_provider ?
621 static_cast<SearchProvider*>(*provider)->IsNonInstantSearchDone() :
622 (*provider)->done();
623 if (!provider_done) {
624 DVLOG(1) << "Waiting for " << (*provider)->GetName();
625 return;
626 }
627 }
628
629 DVLOG(1) << "AutocompleteResults:"; 606 DVLOG(1) << "AutocompleteResults:";
630 std::vector<InstantAutocompleteResult> results; 607 std::vector<InstantAutocompleteResult> results;
631 if (UsingLocalPage()) { 608 if (UsingLocalPage()) {
632 for (AutocompleteResult::const_iterator match(autocomplete_result.begin()); 609 for (AutocompleteResult::const_iterator match(autocomplete_result.begin());
633 match != autocomplete_result.end(); ++match) { 610 match != autocomplete_result.end(); ++match) {
634 InstantAutocompleteResult result; 611 InstantAutocompleteResult result;
635 PopulateInstantAutocompleteResultFromMatch( 612 PopulateInstantAutocompleteResultFromMatch(
636 *match, std::distance(autocomplete_result.begin(), match), &result); 613 *match, std::distance(autocomplete_result.begin(), match), &result);
637 results.push_back(result); 614 results.push_back(result);
638 } 615 }
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 result->transition = match.transition; 1841 result->transition = match.transition;
1865 result->relevance = match.relevance; 1842 result->relevance = match.relevance;
1866 result->autocomplete_match_index = autocomplete_match_index; 1843 result->autocomplete_match_index = autocomplete_match_index;
1867 1844
1868 DVLOG(1) << " " << result->relevance << " " 1845 DVLOG(1) << " " << result->relevance << " "
1869 << UTF8ToUTF16(AutocompleteMatchType::ToString(result->type)) << " " 1846 << UTF8ToUTF16(AutocompleteMatchType::ToString(result->type)) << " "
1870 << result->provider << " " << result->destination_url << " '" 1847 << result->provider << " " << result->destination_url << " '"
1871 << result->description << "' '" << result->search_query << "' " 1848 << result->description << "' '" << result->search_query << "' "
1872 << result->transition << " " << result->autocomplete_match_index; 1849 << result->transition << " " << result->autocomplete_match_index;
1873 } 1850 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698