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

Unified Diff: chrome/browser/ui/extensions/application_launch.cc

Issue 114263005: Convert Extension* to extension id in AppLaunchParams. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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/ui/extensions/application_launch.cc
diff --git a/chrome/browser/ui/extensions/application_launch.cc b/chrome/browser/ui/extensions/application_launch.cc
index 629032384a430f491c60ef3ccab2413b7bcf7641..1f05903653127c263a6c85045379f8cdc76fe58e 100644
--- a/chrome/browser/ui/extensions/application_launch.cc
+++ b/chrome/browser/ui/extensions/application_launch.cc
@@ -118,6 +118,16 @@ class EnableViaAppListFlow : public ExtensionEnableFlowDelegate {
DISALLOW_COPY_AND_ASSIGN(EnableViaAppListFlow);
};
+const Extension* GetExtension(const AppLaunchParams& params) {
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(params.profile)->extension_service();
+ const Extension* extension = service->GetExtensionById(
+ params.extension_id, true);
+ if (!extension)
+ extension = service->GetTerminatedExtension(params.extension_id);
+ return extension;
+}
+
// Get the launch URL for a given extension, with optional override/fallback.
// |override_url|, if non-empty, will be preferred over the extension's
// launch url.
@@ -172,8 +182,10 @@ ui::WindowShowState DetermineWindowShowState(
}
WebContents* OpenApplicationWindow(const AppLaunchParams& params) {
+ const extensions::Extension* const extension = GetExtension(params);
tapted 2013/12/13 03:10:58 nit: probably don't need the extra 'extension::' o
koz (OOO until 15th September) 2013/12/13 03:54:42 Done.
+ if (!extension)
tapted 2013/12/13 03:10:58 I think extension is allowed to be NULL in this fu
koz (OOO until 15th September) 2013/12/13 03:54:42 Done.
+ return NULL;
Profile* const profile = params.profile;
- const extensions::Extension* const extension = params.extension;
const GURL url_input = params.override_url;
DCHECK(!url_input.is_empty() || extension);
@@ -224,8 +236,10 @@ WebContents* OpenApplicationWindow(const AppLaunchParams& params) {
}
WebContents* OpenApplicationTab(const AppLaunchParams& launch_params) {
+ const extensions::Extension* extension = GetExtension(launch_params);
+ if (!extension)
tapted 2013/12/13 03:10:58 This has already been checked in OpenEnabledApplic
koz (OOO until 15th September) 2013/12/13 03:54:42 I think a CHECK is slightly better here because ot
+ return NULL;
Profile* const profile = launch_params.profile;
- const extensions::Extension* extension = launch_params.extension;
WindowOpenDisposition disposition = launch_params.disposition;
Browser* browser = chrome::FindTabbedBrowser(profile,
@@ -317,8 +331,10 @@ WebContents* OpenApplicationTab(const AppLaunchParams& launch_params) {
}
WebContents* OpenEnabledApplication(const AppLaunchParams& params) {
+ const extensions::Extension* extension = GetExtension(params);
+ if (!extension)
+ return NULL;
Profile* profile = params.profile;
- const extensions::Extension* extension = params.extension;
WebContents* tab = NULL;
ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile)->
@@ -387,25 +403,25 @@ AppLaunchParams::AppLaunchParams(Profile* profile,
extensions::LaunchContainer container,
WindowOpenDisposition disposition)
: profile(profile),
- extension(extension),
+ extension_id(extension->id()),
container(container),
disposition(disposition),
desktop_type(chrome::GetActiveDesktop()),
override_url(),
override_bounds(),
- command_line(NULL) {}
+ command_line(CommandLine::NO_PROGRAM) {}
AppLaunchParams::AppLaunchParams(Profile* profile,
const extensions::Extension* extension,
WindowOpenDisposition disposition)
: profile(profile),
- extension(extension),
+ extension_id(extension->id()),
container(extensions::LAUNCH_CONTAINER_NONE),
disposition(disposition),
desktop_type(chrome::GetActiveDesktop()),
override_url(),
override_bounds(),
- command_line(NULL) {
+ command_line(CommandLine::NO_PROGRAM) {
ExtensionService* service =
extensions::ExtensionSystem::Get(profile)->extension_service();
DCHECK(service);
@@ -421,13 +437,13 @@ AppLaunchParams::AppLaunchParams(Profile* profile,
int event_flags,
chrome::HostDesktopType desktop_type)
: profile(profile),
- extension(extension),
+ extension_id(extension->id()),
container(extensions::LAUNCH_CONTAINER_NONE),
disposition(ui::DispositionFromEventFlags(event_flags)),
desktop_type(desktop_type),
override_url(),
override_bounds(),
- command_line(NULL) {
+ command_line(CommandLine::NO_PROGRAM) {
if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
container = extensions::LAUNCH_CONTAINER_TAB;
} else if (disposition == NEW_WINDOW) {
@@ -450,8 +466,10 @@ WebContents* OpenApplication(const AppLaunchParams& params) {
}
void OpenApplicationWithReenablePrompt(const AppLaunchParams& params) {
+ const extensions::Extension* extension = GetExtension(params);
+ if (!extension)
+ return;
Profile* profile = params.profile;
- const extensions::Extension* extension = params.extension;
ExtensionService* service =
extensions::ExtensionSystem::Get(profile)->extension_service();

Powered by Google App Engine
This is Rietveld 408576698