summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc61
-rw-r--r--chrome/browser/profiles/profile.cc8
-rw-r--r--chrome/browser/profiles/profile.h20
-rw-r--r--chrome/browser/profiles/profile_impl.cc15
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc7
-rw-r--r--chrome/common/chrome_notification_types.h6
6 files changed, 44 insertions, 73 deletions
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index b627478..73a3561 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -73,7 +73,6 @@
#include "chromeos/dbus/session_manager_client.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_observer.h"
#include "googleurl/src/gurl.h"
#include "media/base/media_switches.h"
#include "net/base/network_change_notifier.h"
@@ -227,7 +226,6 @@ class LoginUtilsImpl
public OAuth1TokenFetcher::Delegate,
public OAuthLoginVerifier::Delegate,
public net::NetworkChangeNotifier::ConnectionTypeObserver,
- public content::NotificationObserver,
public base::SupportsWeakPtr<LoginUtilsImpl> {
public:
LoginUtilsImpl()
@@ -236,13 +234,8 @@ class LoginUtilsImpl
has_cookies_(false),
delegate_(NULL),
job_restart_request_(NULL),
- should_restore_auth_session_(false),
- url_request_context_getter_(NULL) {
+ should_restore_auth_session_(false) {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
- registrar_.Add(
- this,
- chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
- content::Source<Profile>(ProfileManager::GetDefaultProfile()));
}
virtual ~LoginUtilsImpl() {
@@ -293,11 +286,6 @@ class LoginUtilsImpl
virtual void OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
- // content::NotificationObserver overrides.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
protected:
virtual std::string GetOffTheRecordCommandLine(
const GURL& start_url,
@@ -366,12 +354,6 @@ class LoginUtilsImpl
// online state change.
bool should_restore_auth_session_;
- content::NotificationRegistrar registrar_;
-
- // This is set via a notification after the profile has initialized the
- // getter.
- net::URLRequestContextGetter* url_request_context_getter_;
-
DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl);
};
@@ -880,11 +862,9 @@ scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator(
// We use a special class for this so that it can be safely leaked if we
// never connect. At shutdown the order is not well defined, and it's possible
// for the infrastructure needed to unregister might be unstable and crash.
-class WarmingObserver : public NetworkLibrary::NetworkManagerObserver,
- public content::NotificationObserver {
+class WarmingObserver : public NetworkLibrary::NetworkManagerObserver {
public:
- WarmingObserver()
- : url_request_context_getter_(NULL) {
+ WarmingObserver() {
NetworkLibrary *netlib = CrosLibrary::Get()->GetNetworkLibrary();
netlib->AddNetworkManagerObserver(this);
}
@@ -899,28 +879,11 @@ class WarmingObserver : public NetworkLibrary::NetworkManagerObserver,
GURL(GaiaUrls::GetInstance()->client_login_url()),
chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED,
kConnectionsNeeded,
- url_request_context_getter_);
+ make_scoped_refptr(Profile::GetDefaultRequestContextDeprecated()));
netlib->RemoveNetworkManagerObserver(this);
delete this;
}
}
-
- // content::NotificationObserver overrides.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- switch (type) {
- case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: {
- Profile* profile = content::Source<Profile>(source).ptr();
- url_request_context_getter_ = profile->GetRequestContext();
- break;
- }
- default:
- NOTREACHED();
- }
-}
- private:
- net::URLRequestContextGetter* url_request_context_getter_;
};
void LoginUtilsImpl::PrewarmAuthentication() {
@@ -931,7 +894,7 @@ void LoginUtilsImpl::PrewarmAuthentication() {
GURL(GaiaUrls::GetInstance()->client_login_url()),
chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED,
kConnectionsNeeded,
- url_request_context_getter_);
+ make_scoped_refptr(Profile::GetDefaultRequestContextDeprecated()));
} else {
new WarmingObserver();
}
@@ -1145,20 +1108,6 @@ void LoginUtilsImpl::OnConnectionTypeChanged(
}
}
-void LoginUtilsImpl::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- switch (type) {
- case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: {
- Profile* profile = content::Source<Profile>(source).ptr();
- url_request_context_getter_ = profile->GetRequestContext();
- break;
- }
- default:
- NOTREACHED();
- }
-}
-
// static
LoginUtils* LoginUtils::Get() {
return LoginUtilsWrapper::GetInstance()->get();
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 5d41c8e..5e627e9 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -19,6 +19,10 @@
#include "chrome/common/chrome_switches.h"
#endif
+// A pointer to the request context for the default profile. See comments on
+// Profile::GetDefaultRequestContext.
+net::URLRequestContextGetter* Profile::default_request_context_;
+
Profile::Profile()
: restored_last_session_(false),
accessibility_pause_level_(0) {
@@ -90,6 +94,10 @@ void Profile::RegisterUserPrefs(PrefService* prefs) {
#endif
}
+// static
+net::URLRequestContextGetter* Profile::GetDefaultRequestContext() {
+ return default_request_context_;
+}
std::string Profile::GetDebugName() {
std::string name = GetPath().BaseName().MaybeAsASCII();
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 814e207..b4cc8d1 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -147,6 +147,12 @@ class Profile : public content::BrowserContext {
// Returns the profile corresponding to the given WebUI.
static Profile* FromWebUI(content::WebUI* web_ui);
+ // TODO(rlp): Please do not use this function. It is a temporary fix
+ // for M19 stable. See crbug.com/125292.
+ static net::URLRequestContextGetter* GetDefaultRequestContextDeprecated() {
+ return Profile::GetDefaultRequestContext();
+ }
+
// content::BrowserContext implementation ------------------------------------
// Typesafe upcast.
@@ -260,9 +266,6 @@ class Profile : public content::BrowserContext {
// time that this method is called.
virtual PrefService* GetOffTheRecordPrefs() = 0;
- // Returns the main request context.
- virtual net::URLRequestContextGetter* GetRequestContext() = 0;
-
// Returns the request context used for extension-related requests. This
// is only used for a separate cookie store currently.
virtual net::URLRequestContextGetter* GetRequestContextForExtensions() = 0;
@@ -408,7 +411,18 @@ class Profile : public content::BrowserContext {
virtual base::Callback<ChromeURLDataManagerBackend*(void)>
GetChromeURLDataManagerBackendGetter() const = 0;
+ static net::URLRequestContextGetter* default_request_context_;
+
private:
+ // ***DEPRECATED**: You should be passing in the specific profile's
+ // URLRequestContextGetter or using the system URLRequestContextGetter.
+ //
+ // Returns the request context for the "default" profile. This may be called
+ // from any thread. This CAN return NULL if a first request context has not
+ // yet been created. If necessary, listen on the UI thread for
+ // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE.
+ static net::URLRequestContextGetter* GetDefaultRequestContext();
+
bool restored_last_session_;
// Accessibility events will only be propagated when the pause
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 4ded4a3..b6a2e54 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -513,6 +513,11 @@ ProfileImpl::~ProfileImpl() {
ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
io_data_.GetResourceContextNoInit());
+ if (io_data_.HasMainRequestContext() &&
+ default_request_context_ == GetRequestContext()) {
+ default_request_context_ = NULL;
+ }
+
// Destroy OTR profile and its profile services first.
if (off_the_record_profile_.get()) {
ProfileDestroyer::DestroyOffTheRecordProfileNow(
@@ -698,7 +703,15 @@ FilePath ProfileImpl::GetPrefFilePath() {
}
net::URLRequestContextGetter* ProfileImpl::GetRequestContext() {
- return io_data_.GetMainRequestContextGetter();
+ net::URLRequestContextGetter* request_context =
+ io_data_.GetMainRequestContextGetter();
+ // The first request context is always a normal (non-OTR) request context.
+ // Even when Chromium is started in OTR mode, a normal profile is always
+ // created first.
+ if (!default_request_context_)
+ default_request_context_ = request_context;
+
+ return request_context;
}
net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess(
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index cd133cd..bf5bc50 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -22,12 +22,10 @@
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/resource_context.h"
#include "net/base/server_bound_cert_service.h"
#include "net/ftp/ftp_network_layer.h"
@@ -156,11 +154,6 @@ ProfileImplIOData::Handle::GetMainRequestContextGetter() const {
main_request_context_getter_ =
ChromeURLRequestContextGetter::CreateOriginal(
profile_, io_data_);
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
- content::Source<Profile>(profile_),
- content::NotificationService::NoDetails());
}
return main_request_context_getter_;
}
diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h
index 9a78656..44deed4 100644
--- a/chrome/common/chrome_notification_types.h
+++ b/chrome/common/chrome_notification_types.h
@@ -286,8 +286,6 @@ enum NotificationType {
// updated.
NOTIFICATION_FAVICON_UPDATED,
- // Profiles -----------------------------------------------------------------
-
// Sent after a Profile has been created. This notification is sent both for
// normal and OTR profiles.
// The details are none and the source is the new profile.
@@ -302,10 +300,6 @@ enum NotificationType {
// The details are none and the source is a Profile*.
NOTIFICATION_PROFILE_DESTROYED,
- // Sent after the URLRequestContextGetter for a Profile has been initialized.
- // The details are none and the source is a Profile*.
- NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
-
// TopSites ----------------------------------------------------------------
// Sent by TopSites when it finishes loading. The source is the profile the