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

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 7558014: Add a URL param to indicate group selection in Instant field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed @pkasting's comments Created 9 years, 4 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 default_navigation_results_.clear(); 433 default_navigation_results_.clear();
434 have_suggest_results_ = false; 434 have_suggest_results_ = false;
435 } 435 }
436 436
437 URLFetcher* SearchProvider::CreateSuggestFetcher(int id, 437 URLFetcher* SearchProvider::CreateSuggestFetcher(int id,
438 const TemplateURL& provider, 438 const TemplateURL& provider,
439 const string16& text) { 439 const string16& text) {
440 const TemplateURLRef* const suggestions_url = provider.suggestions_url(); 440 const TemplateURLRef* const suggestions_url = provider.suggestions_url();
441 DCHECK(suggestions_url->SupportsReplacement()); 441 DCHECK(suggestions_url->SupportsReplacement());
442 URLFetcher* fetcher = URLFetcher::Create(id, 442 URLFetcher* fetcher = URLFetcher::Create(id,
443 GURL(suggestions_url->ReplaceSearchTerms( 443 GURL(suggestions_url->ReplaceSearchTermsUsingProfile(profile_, provider,
444 provider, text, 444 text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())),
445 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())),
446 URLFetcher::GET, this); 445 URLFetcher::GET, this);
447 fetcher->set_request_context(profile_->GetRequestContext()); 446 fetcher->set_request_context(profile_->GetRequestContext());
448 fetcher->Start(); 447 fetcher->Start();
449 return fetcher; 448 return fetcher;
450 } 449 }
451 450
452 bool SearchProvider::ParseSuggestResults(Value* root_val, 451 bool SearchProvider::ParseSuggestResults(Value* root_val,
453 bool is_keyword, 452 bool is_keyword,
454 const string16& input_text, 453 const string16& input_text,
455 SuggestResults* suggest_results) { 454 SuggestResults* suggest_results) {
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } 875 }
877 match.fill_into_edit.append(query_string); 876 match.fill_into_edit.append(query_string);
878 // Not all suggestions start with the original input. 877 // Not all suggestions start with the original input.
879 if (!prevent_inline_autocomplete && 878 if (!prevent_inline_autocomplete &&
880 !match.fill_into_edit.compare(search_start, input_text.length(), 879 !match.fill_into_edit.compare(search_start, input_text.length(),
881 input_text)) 880 input_text))
882 match.inline_autocomplete_offset = search_start + input_text.length(); 881 match.inline_autocomplete_offset = search_start + input_text.length();
883 882
884 const TemplateURLRef* const search_url = provider.url(); 883 const TemplateURLRef* const search_url = provider.url();
885 DCHECK(search_url->SupportsReplacement()); 884 DCHECK(search_url->SupportsReplacement());
886 match.destination_url = 885 match.destination_url = GURL(search_url->ReplaceSearchTermsUsingProfile(
887 GURL(search_url->ReplaceSearchTerms(provider, 886 profile_, provider, query_string, accepted_suggestion, input_text));
888 query_string,
889 accepted_suggestion,
890 input_text));
891 887
892 // Search results don't look like URLs. 888 // Search results don't look like URLs.
893 match.transition = 889 match.transition =
894 is_keyword ? PageTransition::KEYWORD : PageTransition::GENERATED; 890 is_keyword ? PageTransition::KEYWORD : PageTransition::GENERATED;
895 891
896 // Try to add |match| to |map|. If a match for |query_string| is already in 892 // Try to add |match| to |map|. If a match for |query_string| is already in
897 // |map|, replace it if |match| is more relevant. 893 // |map|, replace it if |match| is more relevant.
898 // NOTE: Keep this ToLower() call in sync with url_database.cc. 894 // NOTE: Keep this ToLower() call in sync with url_database.cc.
899 const std::pair<MatchMap::iterator, bool> i = map->insert( 895 const std::pair<MatchMap::iterator, bool> i = map->insert(
900 std::pair<string16, AutocompleteMatch>( 896 std::pair<string16, AutocompleteMatch>(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 940
945 return match; 941 return match;
946 } 942 }
947 943
948 void SearchProvider::UpdateDone() { 944 void SearchProvider::UpdateDone() {
949 // We're done when there are no more suggest queries pending (this is set to 1 945 // We're done when there are no more suggest queries pending (this is set to 1
950 // when the timer is started) and we're not waiting on instant. 946 // when the timer is started) and we're not waiting on instant.
951 done_ = ((suggest_results_pending_ == 0) && 947 done_ = ((suggest_results_pending_ == 0) &&
952 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 948 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
953 } 949 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.cc ('k') | chrome/browser/instant/instant_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698