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

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: Rearranged code for unpacked_installer.cc; moved App Host code from chrome_launch_support to app_ho… 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..1a034dea6dd14574ce1243b4f02571bfab1fcbbe 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"
@@ -32,7 +33,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();
@@ -41,18 +43,25 @@ class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate {
virtual void InstallUIProceed() OVERRIDE;
virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
+ void BeginInstall();
+ void OnAppHostInstallation(bool success);
+ void CompleteInstall();
+
private:
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 +75,7 @@ void SimpleExtensionLoadPrompt::ShowPrompt() {
void SimpleExtensionLoadPrompt::InstallUIProceed() {
if (service_weak_.get()) {
erikwright (departed) 2012/10/04 01:28:16 Remove this check, remove the extension_service me
huangs 2012/10/04 22:56:42 Keeping this the way it was, now that we changed i
- 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 +257,44 @@ void UnpackedInstaller::OnLoaded() {
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
service_weak_->profile(),
service_weak_,
- extension_);
+ extension_,
+ base::Bind(&UnpackedInstaller::OnPromptAccepted, this));
prompt->ShowPrompt();
return; // continues in SimpleExtensionLoadPrompt::InstallPrompt*
}
+ OnPromptAccepted();
+}
+void UnpackedInstaller::OnPromptAccepted() {
+ if (!BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&UnpackedInstaller::BeginInstall, this)))
+ NOTREACHED();
+}
+
+void UnpackedInstaller::BeginInstall() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ if (AppHostInstaller::IsAppHostInstallRequired(*extension_)) {
+ // Calls CompleteInstall() after.
+ app_host_installer_.InstallAppHost(
+ base::Bind(&UnpackedInstaller::OnAppHostInstallation, this));
benwells 2012/10/04 07:53:01 early return and remove the else.
huangs 2012/10/04 22:56:42 Done.
+ } else {
+ CompleteInstall();
+ }
+}
+
+void UnpackedInstaller::OnAppHostInstallation(bool success) {
+ if (success) {
+ CompleteInstall();
benwells 2012/10/04 07:53:01 early return and remove the else.
huangs 2012/10/04 22:56:42 Done.
+ } else {
+ // TODO(huangs): Error message.
+ std::string error = "Some random error message";
+ UnpackedInstaller::ReportExtensionLoadError(error);
+ }
+}
+
+void UnpackedInstaller::CompleteInstall() {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
PermissionsUpdater perms_updater(service_weak_->profile());
erikwright (departed) 2012/10/04 01:28:16 Do a check on service_weak_ around lines 298-303.
erikwright (departed) 2012/10/04 01:28:16 This used to all happen on the UI thread. Have you
huangs 2012/10/04 22:56:42 No check, in light of changed interface to AppHost
huangs 2012/10/04 22:56:42 Changing interface to AppHostInstaller, so still i
perms_updater.GrantActivePermissions(extension_, false);
service_weak_->OnExtensionInstalled(extension_,

Powered by Google App Engine
This is Rietveld 408576698