| Index: chrome/browser/signin/signin_manager.cc
|
| diff --git a/chrome/browser/signin/signin_manager.cc b/chrome/browser/signin/signin_manager.cc
|
| index 1f5a507ff71bccdc7e1e3c0379a8755e1dcb890a..b37db7dd4fe18e268f6b4484a2c5f76e0b494960 100644
|
| --- a/chrome/browser/signin/signin_manager.cc
|
| +++ b/chrome/browser/signin/signin_manager.cc
|
| @@ -37,6 +37,7 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/render_process_host.h"
|
| #include "google_apis/gaia/gaia_auth_fetcher.h"
|
| #include "google_apis/gaia/gaia_auth_util.h"
|
| #include "google_apis/gaia/gaia_constants.h"
|
| @@ -62,6 +63,8 @@ const char kGetInfoEmailKey[] = "email";
|
|
|
| const char kGoogleAccountsUrl[] = "https://accounts.google.com";
|
|
|
| +const int kInvalidProcessId = -1;
|
| +
|
| } // namespace
|
|
|
| // This class fetches GAIA cookie on IO thread on behalf of SigninManager which
|
| @@ -199,7 +202,30 @@ SigninManager::SigninManager()
|
| prohibit_signout_(false),
|
| had_two_factor_error_(false),
|
| type_(SIGNIN_TYPE_NONE),
|
| - weak_pointer_factory_(this) {
|
| + weak_pointer_factory_(this),
|
| + signin_process_id_(kInvalidProcessId) {
|
| +}
|
| +
|
| +void SigninManager::SetSigninProcess(int process_id) {
|
| + if (process_id == signin_process_id_)
|
| + return;
|
| + DLOG_IF(WARNING, signin_process_id_ != kInvalidProcessId) <<
|
| + "Replacing in-use signin process.";
|
| + signin_process_id_ = process_id;
|
| + const content::RenderProcessHost* process =
|
| + content::RenderProcessHost::FromID(process_id);
|
| + DCHECK(process);
|
| + registrar_.Add(this,
|
| + content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
|
| + content::Source<content::RenderProcessHost>(process));
|
| +}
|
| +
|
| +bool SigninManager::IsSigninProcess(int process_id) const {
|
| + return process_id == signin_process_id_;
|
| +}
|
| +
|
| +bool SigninManager::HasSigninProcess() const {
|
| + return signin_process_id_ != kInvalidProcessId;
|
| }
|
|
|
| SigninManager::~SigninManager() {
|
| @@ -885,6 +911,20 @@ void SigninManager::Observe(int type,
|
| }
|
| break;
|
| }
|
| + case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
|
| + // 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 listening to it, but only reset signin_process_id_ tracking
|
| + // if this was from the current signin process.
|
| + registrar_.Remove(this,
|
| + content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
|
| + source);
|
| + if (signin_process_id_ ==
|
| + content::Source<content::RenderProcessHost>(source)->GetID()) {
|
| + signin_process_id_ = kInvalidProcessId;
|
| + }
|
| + break;
|
| + }
|
| #endif
|
| default:
|
| NOTREACHED();
|
|
|