diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 22:15:41 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 22:15:41 +0000 |
commit | 6f49a0c37cb312e06a8bb8aa81b88cef905d7edd (patch) | |
tree | 5df7c8d15ba7d60fecc652894d4fd460d350a01b | |
parent | a74321b4c45c0b06ec1e6a00712c902614b8289c (diff) | |
download | chromium_src-6f49a0c37cb312e06a8bb8aa81b88cef905d7edd.zip chromium_src-6f49a0c37cb312e06a8bb8aa81b88cef905d7edd.tar.gz chromium_src-6f49a0c37cb312e06a8bb8aa81b88cef905d7edd.tar.bz2 |
Fix leaky URL requests from ExternalInstallUI.
BUG=346412
TBR=finnur@chromium.org (same fix as from https://codereview.chromium.org/189003006)
Review URL: https://codereview.chromium.org/208603002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258687 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/external_install_ui.cc | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/chrome/browser/extensions/external_install_ui.cc b/chrome/browser/extensions/external_install_ui.cc index a071228..665b1e1 100644 --- a/chrome/browser/extensions/external_install_ui.cc +++ b/chrome/browser/extensions/external_install_ui.cc @@ -62,6 +62,7 @@ class ExternalInstallGlobalError; class ExternalInstallDialogDelegate : public ExtensionInstallPrompt::Delegate, public WebstoreDataFetcherDelegate, + public content::NotificationObserver, public base::RefCountedThreadSafe<ExternalInstallDialogDelegate> { public: ExternalInstallDialogDelegate(Browser* browser, @@ -88,6 +89,11 @@ class ExternalInstallDialogDelegate virtual void OnWebstoreResponseParseFailure( const std::string& error) OVERRIDE; + // NotificationObserver: + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + // Show the install dialog to the user. void ShowInstallUI(); @@ -98,6 +104,7 @@ class ExternalInstallDialogDelegate Browser* browser_; base::WeakPtr<ExtensionService> service_weak_; scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_; + content::NotificationRegistrar registrar_; std::string extension_id_; bool use_global_error_; @@ -230,6 +237,11 @@ ExternalInstallDialogDelegate::ExternalInstallDialogDelegate( return; } + // Make sure to be notified if the owning profile is destroyed. + registrar_.Add(this, + chrome::NOTIFICATION_PROFILE_DESTROYED, + content::Source<Profile>(browser->profile())); + webstore_data_fetcher_.reset(new WebstoreDataFetcher( this, browser->profile()->GetRequestContext(), @@ -272,6 +284,15 @@ void ExternalInstallDialogDelegate::OnWebstoreResponseParseFailure( ShowInstallUI(); } +void ExternalInstallDialogDelegate::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_DESTROYED); + // If the owning profile is destroyed, we need to abort so that we don't leak. + InstallUIAbort(false); // Not user initiated. +} + void ExternalInstallDialogDelegate::ShowInstallUI() { const Extension* extension = NULL; if (!service_weak_.get() || @@ -296,21 +317,19 @@ ExternalInstallDialogDelegate::~ExternalInstallDialogDelegate() { void ExternalInstallDialogDelegate::InstallUIProceed() { const Extension* extension = NULL; - if (!service_weak_.get() || - !(extension = service_weak_->GetInstalledExtension(extension_id_))) { - return; + if (service_weak_.get() && + (extension = service_weak_->GetInstalledExtension(extension_id_))) { + service_weak_->GrantPermissionsAndEnableExtension(extension); } - service_weak_->GrantPermissionsAndEnableExtension(extension); Release(); } void ExternalInstallDialogDelegate::InstallUIAbort(bool user_initiated) { const Extension* extension = NULL; - if (!service_weak_.get() || - !(extension = service_weak_->GetInstalledExtension(extension_id_))) { - return; + if (service_weak_.get() && + (extension = service_weak_->GetInstalledExtension(extension_id_))) { + service_weak_->UninstallExtension(extension_id_, false, NULL); } - service_weak_->UninstallExtension(extension_id_, false, NULL); Release(); } |