diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 18:31:03 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 18:31:03 +0000 |
commit | 004ec925e3f71aeba2acd1461741ccddd92eeedc (patch) | |
tree | e58efd0fc8f7b2baec92cde9d95fd8617d86d32d /chrome/browser/google/google_url_tracker.cc | |
parent | 53f4636020e46d0ca54a60b1ecbbdcb677651c80 (diff) | |
download | chromium_src-004ec925e3f71aeba2acd1461741ccddd92eeedc.zip chromium_src-004ec925e3f71aeba2acd1461741ccddd92eeedc.tar.gz chromium_src-004ec925e3f71aeba2acd1461741ccddd92eeedc.tar.bz2 |
Revert 78228 - Extended: Add "system" URLRequestContext (not ready for use!)
This is an extension of http://codereview.chromium.org/6280018 that provides a proxy configuration which respects command line parameters and policies
BUG=67232,70732
TEST=Start chrome, observe two PROXY_CONFIG_CHANGED events in about:net-internals (if you are on a corporate network with PAC configurations), observe that everything behaves as usual. In particular the https://www.google.com/searchdomaincheck?format=domain&type=chrome request should not fail as it uses the new system URLRequestContext.
Review URL: http://codereview.chromium.org/6292017
TBR=battre@chromium.org
Review URL: http://codereview.chromium.org/6693023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78240 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/google/google_url_tracker.cc')
-rw-r--r-- | chrome/browser/google/google_url_tracker.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 2612d73..206cf0e 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -12,9 +12,9 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/net/url_request_context_getter.h" #include "chrome/common/pref_names.h" #include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/tab_contents.h" @@ -98,9 +98,13 @@ GoogleURLTracker::GoogleURLTracker() in_startup_sleep_(true), already_fetched_(false), need_to_fetch_(false), + request_context_available_(!!Profile::GetDefaultRequestContext()), need_to_prompt_(false), controller_(NULL), infobar_(NULL) { + registrar_.Add(this, NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, + NotificationService::AllSources()); + net::NetworkChangeNotifier::AddIPAddressObserver(this); MessageLoop::current()->PostTask(FROM_HERE, @@ -177,7 +181,8 @@ void GoogleURLTracker::StartFetchIfDesirable() { // // See comments in header on the class, on RequestServerCheck(), and on the // various members here for more detail on exactly what the conditions are. - if (in_startup_sleep_ || already_fetched_ || !need_to_fetch_) + if (in_startup_sleep_ || already_fetched_ || !need_to_fetch_ || + !request_context_available_) return; if (CommandLine::ForCurrentProcess()->HasSwitch( @@ -188,12 +193,12 @@ void GoogleURLTracker::StartFetchIfDesirable() { fetcher_.reset(URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL), URLFetcher::GET, this)); ++fetcher_id_; - // We don't want this fetch to affect existing state in local_state. For + // We don't want this fetch to affect existing state in the profile. For // example, if a user has no Google cookies, this automatic check should not // cause one to be set, lest we alarm the user. fetcher_->set_load_flags(net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SAVE_COOKIES); - fetcher_->set_request_context(g_browser_process->system_request_context()); + fetcher_->set_request_context(Profile::GetDefaultRequestContext()); // Configure to max_retries at most kMaxRetries times for 5xx errors. static const int kMaxRetries = 5; @@ -293,6 +298,14 @@ void GoogleURLTracker::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { switch (type.value) { + case NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE: + registrar_.Remove(this, + NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, + NotificationService::AllSources()); + request_context_available_ = true; + StartFetchIfDesirable(); + break; + case NotificationType::NAV_ENTRY_PENDING: { NavigationController* controller = Source<NavigationController>(source).ptr(); |