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_service.h" | 14 #include "chrome/browser/search_engines/template_url_service.h" |
15 #include "chrome/browser/search_engines/template_url_service_factory.h" | 15 #include "chrome/browser/search_engines/template_url_service_factory.h" |
16 #include "chrome/browser/search_engines/template_url_parser.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/common/url_fetcher.h" | 21 #include "content/public/common/url_fetcher.h" |
22 #include "content/public/common/url_fetcher_delegate.h" | 22 #include "content/public/common/url_fetcher_delegate.h" |
| 23 #include "net/base/load_flags.h" |
23 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
24 | 25 |
25 // RequestDelegate ------------------------------------------------------------ | 26 // RequestDelegate ------------------------------------------------------------ |
26 class TemplateURLFetcher::RequestDelegate | 27 class TemplateURLFetcher::RequestDelegate |
27 : public content::URLFetcherDelegate, | 28 : public content::URLFetcherDelegate, |
28 public content::NotificationObserver { | 29 public content::NotificationObserver { |
29 public: | 30 public: |
30 // Takes ownership of |callbacks|. | 31 // Takes ownership of |callbacks|. |
31 RequestDelegate(TemplateURLFetcher* fetcher, | 32 RequestDelegate(TemplateURLFetcher* fetcher, |
32 const string16& keyword, | 33 const string16& keyword, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 94 |
94 if (!model->loaded()) { | 95 if (!model->loaded()) { |
95 // Start the model load and set-up waiting for it. | 96 // Start the model load and set-up waiting for it. |
96 registrar_.Add(this, | 97 registrar_.Add(this, |
97 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 98 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
98 content::Source<TemplateURLService>(model)); | 99 content::Source<TemplateURLService>(model)); |
99 model->Load(); | 100 model->Load(); |
100 } | 101 } |
101 | 102 |
102 url_fetcher_->SetRequestContext(fetcher->profile()->GetRequestContext()); | 103 url_fetcher_->SetRequestContext(fetcher->profile()->GetRequestContext()); |
| 104 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
103 url_fetcher_->Start(); | 105 url_fetcher_->Start(); |
104 } | 106 } |
105 | 107 |
106 void TemplateURLFetcher::RequestDelegate::Observe( | 108 void TemplateURLFetcher::RequestDelegate::Observe( |
107 int type, | 109 int type, |
108 const content::NotificationSource& source, | 110 const content::NotificationSource& source, |
109 const content::NotificationDetails& details) { | 111 const content::NotificationDetails& details) { |
110 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); | 112 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); |
111 | 113 |
112 if (!template_url_.get()) | 114 if (!template_url_.get()) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 new RequestDelegate(this, keyword, osdd_url, favicon_url, | 284 new RequestDelegate(this, keyword, osdd_url, favicon_url, |
283 owned_callbacks.release(), provider_type)); | 285 owned_callbacks.release(), provider_type)); |
284 } | 286 } |
285 | 287 |
286 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { | 288 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { |
287 DCHECK(std::find(requests_->begin(), requests_->end(), request) != | 289 DCHECK(std::find(requests_->begin(), requests_->end(), request) != |
288 requests_->end()); | 290 requests_->end()); |
289 requests_->erase(std::find(requests_->begin(), requests_->end(), request)); | 291 requests_->erase(std::find(requests_->begin(), requests_->end(), request)); |
290 delete request; | 292 delete request; |
291 } | 293 } |
OLD | NEW |