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

Unified Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 297263003: Optimize promotion of ephemeral apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 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/api/webstore_private/webstore_private_api.cc
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index 09a13a0a198c5e6bbd421ae5bbc520042408232a..e3acae2d8295510babedd16abf3cc35ccfae98ae 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -41,6 +41,7 @@
#include "content/public/common/referrer.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/error_utils.h"
@@ -564,8 +565,6 @@ bool WebstorePrivateCompleteInstallFunction::RunAsync() {
return false;
}
- // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure().
- AddRef();
AppListService* app_list_service =
AppListService::Get(GetCurrentBrowser()->host_desktop_type());
@@ -583,6 +582,22 @@ bool WebstorePrivateCompleteInstallFunction::RunAsync() {
app_list_service->AutoShowForProfile(GetProfile());
}
+ // If the target extension has already been installed ephemerally, it can
+ // be promoted to a regular installed extension and downloading from the Web
+ // Store is not necessary.
+ const Extension* extension = ExtensionRegistry::Get(GetProfile())->
+ GetExtensionById(params->expected_id, ExtensionRegistry::EVERYTHING);
+ if (extension && util::IsEphemeralApp(extension->id(), GetProfile())) {
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(GetProfile())->extension_service();
+ extension_service->PromoteEphemeralApp(extension, false);
+ OnInstallSuccess(extension->id());
+ return true;
+ }
+
+ // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure().
+ AddRef();
+
// The extension will install through the normal extension install flow, but
// the whitelist entry will bypass the normal permissions install dialog.
scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
@@ -599,13 +614,7 @@ bool WebstorePrivateCompleteInstallFunction::RunAsync() {
void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess(
const std::string& id) {
- if (test_webstore_installer_delegate)
- test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
-
- VLOG(1) << "Install success, sending response";
- g_pending_installs.Get().EraseInstall(GetProfile(), id);
- SendResponse(true);
-
+ OnInstallSuccess(id);
RecordWebstoreExtensionInstallResult(true);
// Matches the AddRef in RunAsync().
@@ -632,6 +641,16 @@ void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure(
Release();
}
+void WebstorePrivateCompleteInstallFunction::OnInstallSuccess(
+ const std::string& id) {
+ if (test_webstore_installer_delegate)
+ test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
+
+ VLOG(1) << "Install success, sending response";
+ g_pending_installs.Get().EraseInstall(GetProfile(), id);
+ SendResponse(true);
+}
+
WebstorePrivateEnableAppLauncherFunction::
WebstorePrivateEnableAppLauncherFunction() {}
« no previous file with comments | « chrome/browser/extensions/api/webstore_private/webstore_private_api.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698