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

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

Issue 10554008: Move content::URLFetcher static functions to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 (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 17 matching lines...) Expand all
28 #include "chrome/browser/history/in_memory_database.h" 28 #include "chrome/browser/history/in_memory_database.h"
29 #include "chrome/browser/instant/instant_controller.h" 29 #include "chrome/browser/instant/instant_controller.h"
30 #include "chrome/browser/net/url_fixer_upper.h" 30 #include "chrome/browser/net/url_fixer_upper.h"
31 #include "chrome/browser/prefs/pref_service.h" 31 #include "chrome/browser/prefs/pref_service.h"
32 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/search_engines/search_engine_type.h" 33 #include "chrome/browser/search_engines/search_engine_type.h"
34 #include "chrome/browser/search_engines/template_url_service.h" 34 #include "chrome/browser/search_engines/template_url_service.h"
35 #include "chrome/browser/search_engines/template_url_service_factory.h" 35 #include "chrome/browser/search_engines/template_url_service_factory.h"
36 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
37 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
38 #include "content/public/common/url_fetcher.h"
39 #include "googleurl/src/url_util.h" 38 #include "googleurl/src/url_util.h"
40 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
41 #include "net/base/escape.h" 40 #include "net/base/escape.h"
42 #include "net/base/load_flags.h" 41 #include "net/base/load_flags.h"
43 #include "net/base/net_util.h" 42 #include "net/base/net_util.h"
44 #include "net/http/http_response_headers.h" 43 #include "net/http/http_response_headers.h"
44 #include "net/url_request/url_fetcher.h"
45 #include "net/url_request/url_request_status.h" 45 #include "net/url_request/url_request_status.h"
46 #include "ui/base/l10n/l10n_util.h" 46 #include "ui/base/l10n/l10n_util.h"
47 47
48 using base::Time; 48 using base::Time;
49 using base::TimeDelta; 49 using base::TimeDelta;
50 50
51 namespace { 51 namespace {
52 52
53 bool HasMultipleWords(const string16& text) { 53 bool HasMultipleWords(const string16& text) {
54 base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD); 54 base::i18n::BreakIterator i(text, base::i18n::BreakIterator::BREAK_WORD);
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 (*list)[i].set_relevance(CalculateRelevanceForNavigation(is_keyword) + 584 (*list)[i].set_relevance(CalculateRelevanceForNavigation(is_keyword) +
585 (list->size() - i - 1)); 585 (list->size() - i - 1));
586 } 586 }
587 } 587 }
588 588
589 net::URLFetcher* SearchProvider::CreateSuggestFetcher( 589 net::URLFetcher* SearchProvider::CreateSuggestFetcher(
590 int id, 590 int id,
591 const TemplateURLRef& suggestions_url, 591 const TemplateURLRef& suggestions_url,
592 const string16& text) { 592 const string16& text) {
593 DCHECK(suggestions_url.SupportsReplacement()); 593 DCHECK(suggestions_url.SupportsReplacement());
594 net::URLFetcher* fetcher = content::URLFetcher::Create(id, 594 net::URLFetcher* fetcher = net::URLFetcher::Create(id,
595 GURL(suggestions_url.ReplaceSearchTerms(text, 595 GURL(suggestions_url.ReplaceSearchTerms(text,
596 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), 596 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())),
597 net::URLFetcher::GET, this); 597 net::URLFetcher::GET, this);
598 fetcher->SetRequestContext(profile_->GetRequestContext()); 598 fetcher->SetRequestContext(profile_->GetRequestContext());
599 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 599 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
600 fetcher->Start(); 600 fetcher->Start();
601 return fetcher; 601 return fetcher;
602 } 602 }
603 603
604 bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { 604 bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 ACMatchClassification::NONE, &match.description_class); 1145 ACMatchClassification::NONE, &match.description_class);
1146 return match; 1146 return match;
1147 } 1147 }
1148 1148
1149 void SearchProvider::UpdateDone() { 1149 void SearchProvider::UpdateDone() {
1150 // We're done when there are no more suggest queries pending (this is set to 1 1150 // We're done when there are no more suggest queries pending (this is set to 1
1151 // when the timer is started) and we're not waiting on instant. 1151 // when the timer is started) and we're not waiting on instant.
1152 done_ = ((suggest_results_pending_ == 0) && 1152 done_ = ((suggest_results_pending_ == 0) &&
1153 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 1153 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
1154 } 1154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698