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

Unified Diff: chrome/browser/extensions/crx_installer.cc

Issue 10689097: Enforce the 'requirements' field in manifests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed UnpackedInstller issue Created 8 years, 3 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 | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/crx_installer.cc
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index d17820497c38819cf055bb9b4543362f7940d3dc..3d4071b7eba902a5f9e63941b07e31d1de4f73d0 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -14,7 +14,7 @@
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
-#include "base/stl_util.h"
+#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
@@ -29,6 +29,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/permissions_updater.h"
+#include "chrome/browser/extensions/requirements_checker.h"
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/shell_integration.h"
@@ -101,7 +102,10 @@ CrxInstaller::CrxInstaller(
creation_flags_(Extension::NO_FLAGS),
off_store_install_allow_reason_(OffStoreInstallDisallowed),
did_handle_successfully_(true),
- record_oauth2_grant_(false) {
+ record_oauth2_grant_(false),
+ error_on_unsupported_requirements_(false),
+ requirements_checker_(new extensions::RequirementsChecker()),
+ has_requirement_errors_(false) {
if (!approval)
return;
@@ -385,11 +389,35 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir,
}
if (!BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&CrxInstaller::ConfirmInstall, this)))
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&CrxInstaller::CheckRequirements, this)))
NOTREACHED();
}
+void CrxInstaller::CheckRequirements() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ AddRef(); // Balanced in OnRequirementsChecked().
+ requirements_checker_->Check(extension_,
+ base::Bind(&CrxInstaller::OnRequirementsChecked,
+ this));
+}
+
+void CrxInstaller::OnRequirementsChecked(
+ std::vector<std::string> requirement_errors) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ Release(); // Balanced in CheckRequirements().
+ if (!requirement_errors.empty()) {
+ if (error_on_unsupported_requirements_) {
+ ReportFailureFromUIThread(CrxInstallerError(
+ UTF8ToUTF16(JoinString(requirement_errors, ' '))));
+ return;
+ }
+ has_requirement_errors_ = true;
+ }
+
+ ConfirmInstall();
+}
+
void CrxInstaller::ConfirmInstall() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!frontend_weak_.get())
@@ -598,8 +626,10 @@ void CrxInstaller::ReportSuccessFromUIThread() {
// Tell the frontend about the installation and hand off ownership of
// extension_ to it.
- frontend_weak_->OnExtensionInstalled(extension_, is_gallery_install(),
- page_ordinal_);
+ frontend_weak_->OnExtensionInstalled(extension_,
+ is_gallery_install(),
+ page_ordinal_,
+ has_requirement_errors_);
NotifyCrxInstallComplete(extension_.get());
« no previous file with comments | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698