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 "chrome/browser/google/google_url_tracker.h" | 5 #include "chrome/browser/google/google_url_tracker.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
16 #include "chrome/browser/infobars/infobar_tab_helper.h" | 16 #include "chrome/browser/infobars/infobar_tab_helper.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/search_engines/template_url.h" | 18 #include "chrome/browser/search_engines/template_url.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
24 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/common/content_url_request_user_data.h" |
27 #include "content/public/common/url_fetcher.h" | 28 #include "content/public/common/url_fetcher.h" |
28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
29 #include "net/base/load_flags.h" | 30 #include "net/base/load_flags.h" |
30 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
31 #include "net/url_request/url_request_context_getter.h" | 32 #include "net/url_request/url_request_context_getter.h" |
32 #include "net/url_request/url_request_status.h" | 33 #include "net/url_request/url_request_status.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 | 35 |
35 using content::NavigationController; | 36 using content::NavigationController; |
36 using content::OpenURLParams; | 37 using content::OpenURLParams; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 fetcher_.reset(content::URLFetcher::Create( | 219 fetcher_.reset(content::URLFetcher::Create( |
219 fetcher_id_, GURL(kSearchDomainCheckURL), content::URLFetcher::GET, | 220 fetcher_id_, GURL(kSearchDomainCheckURL), content::URLFetcher::GET, |
220 this)); | 221 this)); |
221 ++fetcher_id_; | 222 ++fetcher_id_; |
222 // We don't want this fetch to affect existing state in local_state. For | 223 // We don't want this fetch to affect existing state in local_state. For |
223 // example, if a user has no Google cookies, this automatic check should not | 224 // example, if a user has no Google cookies, this automatic check should not |
224 // cause one to be set, lest we alarm the user. | 225 // cause one to be set, lest we alarm the user. |
225 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 226 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
226 net::LOAD_DO_NOT_SAVE_COOKIES); | 227 net::LOAD_DO_NOT_SAVE_COOKIES); |
227 fetcher_->SetRequestContext(g_browser_process->system_request_context()); | 228 fetcher_->SetRequestContext(g_browser_process->system_request_context()); |
| 229 // TODO(jochen): Do cookie audit. |
| 230 fetcher_->SetContentURLRequestUserData( |
| 231 new content::ContentURLRequestUserData()); |
228 | 232 |
229 // Configure to max_retries at most kMaxRetries times for 5xx errors. | 233 // Configure to max_retries at most kMaxRetries times for 5xx errors. |
230 static const int kMaxRetries = 5; | 234 static const int kMaxRetries = 5; |
231 fetcher_->SetMaxRetries(kMaxRetries); | 235 fetcher_->SetMaxRetries(kMaxRetries); |
232 | 236 |
233 fetcher_->Start(); | 237 fetcher_->Start(); |
234 } | 238 } |
235 | 239 |
236 void GoogleURLTracker::OnURLFetchComplete(const content::URLFetcher* source) { | 240 void GoogleURLTracker::OnURLFetchComplete(const content::URLFetcher* source) { |
237 // Delete the fetcher on this function's exit. | 241 // Delete the fetcher on this function's exit. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 397 |
394 // |tab_contents| can be NULL during tests. | 398 // |tab_contents| can be NULL during tests. |
395 InfoBarTabHelper* infobar_helper = NULL; | 399 InfoBarTabHelper* infobar_helper = NULL; |
396 if (web_contents) { | 400 if (web_contents) { |
397 TabContentsWrapper* wrapper = | 401 TabContentsWrapper* wrapper = |
398 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 402 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
399 infobar_helper = wrapper->infobar_tab_helper(); | 403 infobar_helper = wrapper->infobar_tab_helper(); |
400 } | 404 } |
401 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); | 405 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); |
402 } | 406 } |
OLD | NEW |