OLD | NEW |
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_parser.h" |
15 #include "chrome/browser/search_engines/template_url_service.h" | 15 #include "chrome/browser/search_engines/template_url_service.h" |
16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.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" | |
26 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 26 #include "net/url_request/url_fetcher_delegate.h" |
27 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
28 | 28 |
29 // RequestDelegate ------------------------------------------------------------ | 29 // RequestDelegate ------------------------------------------------------------ |
30 class TemplateURLFetcher::RequestDelegate | 30 class TemplateURLFetcher::RequestDelegate |
31 : public content::URLFetcherDelegate, | 31 : public net::URLFetcherDelegate, |
32 public content::NotificationObserver { | 32 public content::NotificationObserver { |
33 public: | 33 public: |
34 // Takes ownership of |callbacks|. | 34 // Takes ownership of |callbacks|. |
35 RequestDelegate(TemplateURLFetcher* fetcher, | 35 RequestDelegate(TemplateURLFetcher* fetcher, |
36 const string16& keyword, | 36 const string16& keyword, |
37 const GURL& osdd_url, | 37 const GURL& osdd_url, |
38 const GURL& favicon_url, | 38 const GURL& favicon_url, |
39 content::WebContents* web_contents, | 39 content::WebContents* web_contents, |
40 TemplateURLFetcherCallbacks* callbacks, | 40 TemplateURLFetcherCallbacks* callbacks, |
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 // net::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 net::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 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 owned_callbacks.release(), provider_type)); | 287 owned_callbacks.release(), provider_type)); |
288 } | 288 } |
289 | 289 |
290 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { | 290 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { |
291 Requests::iterator i = | 291 Requests::iterator i = |
292 std::find(requests_->begin(), requests_->end(), request); | 292 std::find(requests_->begin(), requests_->end(), request); |
293 DCHECK(i != requests_->end()); | 293 DCHECK(i != requests_->end()); |
294 requests_->erase(i); | 294 requests_->erase(i); |
295 delete request; | 295 delete request; |
296 } | 296 } |
OLD | NEW |