Index: chrome/browser/extensions/unpacked_installer.cc |
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc |
index 78432e41c33bfa079ced22f942055e0841e9f3a2..82efde766d0396cd4e331a2b307fd4770d4db09b 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" |
@@ -18,7 +19,9 @@ |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/extension_file_util.h" |
#include "content/public/browser/browser_thread.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; |
@@ -33,7 +36,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(); |
@@ -46,14 +50,17 @@ class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate { |
base::WeakPtr<ExtensionService> service_weak_; |
scoped_ptr<ExtensionInstallPrompt> install_ui_; |
scoped_refptr<const Extension> extension_; |
+ 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)); |
} |
@@ -68,12 +75,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_, |
- syncer::StringOrdinal(), |
- false /* no requirement errors */); |
+ callback_.Run(); |
} |
delete this; |
} |
@@ -255,11 +257,35 @@ 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::InstallAppHostIfNecessary( |
Aaron Boodman
2012/10/25 04:41:34
Same thing here - this should be done via an abstr
huangs
2012/11/01 22:55:48
Per our discussion, moving installation to AppShor
|
+ *extension_, |
+ base::Bind(&UnpackedInstaller::OnAppHostInstallationComplete, this)); |
+} |
+ |
+void UnpackedInstaller::OnAppHostInstallationComplete(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_, |