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

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: Extracting app_host_installer_impl_win.*; proposing simplified flow to switch between threads for A… 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 17c738af73e084b95dabe176e7ce639f911ccff0..461471b73a921adc8a7e5db26aeaad336f1f9835 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,12 +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_,
- syncer::StringOrdinal(),
- false /* no requirement errors */);
+ callback_.Run();
}
delete this;
}
@@ -253,11 +255,32 @@ 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(*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_,

Powered by Google App Engine
This is Rietveld 408576698