Index: chrome/browser/extensions/unpacked_installer.cc |
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc |
index 298d3ba6f66e892f32973beea26d5ba1defe3cc9..f5f218723b93fb7c1246c29463930b07ae61760e 100644 |
--- a/chrome/browser/extensions/unpacked_installer.cc |
+++ b/chrome/browser/extensions/unpacked_installer.cc |
@@ -9,6 +9,7 @@ |
#include "base/file_util.h" |
#include "base/string_util.h" |
#include "base/threading/thread_restrictions.h" |
+#include "chrome/browser/extensions/app_host_installer.h" |
#include "chrome/browser/extensions/extension_install_prompt.h" |
#include "chrome/browser/extensions/extension_install_ui.h" |
#include "chrome/browser/extensions/extension_prefs.h" |
@@ -17,7 +18,9 @@ |
#include "chrome/browser/extensions/requirements_checker.h" |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/extension_file_util.h" |
+#include "grit/generated_resources.h" |
#include "sync/api/string_ordinal.h" |
+#include "ui/base/l10n/l10n_util.h" |
using content::BrowserThread; |
using extensions::Extension; |
@@ -32,7 +35,8 @@ class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate { |
public: |
SimpleExtensionLoadPrompt(Profile* profile, |
base::WeakPtr<ExtensionService> extension_service, |
- const Extension* extension); |
+ const Extension* extension, |
+ const base::Closure& callback); |
~SimpleExtensionLoadPrompt(); |
void ShowPrompt(); |
@@ -45,14 +49,17 @@ class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate { |
base::WeakPtr<ExtensionService> service_weak_; |
scoped_ptr<ExtensionInstallPrompt> install_ui_; |
scoped_refptr<const Extension> extension_; |
+ const base::Closure& callback_; |
}; |
SimpleExtensionLoadPrompt::SimpleExtensionLoadPrompt( |
Profile* profile, |
base::WeakPtr<ExtensionService> extension_service, |
- const Extension* extension) |
+ const Extension* extension, |
+ const base::Closure& callback) |
: service_weak_(extension_service), |
- extension_(extension) { |
+ extension_(extension), |
+ callback_(callback) { |
install_ui_.reset( |
ExtensionInstallUI::CreateInstallPromptWithProfile(profile)); |
} |
@@ -66,13 +73,7 @@ void SimpleExtensionLoadPrompt::ShowPrompt() { |
void SimpleExtensionLoadPrompt::InstallUIProceed() { |
if (service_weak_.get()) { |
- extensions::PermissionsUpdater perms_updater(service_weak_->profile()); |
- perms_updater.GrantActivePermissions(extension_, false); |
- service_weak_->OnExtensionInstalled( |
- extension_, |
- false, // Not from web store. |
- syncer::StringOrdinal(), |
- false /* no requirement errors */); |
+ callback_.Run(); |
} |
delete this; |
} |
@@ -254,11 +255,33 @@ void UnpackedInstaller::OnLoaded() { |
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( |
service_weak_->profile(), |
service_weak_, |
- extension_); |
+ extension_, |
+ base::Bind(&UnpackedInstaller::BeginInstall, this)); |
prompt->ShowPrompt(); |
return; // continues in SimpleExtensionLoadPrompt::InstallPrompt* |
} |
+ BeginInstall(); |
+} |
+ |
+void UnpackedInstaller::BeginInstall() { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ app_host_installer_.InstallAppHostIfNecessaryThenCall( |
+ *extension_, |
+ base::Bind(&UnpackedInstaller::OnAppHostInstallation, this)); |
+} |
+ |
+void UnpackedInstaller::OnAppHostInstallation(bool success) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (!success) { |
+ UnpackedInstaller::ReportExtensionLoadError( |
+ l10n_util::GetStringUTF8(IDS_EXTENSION_APP_HOST_INSTALL_ERROR)); |
+ return; |
+ } |
+ CompleteInstall(); |
+} |
+void UnpackedInstaller::CompleteInstall() { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
PermissionsUpdater perms_updater(service_weak_->profile()); |
perms_updater.GrantActivePermissions(extension_, false); |
service_weak_->OnExtensionInstalled(extension_, |