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

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

Issue 9965143: Revert 130431 - Move the URL string from TemplateURLRef onto the owning TemplateURL. This will mak… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 default_suggest_results_.clear(); 448 default_suggest_results_.clear();
449 keyword_navigation_results_.clear(); 449 keyword_navigation_results_.clear();
450 default_navigation_results_.clear(); 450 default_navigation_results_.clear();
451 have_suggest_results_ = false; 451 have_suggest_results_ = false;
452 } 452 }
453 453
454 content::URLFetcher* SearchProvider::CreateSuggestFetcher( 454 content::URLFetcher* SearchProvider::CreateSuggestFetcher(
455 int id, 455 int id,
456 const TemplateURL& provider, 456 const TemplateURL& provider,
457 const string16& text) { 457 const string16& text) {
458 const TemplateURLRef& suggestions_url = provider.suggestions_url_ref(); 458 const TemplateURLRef* const suggestions_url = provider.suggestions_url();
459 DCHECK(suggestions_url.SupportsReplacement()); 459 DCHECK(suggestions_url->SupportsReplacement());
460 content::URLFetcher* fetcher = content::URLFetcher::Create(id, 460 content::URLFetcher* fetcher = content::URLFetcher::Create(id,
461 GURL(suggestions_url.ReplaceSearchTermsUsingProfile( 461 GURL(suggestions_url->ReplaceSearchTermsUsingProfile(
462 profile_, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, 462 profile_, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
463 string16())), 463 string16())),
464 content::URLFetcher::GET, this); 464 content::URLFetcher::GET, this);
465 fetcher->SetRequestContext(profile_->GetRequestContext()); 465 fetcher->SetRequestContext(profile_->GetRequestContext());
466 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 466 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
467 fetcher->Start(); 467 fetcher->Start();
468 return fetcher; 468 return fetcher;
469 } 469 }
470 470
471 bool SearchProvider::ParseSuggestResults(Value* root_val, 471 bool SearchProvider::ParseSuggestResults(Value* root_val,
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 match.fill_into_edit.append(match.keyword + char16(' ')); 894 match.fill_into_edit.append(match.keyword + char16(' '));
895 search_start += match.keyword.length() + 1; 895 search_start += match.keyword.length() + 1;
896 } 896 }
897 match.fill_into_edit.append(query_string); 897 match.fill_into_edit.append(query_string);
898 // Not all suggestions start with the original input. 898 // Not all suggestions start with the original input.
899 if (!prevent_inline_autocomplete && 899 if (!prevent_inline_autocomplete &&
900 !match.fill_into_edit.compare(search_start, input_text.length(), 900 !match.fill_into_edit.compare(search_start, input_text.length(),
901 input_text)) 901 input_text))
902 match.inline_autocomplete_offset = search_start + input_text.length(); 902 match.inline_autocomplete_offset = search_start + input_text.length();
903 903
904 const TemplateURLRef& search_url = provider.url_ref(); 904 const TemplateURLRef* const search_url = provider.url();
905 DCHECK(search_url.SupportsReplacement()); 905 DCHECK(search_url->SupportsReplacement());
906 match.destination_url = GURL(search_url.ReplaceSearchTermsUsingProfile( 906 match.destination_url = GURL(search_url->ReplaceSearchTermsUsingProfile(
907 profile_, query_string, accepted_suggestion, input_text)); 907 profile_, query_string, accepted_suggestion, input_text));
908 908
909 // Search results don't look like URLs. 909 // Search results don't look like URLs.
910 match.transition = is_keyword ? 910 match.transition = is_keyword ?
911 content::PAGE_TRANSITION_KEYWORD : content::PAGE_TRANSITION_GENERATED; 911 content::PAGE_TRANSITION_KEYWORD : content::PAGE_TRANSITION_GENERATED;
912 912
913 // Try to add |match| to |map|. If a match for |query_string| is already in 913 // Try to add |match| to |map|. If a match for |query_string| is already in
914 // |map|, replace it if |match| is more relevant. 914 // |map|, replace it if |match| is more relevant.
915 // NOTE: Keep this ToLower() call in sync with url_database.cc. 915 // NOTE: Keep this ToLower() call in sync with url_database.cc.
916 const std::pair<MatchMap::iterator, bool> i = map->insert( 916 const std::pair<MatchMap::iterator, bool> i = map->insert(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 961
962 return match; 962 return match;
963 } 963 }
964 964
965 void SearchProvider::UpdateDone() { 965 void SearchProvider::UpdateDone() {
966 // We're done when there are no more suggest queries pending (this is set to 1 966 // We're done when there are no more suggest queries pending (this is set to 1
967 // when the timer is started) and we're not waiting on instant. 967 // when the timer is started) and we're not waiting on instant.
968 done_ = ((suggest_results_pending_ == 0) && 968 done_ = ((suggest_results_pending_ == 0) &&
969 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 969 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
970 } 970 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | chrome/browser/autocomplete/search_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698