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

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

Issue 2751013002: Simplify ExtensionInstallChecker into a single-use class (Closed)
Patch Set: todo 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
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..148113f36b5a782b3695c9501369db66452e438c 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -7,9 +7,11 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file_util.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/extensions/extension_error_reporter.h"
+#include "chrome/browser/extensions/extension_install_checker.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -110,10 +112,10 @@ scoped_refptr<UnpackedInstaller> UnpackedInstaller::Create(
UnpackedInstaller::UnpackedInstaller(ExtensionService* extension_service)
: service_weak_(extension_service->AsWeakPtr()),
+ profile_(extension_service->profile()),
prompt_for_plugins_(true),
require_modern_manifest_version_(true),
- be_noisy_on_failure_(true),
- install_checker_(extension_service->profile()) {
+ be_noisy_on_failure_(true) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
@@ -149,9 +151,8 @@ bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
}
std::string error;
- install_checker_.set_extension(
- file_util::LoadExtension(
- extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get());
+ extension_ = file_util::LoadExtension(extension_path_, Manifest::COMMAND_LINE,
+ GetFlags(), &error);
if (!extension() ||
!extension_l10n_util::ValidateExtensionLocales(
@@ -195,8 +196,7 @@ void UnpackedInstaller::ShowInstallPrompt() {
PluginInfo::HasPlugins(extension()) &&
!disabled_extensions.Contains(extension()->id())) {
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
- extension(),
- install_checker_.profile(),
+ extension(), profile_,
base::Bind(&UnpackedInstaller::StartInstallChecks, this));
prompt->ShowPrompt();
return;
@@ -241,24 +241,26 @@ void UnpackedInstaller::StartInstallChecks() {
}
}
- install_checker_.Start(
+ install_checker_ = base::MakeUnique<ExtensionInstallChecker>(
+ profile_, extension_,
ExtensionInstallChecker::CHECK_REQUIREMENTS |
ExtensionInstallChecker::CHECK_MANAGEMENT_POLICY,
- true /* fail fast */,
+ true /* fail fast */);
+ install_checker_->Start(
base::Bind(&UnpackedInstaller::OnInstallChecksComplete, this));
}
void UnpackedInstaller::OnInstallChecksComplete(int failed_checks) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (!install_checker_.policy_error().empty()) {
- ReportExtensionLoadError(install_checker_.policy_error());
+ if (!install_checker_->policy_error().empty()) {
+ ReportExtensionLoadError(install_checker_->policy_error());
return;
}
- if (!install_checker_.requirement_errors().empty()) {
+ if (!install_checker_->requirement_errors().empty()) {
ReportExtensionLoadError(
- base::JoinString(install_checker_.requirement_errors(), " "));
+ base::JoinString(install_checker_->requirement_errors(), " "));
return;
}
@@ -329,9 +331,8 @@ void UnpackedInstaller::LoadWithFileAccess(int flags) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
std::string error;
- install_checker_.set_extension(
- file_util::LoadExtension(
- extension_path_, Manifest::UNPACKED, flags, &error).get());
+ extension_ = file_util::LoadExtension(extension_path_, Manifest::UNPACKED,
+ flags, &error);
if (!extension() ||
!extension_l10n_util::ValidateExtensionLocales(
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.h ('k') | extensions/test/extension_test_notification_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698