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

Unified Diff: chrome/browser/apps/ephemeral_app_launcher.cc

Issue 326213004: Invoke callback from WebstoreInstaller when installation is fully complete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self nits Created 6 years, 6 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/apps/ephemeral_app_launcher.cc
diff --git a/chrome/browser/apps/ephemeral_app_launcher.cc b/chrome/browser/apps/ephemeral_app_launcher.cc
index d95e833a80d90235ccaa445eb9b3750c467e00d1..d46942ea85cc8d7ca2bfc8e3a8dc5a7ae81a6462 100644
--- a/chrome/browser/apps/ephemeral_app_launcher.cc
+++ b/chrome/browser/apps/ephemeral_app_launcher.cc
@@ -5,19 +5,17 @@
#include "chrome/browser/apps/ephemeral_app_launcher.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/extension_enable_flow.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/extension_system.h"
#include "extensions/common/permissions/permissions_data.h"
using content::WebContents;
using extensions::Extension;
-using extensions::ExtensionSystem;
+using extensions::ExtensionRegistry;
using extensions::WebstoreInstaller;
namespace {
@@ -72,11 +70,9 @@ EphemeralAppLauncher::CreateForLink(
}
void EphemeralAppLauncher::Start() {
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile())->extension_service();
- DCHECK(extension_service);
-
- const Extension* extension = extension_service->GetInstalledExtension(id());
+ const Extension* extension =
+ ExtensionRegistry::Get(profile())
+ ->GetExtensionById(id(), ExtensionRegistry::EVERYTHING);
if (extension) {
if (extensions::util::IsAppLaunchableWithoutEnabling(extension->id(),
profile())) {
@@ -101,7 +97,6 @@ void EphemeralAppLauncher::Start() {
}
// Fetch the app from the webstore.
- StartObserving();
BeginInstall();
}
@@ -110,7 +105,6 @@ EphemeralAppLauncher::EphemeralAppLauncher(const std::string& webstore_item_id,
gfx::NativeWindow parent_window,
const Callback& callback)
: WebstoreStandaloneInstaller(webstore_item_id, profile, callback),
- extension_registry_observer_(this),
parent_window_(parent_window),
dummy_web_contents_(
WebContents::Create(WebContents::CreateParams(profile))) {
@@ -123,17 +117,11 @@ EphemeralAppLauncher::EphemeralAppLauncher(const std::string& webstore_item_id,
ProfileForWebContents(web_contents),
callback),
content::WebContentsObserver(web_contents),
- extension_registry_observer_(this),
parent_window_(NativeWindowForWebContents(web_contents)) {
}
EphemeralAppLauncher::~EphemeralAppLauncher() {}
-void EphemeralAppLauncher::StartObserving() {
- extension_registry_observer_.Add(
- extensions::ExtensionRegistry::Get(profile()));
-}
-
void EphemeralAppLauncher::LaunchApp(const Extension* extension) const {
DCHECK(extension);
if (!extension->is_app()) {
@@ -238,46 +226,25 @@ EphemeralAppLauncher::CreateApproval() const {
}
void EphemeralAppLauncher::CompleteInstall(const std::string& error) {
- if (!error.empty())
- WebstoreStandaloneInstaller::CompleteInstall(error);
-
- // If the installation succeeds, we reach this point as a result of
- // chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, but this is
- // broadcasted before
- // ExtensionService has added the extension to its list of installed
- // extensions and is too early to launch the app. Instead, we will launch at
- // EphemeralAppLauncher::OnExtensionLoaded().
- // TODO(tmdiep): Refactor extensions/WebstoreInstaller or
- // WebstoreStandaloneInstaller to support this cleanly.
+ if (error.empty()) {
+ const Extension* extension =
+ ExtensionRegistry::Get(profile())
+ ->GetExtensionById(id(), ExtensionRegistry::ENABLED);
+ if (extension)
+ LaunchApp(extension);
+ }
+
+ WebstoreStandaloneInstaller::CompleteInstall(error);
}
void EphemeralAppLauncher::WebContentsDestroyed() {
AbortInstall();
}
-void EphemeralAppLauncher::OnExtensionLoaded(
- content::BrowserContext* browser_context,
- const Extension* extension) {
- if (extension->id() == id()) {
- LaunchApp(extension);
- WebstoreStandaloneInstaller::CompleteInstall(std::string());
- }
-}
-
void EphemeralAppLauncher::ExtensionEnableFlowFinished() {
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile())->extension_service();
- DCHECK(extension_service);
-
- const Extension* extension = extension_service->GetExtensionById(id(), false);
- if (extension) {
- LaunchApp(extension);
- WebstoreStandaloneInstaller::CompleteInstall(std::string());
- } else {
- WebstoreStandaloneInstaller::CompleteInstall(kLaunchAbortedError);
- }
+ CompleteInstall(std::string());
}
void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) {
- WebstoreStandaloneInstaller::CompleteInstall(kLaunchAbortedError);
+ CompleteInstall(kLaunchAbortedError);
}

Powered by Google App Engine
This is Rietveld 408576698