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

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

Issue 11054006: Make application shortcuts point to app_host.exe, install App Host during app installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moving quick-enable-app-host feature; adding App Host install code for unpacked extension installer. Created 8 years, 2 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 298d3ba6f66e892f32973beea26d5ba1defe3cc9..744eaf6357d8f0d3aa5a2b5dd8dda539ab85512d 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"
@@ -41,10 +42,14 @@ class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate {
virtual void InstallUIProceed() OVERRIDE;
virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
+ void OnAppHostInstallation(bool success);
+ void CompleteInstall();
+
private:
base::WeakPtr<ExtensionService> service_weak_;
scoped_ptr<ExtensionInstallPrompt> install_ui_;
scoped_refptr<const Extension> extension_;
+ extensions::AppHostInstaller app_host_installer_;
};
SimpleExtensionLoadPrompt::SimpleExtensionLoadPrompt(
@@ -66,14 +71,36 @@ 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 */);
+ if (extensions::AppHostInstaller::IsAppHostInstallRequired(*extension_)) {
+ // TODO(huangs): Should this be Unretained, or not?
+ app_host_installer_.InstallAppHost(
+ base::Bind(&SimpleExtensionLoadPrompt::OnAppHostInstallation,
+ base::Unretained(this)));
+ } else {
+ CompleteInstall();
+ }
+ } else {
+ delete this;
+ }
+}
+
+void SimpleExtensionLoadPrompt::OnAppHostInstallation(bool success) {
+ if (success) {
+ CompleteInstall();
+ } else {
+ // TODO(huangs): Error message.
+ delete this;
}
+}
+
+void SimpleExtensionLoadPrompt::CompleteInstall() {
+ 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 */);
delete this;
}
@@ -259,6 +286,27 @@ void UnpackedInstaller::OnLoaded() {
return; // continues in SimpleExtensionLoadPrompt::InstallPrompt*
}
+ if (AppHostInstaller::IsAppHostInstallRequired(*extension_)) {
+ // Calls CompleteInstall() after.
+ app_host_installer_.InstallAppHost(
+ base::Bind(&UnpackedInstaller::OnAppHostInstallation, this));
+ } else {
+ CompleteInstall();
+ }
+}
+
+void UnpackedInstaller::OnAppHostInstallation(bool success) {
+ if (success) {
+ CompleteInstall();
+ } else {
+ // TODO(huangs): Error message.
+ std::string error = "Some random error message";
+ UnpackedInstaller::ReportExtensionLoadError(error);
+ }
+}
+
+void UnpackedInstaller::CompleteInstall() {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PermissionsUpdater perms_updater(service_weak_->profile());
perms_updater.GrantActivePermissions(extension_, false);
service_weak_->OnExtensionInstalled(extension_,

Powered by Google App Engine
This is Rietveld 408576698