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

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

Issue 2740853002: Use PreloadCheckGroup in ExtensionInstallChecker. Make RequirementsChecker a PreloadCheck. (Closed)
Patch Set: Created 3 years, 9 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/unpacked_installer.h ('k') | extensions/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/unpacked_installer.cc
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index 02e59d907a93627825b838b1adc69d73b4863b6f..c6b3ed244bed199af479ef82616b08be3647c6ca 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/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"
@@ -149,18 +149,18 @@ bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
}
std::string error;
- install_checker_.set_extension(
+ extension_ =
file_util::LoadExtension(
- extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get());
+ extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error);
- if (!extension() ||
+ if (!extension_ ||
!extension_l10n_util::ValidateExtensionLocales(
- extension_path_, extension()->manifest()->value(), &error)) {
+ extension_path_, extension_->manifest()->value(), &error)) {
ReportExtensionLoadError(error);
return false;
}
- if (only_allow_apps && !extension()->is_platform_app()) {
+ if (only_allow_apps && !extension_->is_platform_app()) {
#if defined(GOOGLE_CHROME_BUILD)
// Avoid crashing for users with hijacked shortcuts.
return true;
@@ -174,13 +174,13 @@ bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
#endif
}
- extension()->permissions_data()->BindToCurrentThread();
+ extension_->permissions_data()->BindToCurrentThread();
PermissionsUpdater(
service_weak_->profile(), PermissionsUpdater::INIT_FLAG_TRANSIENT)
- .InitializePermissions(extension());
+ .InitializePermissions(extension_.get());
ShowInstallPrompt();
- *extension_id = extension()->id();
+ *extension_id = extension_->id();
return true;
}
@@ -192,10 +192,10 @@ void UnpackedInstaller::ShowInstallPrompt() {
const ExtensionSet& disabled_extensions =
ExtensionRegistry::Get(service_weak_->profile())->disabled_extensions();
if (prompt_for_plugins_ &&
- PluginInfo::HasPlugins(extension()) &&
- !disabled_extensions.Contains(extension()->id())) {
+ PluginInfo::HasPlugins(extension_.get()) &&
+ !disabled_extensions.Contains(extension_->id())) {
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
- extension(),
+ extension_.get(),
install_checker_.profile(),
base::Bind(&UnpackedInstaller::StartInstallChecks, this));
prompt->ShowPrompt();
@@ -209,16 +209,16 @@ void UnpackedInstaller::StartInstallChecks() {
// they are disabled for extensions loaded from the command-line is that
// installing unpacked extensions is asynchronous, but there can be
// dependencies between the extensions loaded by the command line.
- if (extension()->manifest()->location() != Manifest::COMMAND_LINE) {
+ if (extension_->manifest()->location() != Manifest::COMMAND_LINE) {
ExtensionService* service = service_weak_.get();
if (!service || service->browser_terminating())
return;
// TODO(crbug.com/420147): Move this code to a utility class to avoid
// duplication of SharedModuleService::CheckImports code.
- if (SharedModuleInfo::ImportsModules(extension())) {
+ if (SharedModuleInfo::ImportsModules(extension_.get())) {
const std::vector<SharedModuleInfo::ImportInfo>& imports =
- SharedModuleInfo::GetImports(extension());
+ SharedModuleInfo::GetImports(extension_.get());
std::vector<SharedModuleInfo::ImportInfo>::const_iterator i;
for (i = imports.begin(); i != imports.end(); ++i) {
base::Version version_required(i->minimum_version);
@@ -242,6 +242,7 @@ void UnpackedInstaller::StartInstallChecks() {
}
install_checker_.Start(
+ extension_,
ExtensionInstallChecker::CHECK_REQUIREMENTS |
ExtensionInstallChecker::CHECK_MANAGEMENT_POLICY,
true /* fail fast */,
@@ -252,13 +253,14 @@ void UnpackedInstaller::OnInstallChecksComplete(int failed_checks) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!install_checker_.policy_error().empty()) {
- ReportExtensionLoadError(install_checker_.policy_error());
+ ReportExtensionLoadError(
+ base::UTF16ToUTF8(install_checker_.policy_error()));
return;
}
- if (!install_checker_.requirement_errors().empty()) {
+ if (!install_checker_.requirement_error_message().empty()) {
ReportExtensionLoadError(
- base::JoinString(install_checker_.requirement_errors(), " "));
+ base::UTF16ToUTF8(install_checker_.requirement_error_message()));
return;
}
@@ -329,13 +331,13 @@ void UnpackedInstaller::LoadWithFileAccess(int flags) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
std::string error;
- install_checker_.set_extension(
+ extension_ =
file_util::LoadExtension(
- extension_path_, Manifest::UNPACKED, flags, &error).get());
+ extension_path_, Manifest::UNPACKED, flags, &error);
- if (!extension() ||
+ if (!extension_ ||
!extension_l10n_util::ValidateExtensionLocales(
- extension_path_, extension()->manifest()->value(), &error)) {
+ extension_path_, extension_->manifest()->value(), &error)) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
@@ -375,14 +377,14 @@ void UnpackedInstaller::InstallExtension() {
}
PermissionsUpdater perms_updater(service_weak_->profile());
- perms_updater.InitializePermissions(extension());
- perms_updater.GrantActivePermissions(extension());
+ perms_updater.InitializePermissions(extension_.get());
+ perms_updater.GrantActivePermissions(extension_.get());
service_weak_->OnExtensionInstalled(
- extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately);
+ extension_.get(), syncer::StringOrdinal(), kInstallFlagInstallImmediately);
if (!callback_.is_null()) {
- callback_.Run(extension(), extension_path_, std::string());
+ callback_.Run(extension_.get(), extension_path_, std::string());
callback_.Reset();
}
}
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.h ('k') | extensions/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698