| Index: chrome/browser/extensions/unpacked_installer.cc
|
| diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
|
| index 80307c0d25743f80e161e5817983721bb3102ce8..298d3ba6f66e892f32973beea26d5ba1defe3cc9 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 "sync/api/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, syncer::StringOrdinal()); // Not from web store.
|
| + extension_,
|
| + false, // Not from web store.
|
| + syncer::StringOrdinal(),
|
| + false /* no requirement errors */);
|
| }
|
| delete this;
|
| }
|
| @@ -90,6 +95,7 @@ scoped_refptr<UnpackedInstaller> UnpackedInstaller::Create(
|
| UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service)
|
| : service_weak_(extension_service->AsWeakPtr()),
|
| prompt_for_plugins_(true),
|
| + requirements_checker_(new RequirementsChecker()),
|
| require_modern_manifest_version_(true) {
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| }
|
| @@ -100,12 +106,16 @@ UnpackedInstaller::~UnpackedInstaller() {
|
| }
|
|
|
| void UnpackedInstaller::Load(const FilePath& path_in) {
|
| + DCHECK(extension_path_.empty());
|
| extension_path_ = path_in;
|
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&UnpackedInstaller::GetAbsolutePath, this));
|
| }
|
|
|
| void UnpackedInstaller::LoadFromCommandLine(const FilePath& path_in) {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK(extension_path_.empty());
|
| +
|
| if (!service_weak_.get())
|
| return;
|
| // Load extensions from the command line synchronously to avoid a race
|
| @@ -121,18 +131,37 @@ void UnpackedInstaller::LoadFromCommandLine(const FilePath& path_in) {
|
| }
|
|
|
| std::string error;
|
| - scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
|
| + extension_ = extension_file_util::LoadExtension(
|
| extension_path_,
|
| Extension::LOAD,
|
| GetFlags(),
|
| - &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::OnRequirementsChecked, this));
|
| +}
|
| +
|
| +void UnpackedInstaller::OnRequirementsChecked(
|
| + std::vector<std::string> requirement_errors) {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + if (!requirement_errors.empty()) {
|
| + ReportExtensionLoadError(JoinString(requirement_errors, ' '));
|
| + return;
|
| + }
|
| +
|
| + OnLoaded();
|
| }
|
|
|
| int UnpackedInstaller::GetFlags() {
|
| @@ -187,13 +216,13 @@ void UnpackedInstaller::LoadWithFileAccess(int flags) {
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
|
|
| std::string error;
|
| - scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
|
| + extension_ = extension_file_util::LoadExtension(
|
| extension_path_,
|
| Extension::LOAD,
|
| flags,
|
| - &error));
|
| + &error);
|
|
|
| - if (!extension) {
|
| + if (!extension_.get()) {
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| base::Bind(
|
| &UnpackedInstaller::ReportExtensionLoadError,
|
| @@ -202,9 +231,7 @@ void UnpackedInstaller::LoadWithFileAccess(int flags) {
|
| }
|
|
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| - base::Bind(
|
| - &UnpackedInstaller::OnLoaded,
|
| - this, extension));
|
| + base::Bind(&UnpackedInstaller::CheckRequirements, this));
|
| }
|
|
|
| void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) {
|
| @@ -214,8 +241,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;
|
| @@ -223,21 +249,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.
|
| - syncer::StringOrdinal());
|
| + syncer::StringOrdinal(),
|
| + false /* no requirement errors */);
|
| }
|
|
|
| } // namespace extensions
|
|
|