Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5078)

Unified Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 10399069: Reland 137540 - Disable off-store extension installs by default. Also get rid of ExtensionService::… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/download/download_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/chrome_download_manager_delegate.cc
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index 53b0cfd576e1c7f6533d8a48fc43b5a28617bf10..3d1124992a444a9d249e0caa09d485d0fd7d4094 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/extensions/extension_switch_utils.h"
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/download_item.h"
@@ -92,12 +93,12 @@ bool ChromeDownloadManagerDelegate::IsExtensionDownload(
if (item->PromptUserForSaveLocation())
return false;
- if ((item->GetMimeType() != Extension::kMimeType) &&
- !UserScript::IsURLUserScript(item->GetURL(), item->GetMimeType())) {
+ if (item->GetMimeType() == Extension::kMimeType ||
+ UserScript::IsURLUserScript(item->GetURL(), item->GetMimeType())) {
+ return true;
+ } else {
return false;
}
-
- return download_crx_util::ShouldOpenExtensionDownload(*item);
}
void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
@@ -253,22 +254,28 @@ bool ChromeDownloadManagerDelegate::ShouldCompleteDownload(DownloadItem* item) {
bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) {
if (IsExtensionDownload(item)) {
- scoped_refptr<CrxInstaller> crx_installer =
- download_crx_util::OpenChromeExtension(profile_, *item);
-
- // CRX_INSTALLER_DONE will fire when the install completes. Observe()
- // will call DelayedDownloadOpened() on this item. If this DownloadItem is
- // not around when CRX_INSTALLER_DONE fires, Complete() will not be called.
- registrar_.Add(this,
- chrome::NOTIFICATION_CRX_INSTALLER_DONE,
- content::Source<CrxInstaller>(crx_installer.get()));
-
- crx_installers_[crx_installer.get()] = item->GetId();
- // The status text and percent complete indicator will change now
- // that we are installing a CRX. Update observers so that they pick
- // up the change.
- item->UpdateObservers();
- return false;
+ // We can open extensions if either they came from the store, or
+ // off-store-install is enabled.
+ if (extensions::switch_utils::IsOffStoreInstallEnabled() ||
+ WebstoreInstaller::GetAssociatedApproval(*item)) {
+ scoped_refptr<CrxInstaller> crx_installer =
+ download_crx_util::OpenChromeExtension(profile_, *item);
+
+ // CRX_INSTALLER_DONE will fire when the install completes. Observe()
+ // will call DelayedDownloadOpened() on this item. If this DownloadItem
+ // is not around when CRX_INSTALLER_DONE fires, Complete() will not be
+ // called.
+ registrar_.Add(this,
+ chrome::NOTIFICATION_CRX_INSTALLER_DONE,
+ content::Source<CrxInstaller>(crx_installer.get()));
+
+ crx_installers_[crx_installer.get()] = item->GetId();
+ // The status text and percent complete indicator will change now
+ // that we are installing a CRX. Update observers so that they pick
+ // up the change.
+ item->UpdateObservers();
+ return false;
+ }
}
if (ShouldOpenWithWebIntents(item)) {
@@ -693,11 +700,12 @@ bool ChromeDownloadManagerDelegate::IsDangerousFile(
return false;
// Extensions that are not from the gallery are considered dangerous.
- if (IsExtensionDownload(&download)) {
- ExtensionService* service = profile_->GetExtensionService();
- if (!service || !service->IsDownloadFromGallery(download.GetURL(),
- download.GetReferrerUrl()))
- return true;
+ // When off-store install is disabled we skip this, since in this case, we
+ // will not offer to install the extension.
+ if (extensions::switch_utils::IsOffStoreInstallEnabled() &&
+ IsExtensionDownload(&download) &&
+ !WebstoreInstaller::GetAssociatedApproval(download)) {
+ return true;
}
// Anything the user has marked auto-open is OK if it's user-initiated.
« no previous file with comments | « no previous file | chrome/browser/download/download_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698