diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 01:18:07 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 01:18:07 +0000 |
commit | 86a9911539699e5f43c13047f8c7ffa01fe07f67 (patch) | |
tree | 08a06e74fd81ef29c066537c02b6fafdb987d285 | |
parent | e9452a059dcd465d0a96724fcc0761bc2283022f (diff) | |
download | chromium_src-86a9911539699e5f43c13047f8c7ffa01fe07f67.zip chromium_src-86a9911539699e5f43c13047f8c7ffa01fe07f67.tar.gz chromium_src-86a9911539699e5f43c13047f8c7ffa01fe07f67.tar.bz2 |
Keep shelf item visible when extension install blocked off-store.
BUG=133025
TBR=yoz@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10559026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142885 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/download/chrome_download_manager_delegate.cc | 9 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 7 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer.h | 9 | ||||
-rw-r--r-- | content/browser/download/download_item_impl.cc | 4 | ||||
-rw-r--r-- | content/browser/download/download_item_impl.h | 2 | ||||
-rw-r--r-- | content/public/browser/download_item.h | 2 | ||||
-rw-r--r-- | content/public/test/mock_download_item.h | 2 |
7 files changed, 25 insertions, 10 deletions
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 5837ce9..19b81fa 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -336,7 +336,7 @@ bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) { if (ShouldOpenWithWebIntents(item)) { OpenWithWebIntent(item); - item->DelayedDownloadOpened(); + item->DelayedDownloadOpened(true /* did_open */); return false; } @@ -589,13 +589,14 @@ void ChromeDownloadManagerDelegate::Observe( chrome::NOTIFICATION_CRX_INSTALLER_DONE, source); - CrxInstaller* installer = content::Source<CrxInstaller>(source).ptr(); + scoped_refptr<CrxInstaller> installer = + content::Source<CrxInstaller>(source).ptr(); int download_id = crx_installers_[installer]; - crx_installers_.erase(installer); + crx_installers_.erase(installer.get()); DownloadItem* item = download_manager_->GetActiveDownloadItem(download_id); if (item) - item->DelayedDownloadOpened(); + item->DelayedDownloadOpened(installer->did_handle_successfully()); } void ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone( diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index a4a1c13..27b6808 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -98,7 +98,8 @@ CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, allow_silent_install_(false), install_cause_(extension_misc::INSTALL_CAUSE_UNSET), creation_flags_(Extension::NO_FLAGS), - off_store_install_allow_reason_(OffStoreInstallDisallowed) { + off_store_install_allow_reason_(OffStoreInstallDisallowed), + did_handle_successfully_(true) { if (!approval) return; @@ -271,6 +272,10 @@ bool CrxInstaller::AllowInstall(const Extension* extension, NumOffStoreInstallDecision); *error = l10n_util::GetStringUTF16( IDS_EXTENSION_INSTALL_DISALLOWED_ON_SITE); + // Don't delete source in this case so that the user can install + // manually if they want. + delete_source_ = false; + did_handle_successfully_ = false; return false; } } diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h index f90c85f..4c6c70b 100644 --- a/chrome/browser/extensions/crx_installer.h +++ b/chrome/browser/extensions/crx_installer.h @@ -166,6 +166,8 @@ class CrxInstaller page_ordinal_ = page_ordinal; } + bool did_handle_successfully() const { return did_handle_successfully_; } + Profile* profile() { return profile_; } private: @@ -327,6 +329,13 @@ class CrxInstaller // Whether to allow off store installation. OffStoreInstallAllowReason off_store_install_allow_reason_; + // Whether the installation was handled successfully. This is used to + // indicate to the client whether the file should be removed and any UI + // initiating the installation can be removed. This is different than whether + // there was an error; if there was an error that rejects installation we + // still consider the installation 'handled'. + bool did_handle_successfully_; + DISALLOW_COPY_AND_ASSIGN(CrxInstaller); }; diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc index 82d5f94..d3f80db 100644 --- a/content/browser/download/download_item_impl.cc +++ b/content/browser/download/download_item_impl.cc @@ -492,8 +492,8 @@ void DownloadItemImpl::MarkAsComplete() { TransitionTo(COMPLETE); } -void DownloadItemImpl::DelayedDownloadOpened() { - auto_opened_ = true; +void DownloadItemImpl::DelayedDownloadOpened(bool auto_opened) { + auto_opened_ = auto_opened; Completed(); } diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h index aee6f52..1f72f5ef 100644 --- a/content/browser/download/download_item_impl.h +++ b/content/browser/download/download_item_impl.h @@ -126,7 +126,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { const std::string& hash_state) OVERRIDE; virtual void Cancel(bool user_cancel) OVERRIDE; virtual void MarkAsComplete() OVERRIDE; - virtual void DelayedDownloadOpened() OVERRIDE; + virtual void DelayedDownloadOpened(bool auto_opened) OVERRIDE; virtual void OnAllDataSaved( int64 size, const std::string& final_hash) OVERRIDE; virtual void OnDownloadedFileRemoved() OVERRIDE; diff --git a/content/public/browser/download_item.h b/content/public/browser/download_item.h index a76786e..1101157 100644 --- a/content/public/browser/download_item.h +++ b/content/public/browser/download_item.h @@ -175,7 +175,7 @@ class CONTENT_EXPORT DownloadItem { // Called by the delegate after it delayed opening the download in // DownloadManagerDelegate::ShouldOpenDownload. - virtual void DelayedDownloadOpened() = 0; + virtual void DelayedDownloadOpened(bool auto_opened) = 0; // Called when all data has been saved. Only has display effects. virtual void OnAllDataSaved(int64 size, const std::string& final_hash) = 0; diff --git a/content/public/test/mock_download_item.h b/content/public/test/mock_download_item.h index 8c46bd6..b5e7cdd 100644 --- a/content/public/test/mock_download_item.h +++ b/content/public/test/mock_download_item.h @@ -30,7 +30,7 @@ class MockDownloadItem : public content::DownloadItem { MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&)); MOCK_METHOD1(Cancel, void(bool)); MOCK_METHOD0(MarkAsComplete, void()); - MOCK_METHOD0(DelayedDownloadOpened, void()); + MOCK_METHOD1(DelayedDownloadOpened, void(bool)); MOCK_METHOD2(OnAllDataSaved, void(int64, const std::string&)); MOCK_METHOD0(OnDownloadedFileRemoved, void()); MOCK_METHOD0(MaybeCompleteDownload, void()); |