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

Side by Side Diff: chrome/browser/apps/ephemeral_app_launcher.cc

Issue 242613004: Replace NOTIFICATION_EXTENSION_LOADED to NOTIFICATION_EXTENSION_LOADED_DEPRECATED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/apps/ephemeral_app_launcher.h" 5 #include "chrome/browser/apps/ephemeral_app_launcher.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_install_prompt.h" 8 #include "chrome/browser/extensions/extension_install_prompt.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 webstore_item_id, 130 webstore_item_id,
131 ProfileForWebContents(web_contents), 131 ProfileForWebContents(web_contents),
132 callback), 132 callback),
133 content::WebContentsObserver(web_contents), 133 content::WebContentsObserver(web_contents),
134 parent_window_(NativeWindowForWebContents(web_contents)) { 134 parent_window_(NativeWindowForWebContents(web_contents)) {
135 } 135 }
136 136
137 EphemeralAppLauncher::~EphemeralAppLauncher() {} 137 EphemeralAppLauncher::~EphemeralAppLauncher() {}
138 138
139 void EphemeralAppLauncher::StartObserving() { 139 void EphemeralAppLauncher::StartObserving() {
140 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 140 registrar_.Add(this,
141 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
141 content::Source<Profile>(profile()->GetOriginalProfile())); 142 content::Source<Profile>(profile()->GetOriginalProfile()));
142 } 143 }
143 144
144 void EphemeralAppLauncher::LaunchApp(const Extension* extension) const { 145 void EphemeralAppLauncher::LaunchApp(const Extension* extension) const {
145 DCHECK(extension); 146 DCHECK(extension);
146 if (!extension->is_app()) { 147 if (!extension->is_app()) {
147 LOG(ERROR) << "Unable to launch extension " << extension->id() 148 LOG(ERROR) << "Unable to launch extension " << extension->id()
148 << ". It is not an app."; 149 << ". It is not an app.";
149 return; 150 return;
150 } 151 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 248 }
248 249
249 void EphemeralAppLauncher::CompleteInstall(const std::string& error) { 250 void EphemeralAppLauncher::CompleteInstall(const std::string& error) {
250 if (!error.empty()) 251 if (!error.empty())
251 WebstoreStandaloneInstaller::CompleteInstall(error); 252 WebstoreStandaloneInstaller::CompleteInstall(error);
252 253
253 // If the installation succeeds, we reach this point as a result of 254 // If the installation succeeds, we reach this point as a result of
254 // chrome::NOTIFICATION_EXTENSION_INSTALLED, but this is broadcasted before 255 // chrome::NOTIFICATION_EXTENSION_INSTALLED, but this is broadcasted before
255 // ExtensionService has added the extension to its list of installed 256 // ExtensionService has added the extension to its list of installed
256 // extensions and is too early to launch the app. Instead, we will launch at 257 // extensions and is too early to launch the app. Instead, we will launch at
257 // chrome::NOTIFICATION_EXTENSION_LOADED. 258 // chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED.
258 // TODO(tmdiep): Refactor extensions/WebstoreInstaller or 259 // TODO(tmdiep): Refactor extensions/WebstoreInstaller or
259 // WebstoreStandaloneInstaller to support this cleanly. 260 // WebstoreStandaloneInstaller to support this cleanly.
260 } 261 }
261 262
262 void EphemeralAppLauncher::WebContentsDestroyed( 263 void EphemeralAppLauncher::WebContentsDestroyed(
263 content::WebContents* web_contents) { 264 content::WebContents* web_contents) {
264 AbortInstall(); 265 AbortInstall();
265 } 266 }
266 267
267 void EphemeralAppLauncher::Observe( 268 void EphemeralAppLauncher::Observe(
268 int type, 269 int type,
269 const content::NotificationSource& source, 270 const content::NotificationSource& source,
270 const content::NotificationDetails& details) { 271 const content::NotificationDetails& details) {
271 switch (type) { 272 switch (type) {
272 case chrome::NOTIFICATION_EXTENSION_LOADED: { 273 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
273 const extensions::Extension* extension = 274 const extensions::Extension* extension =
274 content::Details<const extensions::Extension>(details).ptr(); 275 content::Details<const extensions::Extension>(details).ptr();
275 DCHECK(extension); 276 DCHECK(extension);
276 if (extension->id() == id()) { 277 if (extension->id() == id()) {
277 LaunchApp(extension); 278 LaunchApp(extension);
278 WebstoreStandaloneInstaller::CompleteInstall(std::string()); 279 WebstoreStandaloneInstaller::CompleteInstall(std::string());
279 } 280 }
280 break; 281 break;
281 } 282 }
282 283
(...skipping 12 matching lines...) Expand all
295 LaunchApp(extension); 296 LaunchApp(extension);
296 WebstoreStandaloneInstaller::CompleteInstall(std::string()); 297 WebstoreStandaloneInstaller::CompleteInstall(std::string());
297 } else { 298 } else {
298 WebstoreStandaloneInstaller::CompleteInstall(kLaunchAbortedError); 299 WebstoreStandaloneInstaller::CompleteInstall(kLaunchAbortedError);
299 } 300 }
300 } 301 }
301 302
302 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { 303 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) {
303 WebstoreStandaloneInstaller::CompleteInstall(kLaunchAbortedError); 304 WebstoreStandaloneInstaller::CompleteInstall(kLaunchAbortedError);
304 } 305 }
OLDNEW
« no previous file with comments | « apps/shell/browser/shell_extension_system.cc ('k') | chrome/browser/autocomplete/extension_app_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698