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

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

Issue 10689097: Enforce the 'requirements' field in manifests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index e60dbe39081567893a743b19b050d96b25decdb3..3834a3a8ce2eb5a62da966b7484d574ea7a57828 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -93,6 +93,7 @@
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/extension_resource.h"
+#include "chrome/common/extensions/requirements_provider.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -119,7 +120,6 @@
#include "chrome/browser/chromeos/extensions/input_method_event_router.h"
#include "chrome/browser/chromeos/extensions/media_player_event_router.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
-#include "chrome/browser/extensions/extension_input_ime_api.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
#endif
@@ -346,7 +346,7 @@ ExtensionService::ExtensionService(Profile* profile,
api_resource_controller_(NULL),
app_shortcut_manager_(profile) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
+ requirements_provider_.reset(extensions::RequirementsProvider::Create());
// Figure out if extension installation should be enabled.
if (command_line->HasSwitch(switches::kDisableExtensions)) {
extensions_enabled_ = false;
@@ -578,6 +578,7 @@ bool ExtensionService::UpdateExtension(
// We want a silent install only for non-pending extensions and
// pending extensions that have install_silently set.
Browser* browser = browser::FindLastActiveWithProfile(profile_);
+
ExtensionInstallPrompt* client =
(!pending_extension_info || pending_extension_info->install_silently()) ?
NULL : chrome::CreateExtensionInstallPromptWithBrowser(browser);
@@ -613,7 +614,6 @@ bool ExtensionService::UpdateExtension(
creation_flags |= Extension::FROM_BOOKMARK;
installer->set_creation_flags(creation_flags);
-
installer->set_delete_source(true);
installer->set_download_url(download_url);
installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
@@ -1931,6 +1931,17 @@ void ExtensionService::AddExtension(const Extension* extension) {
InitializePermissions(extension);
bool disabled = extension_prefs_->IsExtensionDisabled(extension->id());
+
+ string16 error;
+ if (!requirements_provider_->Supports(*extension->manifest(), &error)) {
Aaron Boodman 2012/07/16 21:16:12 Didn't it look like some of the requirements neede
+ disabled = true;
+ Extension::InstallWarningVector warnings;
+ warnings.push_back(Extension::InstallWarning(
+ Extension::InstallWarning::FORMAT_TEXT, UTF16ToUTF8(error)));
+ // TODO(eriq): Avoid this messy cast.
+ const_cast<Extension*>(extension)->AddInstallWarnings(warnings);
+ }
+
if (disabled) {
disabled_extensions_.Insert(scoped_extension);
SyncExtensionChangeIfNeeded(*extension);

Powered by Google App Engine
This is Rietveld 408576698