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

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

Issue 381553002: Update the CrxInstaller and UnpackedInstaller to use the ExtensionInstallChecker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved include to correct file Created 6 years, 5 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/unpacked_installer.cc
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index cb7966f8908b27b491430611cfdbff67953ee48d..52dd01a162e61fc6dcf50205686b1e762251e5b2 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -9,7 +9,6 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
@@ -115,7 +114,7 @@ UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service)
prompt_for_plugins_(true),
require_modern_manifest_version_(true),
be_noisy_on_failure_(true),
- installer_(extension_service->profile()) {
+ install_checker_(extension_service->profile()) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
@@ -152,22 +151,20 @@ bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
}
std::string error;
- installer_.set_extension(
+ install_checker_.set_extension(
file_util::LoadExtension(
extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get());
- if (!installer_.extension().get() ||
+ if (!extension() ||
!extension_l10n_util::ValidateExtensionLocales(
- extension_path_,
- installer_.extension()->manifest()->value(),
- &error)) {
+ extension_path_, extension()->manifest()->value(), &error)) {
ReportExtensionLoadError(error);
return false;
}
ShowInstallPrompt();
- *extension_id = installer_.extension()->id();
+ *extension_id = extension()->id();
return true;
}
@@ -179,33 +176,41 @@ void UnpackedInstaller::ShowInstallPrompt() {
const ExtensionSet& disabled_extensions =
ExtensionRegistry::Get(service_weak_->profile())->disabled_extensions();
if (service_weak_->show_extensions_prompts() && prompt_for_plugins_ &&
- PluginInfo::HasPlugins(installer_.extension().get()) &&
- !disabled_extensions.Contains(installer_.extension()->id())) {
+ PluginInfo::HasPlugins(extension()) &&
+ !disabled_extensions.Contains(extension()->id())) {
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
- installer_.extension().get(),
- installer_.profile(),
- base::Bind(&UnpackedInstaller::CallCheckRequirements, this));
+ extension(),
+ install_checker_.profile(),
+ base::Bind(&UnpackedInstaller::StartInstallChecks, this));
prompt->ShowPrompt();
return;
}
- CallCheckRequirements();
+ StartInstallChecks();
}
-void UnpackedInstaller::CallCheckRequirements() {
- installer_.CheckRequirements(
- base::Bind(&UnpackedInstaller::OnRequirementsChecked, this));
+void UnpackedInstaller::StartInstallChecks() {
+ install_checker_.Start(
+ ExtensionInstallChecker::CHECK_REQUIREMENTS |
+ ExtensionInstallChecker::CHECK_MANAGEMENT_POLICY,
+ true /* fail fast */,
+ base::Bind(&UnpackedInstaller::OnInstallChecksComplete, this));
}
-void UnpackedInstaller::OnRequirementsChecked(
- std::vector<std::string> requirement_errors) {
+void UnpackedInstaller::OnInstallChecksComplete(int failed_checks) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!requirement_errors.empty()) {
- ReportExtensionLoadError(JoinString(requirement_errors, ' '));
+ if (!install_checker_.policy_error().empty()) {
+ ReportExtensionLoadError(install_checker_.policy_error());
return;
}
- ConfirmInstall();
+ if (!install_checker_.requirement_errors().empty()) {
+ ReportExtensionLoadError(
+ JoinString(install_checker_.requirement_errors(), ' '));
+ return;
+ }
+
+ InstallExtension();
}
int UnpackedInstaller::GetFlags() {
@@ -272,15 +277,13 @@ void UnpackedInstaller::LoadWithFileAccess(int flags) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
std::string error;
- installer_.set_extension(
+ install_checker_.set_extension(
file_util::LoadExtension(
extension_path_, Manifest::UNPACKED, flags, &error).get());
- if (!installer_.extension().get() ||
+ if (!extension() ||
!extension_l10n_util::ValidateExtensionLocales(
- extension_path_,
- installer_.extension()->manifest()->value(),
- &error)) {
+ extension_path_, extension()->manifest()->value(), &error)) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
@@ -308,20 +311,14 @@ void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) {
}
}
-void UnpackedInstaller::ConfirmInstall() {
+void UnpackedInstaller::InstallExtension() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::string16 error = installer_.CheckManagementPolicy();
- if (!error.empty()) {
- ReportExtensionLoadError(base::UTF16ToUTF8(error));
- return;
- }
PermissionsUpdater perms_updater(service_weak_->profile());
- perms_updater.GrantActivePermissions(installer_.extension().get());
+ perms_updater.GrantActivePermissions(extension());
- service_weak_->OnExtensionInstalled(installer_.extension().get(),
- syncer::StringOrdinal(),
- kInstallFlagInstallImmediately);
+ service_weak_->OnExtensionInstalled(
+ extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately);
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.h ('k') | chrome/browser/supervised_user/supervised_user_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698