| Index: chrome/browser/extensions/unpacked_installer.cc
|
| diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
|
| index f314c4b4ebf9daa12ee79ae6e5cdab2e131b42fe..9f71acbb380bd63905b290b8a6a227c0492bae65 100644
|
| --- a/chrome/browser/extensions/unpacked_installer.cc
|
| +++ b/chrome/browser/extensions/unpacked_installer.cc
|
| @@ -7,12 +7,14 @@
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| #include "base/file_util.h"
|
| +#include "base/string_util.h"
|
| #include "base/threading/thread_restrictions.h"
|
| #include "chrome/browser/extensions/extension_install_prompt.h"
|
| #include "chrome/browser/extensions/extension_install_ui.h"
|
| #include "chrome/browser/extensions/extension_prefs.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/permissions_updater.h"
|
| +#include "chrome/browser/extensions/requirements_checker.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/extensions/extension_file_util.h"
|
| #include "chrome/common/string_ordinal.h"
|
| @@ -67,7 +69,10 @@ void SimpleExtensionLoadPrompt::InstallUIProceed() {
|
| extensions::PermissionsUpdater perms_updater(service_weak_->profile());
|
| perms_updater.GrantActivePermissions(extension_, false);
|
| service_weak_->OnExtensionInstalled(
|
| - extension_, false, StringOrdinal()); // Not from web store.
|
| + extension_,
|
| + false, // Not from web store.
|
| + StringOrdinal(),
|
| + false /* no requirement errors */);
|
| }
|
| delete this;
|
| }
|
| @@ -89,7 +94,8 @@ scoped_refptr<UnpackedInstaller> UnpackedInstaller::Create(
|
|
|
| UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service)
|
| : service_weak_(extension_service->AsWeakPtr()),
|
| - prompt_for_plugins_(true) {
|
| + prompt_for_plugins_(true),
|
| + requirements_checker_(new RequirementsChecker()) {
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| }
|
|
|
| @@ -105,6 +111,8 @@ void UnpackedInstaller::Load(const FilePath& path_in) {
|
| }
|
|
|
| void UnpackedInstaller::LoadFromCommandLine(const FilePath& path_in) {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| if (!service_weak_.get())
|
| return;
|
| // Load extensions from the command line synchronously to avoid a race
|
| @@ -130,18 +138,36 @@ void UnpackedInstaller::LoadFromCommandLine(const FilePath& path_in) {
|
| flags |= Extension::ALLOW_FILE_ACCESS;
|
|
|
| std::string error;
|
| - scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
|
| + extension_ = extension_file_util::LoadExtension(
|
| extension_path_,
|
| Extension::LOAD,
|
| flags | Extension::FOLLOW_SYMLINKS_ANYWHERE,
|
| - &error));
|
| + &error);
|
|
|
| - if (!extension) {
|
| + if (!extension_.get()) {
|
| ReportExtensionLoadError(error);
|
| return;
|
| }
|
|
|
| - OnLoaded(extension);
|
| + CheckRequirements();
|
| +}
|
| +
|
| +void UnpackedInstaller::CheckRequirements() {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + requirements_checker_->Check(
|
| + extension_,
|
| + base::Bind(&UnpackedInstaller::RequirementsChecked, this));
|
| +}
|
| +
|
| +void UnpackedInstaller::RequirementsChecked(std::vector<std::string> errors) {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + if (!errors.empty()) {
|
| + ReportExtensionLoadError(JoinString(errors, ' '));
|
| + return;
|
| + }
|
| +
|
| + OnLoaded();
|
| }
|
|
|
| bool UnpackedInstaller::IsLoadingUnpackedAllowed() const {
|
| @@ -191,13 +217,13 @@ void UnpackedInstaller::LoadWithFileAccess(bool allow_file_access) {
|
| if (allow_file_access)
|
| flags |= Extension::ALLOW_FILE_ACCESS;
|
| std::string error;
|
| - scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
|
| + extension_ = extension_file_util::LoadExtension(
|
| extension_path_,
|
| Extension::LOAD,
|
| flags | Extension::FOLLOW_SYMLINKS_ANYWHERE,
|
| - &error));
|
| + &error);
|
|
|
| - if (!extension) {
|
| + if (!extension_.get()) {
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| base::Bind(
|
| &UnpackedInstaller::ReportExtensionLoadError,
|
| @@ -206,9 +232,7 @@ void UnpackedInstaller::LoadWithFileAccess(bool allow_file_access) {
|
| }
|
|
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| - base::Bind(
|
| - &UnpackedInstaller::OnLoaded,
|
| - this, extension));
|
| + base::Bind(&UnpackedInstaller::CheckRequirements, this));
|
| }
|
|
|
| void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) {
|
| @@ -218,8 +242,7 @@ void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) {
|
| service_weak_->ReportExtensionLoadError(extension_path_, error, true);
|
| }
|
|
|
| -void UnpackedInstaller::OnLoaded(
|
| - const scoped_refptr<const Extension>& extension) {
|
| +void UnpackedInstaller::OnLoaded() {
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| if (!service_weak_.get())
|
| return;
|
| @@ -227,21 +250,22 @@ void UnpackedInstaller::OnLoaded(
|
| service_weak_->disabled_extensions();
|
| if (service_weak_->show_extensions_prompts() &&
|
| prompt_for_plugins_ &&
|
| - !extension->plugins().empty() &&
|
| - !disabled_extensions->Contains(extension->id())) {
|
| + !extension_->plugins().empty() &&
|
| + !disabled_extensions->Contains(extension_->id())) {
|
| SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
|
| service_weak_->profile(),
|
| service_weak_,
|
| - extension);
|
| + extension_);
|
| prompt->ShowPrompt();
|
| return; // continues in SimpleExtensionLoadPrompt::InstallPrompt*
|
| }
|
|
|
| PermissionsUpdater perms_updater(service_weak_->profile());
|
| - perms_updater.GrantActivePermissions(extension, false);
|
| - service_weak_->OnExtensionInstalled(extension,
|
| + perms_updater.GrantActivePermissions(extension_, false);
|
| + service_weak_->OnExtensionInstalled(extension_,
|
| false, // Not from web store.
|
| - StringOrdinal());
|
| + StringOrdinal(),
|
| + false /* no requirement errors */);
|
| }
|
|
|
| } // namespace extensions
|
|
|