diff options
4 files changed, 17 insertions, 9 deletions
diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc index 64f67f2..4ed7fca 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc @@ -40,7 +40,8 @@ ExtensionFunction::ResponseAction EXTENSION_FUNCTION_VALIDATE(parameters.get()); PasswordsPrivateDelegate* delegate = - PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); + PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), + true /* create */); delegate->RemoveSavedPassword( parameters->login_pair.origin_url, parameters->login_pair.username); @@ -62,7 +63,8 @@ ExtensionFunction::ResponseAction EXTENSION_FUNCTION_VALIDATE(parameters.get()); PasswordsPrivateDelegate* delegate = - PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); + PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), + true /* create */); delegate->RemovePasswordException(parameters->exception_url); return RespondNow(NoArguments()); @@ -82,7 +84,8 @@ ExtensionFunction::ResponseAction EXTENSION_FUNCTION_VALIDATE(parameters.get()); PasswordsPrivateDelegate* delegate = - PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); + PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), + true /* create */); delegate->RequestShowPassword(parameters->login_pair.origin_url, parameters->login_pair.username, diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.cc index c535df1..c73bf7f 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.cc @@ -16,9 +16,10 @@ using content::BrowserContext; // static PasswordsPrivateDelegate* PasswordsPrivateDelegateFactory::GetForBrowserContext( - BrowserContext* browser_context) { + BrowserContext* browser_context, + bool create) { return static_cast<PasswordsPrivateDelegate*>( - GetInstance()->GetServiceForBrowserContext(browser_context, true)); + GetInstance()->GetServiceForBrowserContext(browser_context, create)); } // static diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h index e7139a3..a5cc994 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h @@ -20,7 +20,8 @@ class PasswordsPrivateDelegateFactory : public BrowserContextKeyedServiceFactory { public: static PasswordsPrivateDelegate* GetForBrowserContext( - content::BrowserContext* browser_context); + content::BrowserContext* browser_context, + bool create); static PasswordsPrivateDelegateFactory* GetInstance(); diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc index 550fc02..c5565a1 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc @@ -48,8 +48,10 @@ void PasswordsPrivateEventRouter::Shutdown() { event_router_->UnregisterObserver(this); PasswordsPrivateDelegate* delegate = - PasswordsPrivateDelegateFactory::GetForBrowserContext(context_); - delegate->RemoveObserver(this); + PasswordsPrivateDelegateFactory::GetForBrowserContext(context_, + false /* create */); + if (delegate) + delegate->RemoveObserver(this); } void PasswordsPrivateEventRouter::OnListenerAdded( @@ -141,7 +143,8 @@ void PasswordsPrivateEventRouter::StartOrStopListeningForChanges() { should_listen_for_plaintext_password_retrieval; PasswordsPrivateDelegate* delegate = - PasswordsPrivateDelegateFactory::GetForBrowserContext(context_); + PasswordsPrivateDelegateFactory::GetForBrowserContext(context_, + true /* create */); if (should_listen && !listening_) delegate->AddObserver(this); else if (!should_listen && listening_) |