Index: chrome/browser/signin/chrome_signin_client.cc |
diff --git a/chrome/browser/signin/chrome_signin_client.cc b/chrome/browser/signin/chrome_signin_client.cc |
index 74e31c463354e89b7e50c4d58604d9bf52b2cb68..15c2fbad2435322f2fff2d3e558d1f6f7dea4b27 100644 |
--- a/chrome/browser/signin/chrome_signin_client.cc |
+++ b/chrome/browser/signin/chrome_signin_client.cc |
@@ -8,6 +8,8 @@ |
#include "chrome/browser/signin/local_auth.h" |
#include "chrome/browser/webdata/web_data_service_factory.h" |
#include "chrome/common/profile_management_switches.h" |
+#include "content/public/browser/render_process_host.h" |
+#include "content/public/common/child_process_host.h" |
#include "url/gurl.h" |
#if defined(ENABLE_MANAGED_USERS) |
@@ -18,15 +20,25 @@ |
#include "chrome/browser/chromeos/login/user_manager.h" |
#endif |
+using content::ChildProcessHost; |
+using content::RenderProcessHost; |
+ |
namespace { |
const char kGoogleAccountsUrl[] = "https://accounts.google.com"; |
} // namespace |
-ChromeSigninClient::ChromeSigninClient(Profile* profile) : profile_(profile) {} |
+ChromeSigninClient::ChromeSigninClient(Profile* profile) |
+ : profile_(profile), signin_host_id_(ChildProcessHost::kInvalidUniqueID) {} |
-ChromeSigninClient::~ChromeSigninClient() {} |
+ChromeSigninClient::~ChromeSigninClient() { |
+ std::set<RenderProcessHost*>::iterator i; |
+ for (i = signin_hosts_observed_.begin(); i != signin_hosts_observed_.end(); |
+ ++i) { |
+ (*i)->RemoveObserver(this); |
+ } |
+} |
// static |
bool ChromeSigninClient::ProfileAllowsSigninCookies(Profile* profile) { |
@@ -43,6 +55,40 @@ bool ChromeSigninClient::SettingsAllowSigninCookies( |
GURL(kGoogleAccountsUrl)); |
} |
+void ChromeSigninClient::SetSigninProcess(int process_id) { |
+ if (process_id == signin_host_id_) |
+ return; |
+ DLOG_IF(WARNING, signin_host_id_ != ChildProcessHost::kInvalidUniqueID) |
+ << "Replacing in-use signin process."; |
+ signin_host_id_ = process_id; |
+ RenderProcessHost* host = RenderProcessHost::FromID(process_id); |
+ DCHECK(host); |
+ host->AddObserver(this); |
+ signin_hosts_observed_.insert(host); |
+} |
+ |
+void ChromeSigninClient::ClearSigninProcess() { |
+ signin_host_id_ = ChildProcessHost::kInvalidUniqueID; |
+} |
+ |
+bool ChromeSigninClient::IsSigninProcess(int process_id) const { |
+ return process_id == signin_host_id_; |
+} |
+ |
+bool ChromeSigninClient::HasSigninProcess() const { |
+ return signin_host_id_ != ChildProcessHost::kInvalidUniqueID; |
+} |
+ |
+void ChromeSigninClient::RenderProcessHostDestroyed(RenderProcessHost* host) { |
+ // It's possible we're listening to a "stale" renderer because it was replaced |
+ // with a new process by process-per-site. In either case, stop observing it, |
+ // but only reset signin_host_id_ tracking if this was from the current signin |
+ // process. |
+ signin_hosts_observed_.erase(host); |
+ if (signin_host_id_ == host->GetID()) |
+ signin_host_id_ = ChildProcessHost::kInvalidUniqueID; |
+} |
+ |
PrefService* ChromeSigninClient::GetPrefs() { return profile_->GetPrefs(); } |
scoped_refptr<TokenWebData> ChromeSigninClient::GetDatabase() { |