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

Side by Side Diff: chrome/browser/search_engines/template_url_fetcher.cc

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build Created 8 years, 7 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/search_engines/template_url_fetcher.h" 7 #include "chrome/browser/search_engines/template_url_fetcher.h"
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search_engines/template_url.h" 12 #include "chrome/browser/search_engines/template_url.h"
13 #include "chrome/browser/search_engines/template_url_fetcher_callbacks.h" 13 #include "chrome/browser/search_engines/template_url_fetcher_callbacks.h"
14 #include "chrome/browser/search_engines/template_url_parser.h"
14 #include "chrome/browser/search_engines/template_url_service.h" 15 #include "chrome/browser/search_engines/template_url_service.h"
15 #include "chrome/browser/search_engines/template_url_service_factory.h" 16 #include "chrome/browser/search_engines/template_url_service_factory.h"
16 #include "chrome/browser/search_engines/template_url_parser.h"
17 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/url_fetcher.h" 24 #include "content/public/common/url_fetcher.h"
25 #include "content/public/common/url_fetcher_delegate.h" 25 #include "content/public/common/url_fetcher_delegate.h"
26 #include "net/base/load_flags.h" 26 #include "net/base/load_flags.h"
(...skipping 14 matching lines...) Expand all
41 ProviderType provider_type); 41 ProviderType provider_type);
42 42
43 // content::NotificationObserver: 43 // content::NotificationObserver:
44 virtual void Observe(int type, 44 virtual void Observe(int type,
45 const content::NotificationSource& source, 45 const content::NotificationSource& source,
46 const content::NotificationDetails& details); 46 const content::NotificationDetails& details);
47 47
48 // content::URLFetcherDelegate: 48 // content::URLFetcherDelegate:
49 // If data contains a valid OSDD, a TemplateURL is created and added to 49 // If data contains a valid OSDD, a TemplateURL is created and added to
50 // the TemplateURLService. 50 // the TemplateURLService.
51 virtual void OnURLFetchComplete(const content::URLFetcher* source); 51 virtual void OnURLFetchComplete(const net::URLFetcher* source);
52 52
53 // URL of the OSDD. 53 // URL of the OSDD.
54 GURL url() const { return osdd_url_; } 54 GURL url() const { return osdd_url_; }
55 55
56 // Keyword to use. 56 // Keyword to use.
57 string16 keyword() const { return keyword_; } 57 string16 keyword() const { return keyword_; }
58 58
59 // The type of search provider being fetched. 59 // The type of search provider being fetched.
60 ProviderType provider_type() const { return provider_type_; } 60 ProviderType provider_type() const { return provider_type_; }
61 61
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 const content::NotificationDetails& details) { 123 const content::NotificationDetails& details) {
124 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); 124 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
125 125
126 if (!template_url_.get()) 126 if (!template_url_.get())
127 return; 127 return;
128 AddSearchProvider(); 128 AddSearchProvider();
129 // WARNING: AddSearchProvider deletes us. 129 // WARNING: AddSearchProvider deletes us.
130 } 130 }
131 131
132 void TemplateURLFetcher::RequestDelegate::OnURLFetchComplete( 132 void TemplateURLFetcher::RequestDelegate::OnURLFetchComplete(
133 const content::URLFetcher* source) { 133 const net::URLFetcher* source) {
134 // Validation checks. 134 // Validation checks.
135 // Make sure we can still replace the keyword, i.e. the fetch was successful. 135 // Make sure we can still replace the keyword, i.e. the fetch was successful.
136 // If the OSDD file was loaded HTTP, we also have to check the response_code. 136 // If the OSDD file was loaded HTTP, we also have to check the response_code.
137 // For other schemes, e.g. when the OSDD file is bundled with an extension, 137 // For other schemes, e.g. when the OSDD file is bundled with an extension,
138 // the response_code is not applicable and should be -1. Also, ensure that 138 // the response_code is not applicable and should be -1. Also, ensure that
139 // the returned information results in a valid search URL. 139 // the returned information results in a valid search URL.
140 std::string data; 140 std::string data;
141 if (!source->GetStatus().is_success() || 141 if (!source->GetStatus().is_success() ||
142 ((source->GetResponseCode() != -1) && 142 ((source->GetResponseCode() != -1) &&
143 (source->GetResponseCode() != 200)) || 143 (source->GetResponseCode() != 200)) ||
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 owned_callbacks.release(), provider_type)); 286 owned_callbacks.release(), provider_type));
287 } 287 }
288 288
289 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { 289 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) {
290 Requests::iterator i = 290 Requests::iterator i =
291 std::find(requests_->begin(), requests_->end(), request); 291 std::find(requests_->begin(), requests_->end(), request);
292 DCHECK(i != requests_->end()); 292 DCHECK(i != requests_->end());
293 requests_->erase(i); 293 requests_->erase(i);
294 delete request; 294 delete request;
295 } 295 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_test.cc ('k') | chrome/browser/spellchecker/spellcheck_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698