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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
62 private: | 62 private: |
63 void AddSearchProvider(); | 63 void AddSearchProvider(); |
64 | 64 |
65 scoped_ptr<content::URLFetcher> url_fetcher_; | 65 scoped_ptr<net::URLFetcher> url_fetcher_; |
66 TemplateURLFetcher* fetcher_; | 66 TemplateURLFetcher* fetcher_; |
67 scoped_ptr<TemplateURL> template_url_; | 67 scoped_ptr<TemplateURL> template_url_; |
68 string16 keyword_; | 68 string16 keyword_; |
69 const GURL osdd_url_; | 69 const GURL osdd_url_; |
70 const GURL favicon_url_; | 70 const GURL favicon_url_; |
71 const ProviderType provider_type_; | 71 const ProviderType provider_type_; |
72 scoped_ptr<TemplateURLFetcherCallbacks> callbacks_; | 72 scoped_ptr<TemplateURLFetcherCallbacks> callbacks_; |
73 | 73 |
74 // Handles registering for our notifications. | 74 // Handles registering for our notifications. |
75 content::NotificationRegistrar registrar_; | 75 content::NotificationRegistrar registrar_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(RequestDelegate); | 77 DISALLOW_COPY_AND_ASSIGN(RequestDelegate); |
78 }; | 78 }; |
79 | 79 |
80 TemplateURLFetcher::RequestDelegate::RequestDelegate( | 80 TemplateURLFetcher::RequestDelegate::RequestDelegate( |
81 TemplateURLFetcher* fetcher, | 81 TemplateURLFetcher* fetcher, |
82 const string16& keyword, | 82 const string16& keyword, |
83 const GURL& osdd_url, | 83 const GURL& osdd_url, |
84 const GURL& favicon_url, | 84 const GURL& favicon_url, |
85 content::WebContents* web_contents, | 85 content::WebContents* web_contents, |
86 TemplateURLFetcherCallbacks* callbacks, | 86 TemplateURLFetcherCallbacks* callbacks, |
87 ProviderType provider_type) | 87 ProviderType provider_type) |
88 : ALLOW_THIS_IN_INITIALIZER_LIST(url_fetcher_(content::URLFetcher::Create( | 88 : ALLOW_THIS_IN_INITIALIZER_LIST(url_fetcher_(content::URLFetcher::Create( |
89 osdd_url, content::URLFetcher::GET, this))), | 89 osdd_url, net::URLFetcher::GET, this))), |
90 fetcher_(fetcher), | 90 fetcher_(fetcher), |
91 keyword_(keyword), | 91 keyword_(keyword), |
92 osdd_url_(osdd_url), | 92 osdd_url_(osdd_url), |
93 favicon_url_(favicon_url), | 93 favicon_url_(favicon_url), |
94 provider_type_(provider_type), | 94 provider_type_(provider_type), |
95 callbacks_(callbacks) { | 95 callbacks_(callbacks) { |
96 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( | 96 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( |
97 fetcher_->profile()); | 97 fetcher_->profile()); |
98 DCHECK(model); // TemplateURLFetcher::ScheduleDownload verifies this. | 98 DCHECK(model); // TemplateURLFetcher::ScheduleDownload verifies this. |
99 | 99 |
(...skipping 187 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 |