Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/command_line.h" | |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
| 16 #include "chrome/browser/search_engines/template_url.h" | 17 #include "chrome/browser/search_engines/template_url.h" |
| 17 #include "chrome/browser/tab_contents/infobar_delegate.h" | 18 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 18 #include "chrome/browser/tab_contents/navigation_controller.h" | 19 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
| 21 #include "chrome/common/chrome_switches.h" | |
| 20 #include "chrome/common/net/url_fetcher_protect.h" | 22 #include "chrome/common/net/url_fetcher_protect.h" |
| 21 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
| 22 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 24 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
| 25 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
| 26 | 28 |
| 27 const char GoogleURLTracker::kDefaultGoogleHomepage[] = | 29 const char GoogleURLTracker::kDefaultGoogleHomepage[] = |
| 28 "http://www.google.com/"; | 30 "http://www.google.com/"; |
| 29 const char GoogleURLTracker::kSearchDomainCheckURL[] = | 31 const char GoogleURLTracker::kSearchDomainCheckURL[] = |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 // Bail if a fetch isn't appropriate right now. This function will be called | 183 // Bail if a fetch isn't appropriate right now. This function will be called |
| 182 // again each time one of the preconditions changes, so we'll fetch | 184 // again each time one of the preconditions changes, so we'll fetch |
| 183 // immediately once all of them are met. | 185 // immediately once all of them are met. |
| 184 // | 186 // |
| 185 // See comments in header on the class, on RequestServerCheck(), and on the | 187 // See comments in header on the class, on RequestServerCheck(), and on the |
| 186 // various members here for more detail on exactly what the conditions are. | 188 // various members here for more detail on exactly what the conditions are. |
| 187 if (in_startup_sleep_ || already_fetched_ || !need_to_fetch_ || | 189 if (in_startup_sleep_ || already_fetched_ || !need_to_fetch_ || |
| 188 !request_context_available_) | 190 !request_context_available_) |
| 189 return; | 191 return; |
| 190 | 192 |
| 193 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
|
Peter Kasting
2010/09/08 19:38:45
Nit: I'd put this at the end of the above conditio
| |
| 194 switches::kDisableBackgroundNetworking)) | |
| 195 return; | |
| 196 | |
| 191 already_fetched_ = true; | 197 already_fetched_ = true; |
| 192 fetcher_.reset(URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL), | 198 fetcher_.reset(URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL), |
| 193 URLFetcher::GET, this)); | 199 URLFetcher::GET, this)); |
| 194 ++fetcher_id_; | 200 ++fetcher_id_; |
| 195 // We don't want this fetch to affect existing state in the profile. For | 201 // We don't want this fetch to affect existing state in the profile. For |
| 196 // example, if a user has no Google cookies, this automatic check should not | 202 // example, if a user has no Google cookies, this automatic check should not |
| 197 // cause one to be set, lest we alarm the user. | 203 // cause one to be set, lest we alarm the user. |
| 198 fetcher_->set_load_flags(net::LOAD_DISABLE_CACHE | | 204 fetcher_->set_load_flags(net::LOAD_DISABLE_CACHE | |
| 199 net::LOAD_DO_NOT_SAVE_COOKIES); | 205 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 200 fetcher_->set_request_context(Profile::GetDefaultRequestContext()); | 206 fetcher_->set_request_context(Profile::GetDefaultRequestContext()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 TabContents* tab_contents) { | 355 TabContents* tab_contents) { |
| 350 if (!need_to_prompt_) | 356 if (!need_to_prompt_) |
| 351 return; | 357 return; |
| 352 DCHECK(!fetched_google_url_.is_empty()); | 358 DCHECK(!fetched_google_url_.is_empty()); |
| 353 DCHECK(infobar_factory_.get()); | 359 DCHECK(infobar_factory_.get()); |
| 354 | 360 |
| 355 infobar_ = infobar_factory_->CreateInfoBar(tab_contents, | 361 infobar_ = infobar_factory_->CreateInfoBar(tab_contents, |
| 356 this, | 362 this, |
| 357 fetched_google_url_); | 363 fetched_google_url_); |
| 358 } | 364 } |
| OLD | NEW |