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

Side by Side Diff: chrome/browser/ui/extensions/application_launch.cc

Issue 10700130: Introduce LaunchParams struct for opening chrome apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar cleanup Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/extensions/application_launch.h" 5 #include "chrome/browser/ui/extensions/application_launch.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/extensions/default_apps_trial.h" 10 #include "chrome/browser/extensions/default_apps_trial.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 bool AllowPanels(const std::string& app_name) { 75 bool AllowPanels(const std::string& app_name) {
76 return PanelManager::ShouldUsePanels( 76 return PanelManager::ShouldUsePanels(
77 web_app::GetExtensionIdFromApplicationName(app_name)); 77 web_app::GetExtensionIdFromApplicationName(app_name));
78 } 78 }
79 79
80 } // namespace 80 } // namespace
81 81
82 namespace application_launch { 82 namespace application_launch {
83 83
84 WebContents* OpenApplication(Profile* profile, 84 LaunchParams::LaunchParams(Profile* profile,
85 const Extension* extension, 85 const extensions::Extension* extension,
86 extension_misc::LaunchContainer container, 86 extension_misc::LaunchContainer container,
87 const GURL& override_url, 87 WindowOpenDisposition disposition)
88 WindowOpenDisposition disposition, 88 : profile(profile),
89 const CommandLine* command_line) { 89 extension(extension),
90 container(container),
91 disposition(disposition),
92 override_url(),
93 command_line(NULL) {}
94
95 WebContents* OpenApplication(const LaunchParams& params) {
96 Profile* profile = params.profile;
97 const extensions::Extension* extension = params.extension;
98 extension_misc::LaunchContainer container = params.container;
99 const GURL& override_url = params.override_url;
100
90 WebContents* tab = NULL; 101 WebContents* tab = NULL;
91 ExtensionPrefs* prefs = profile->GetExtensionService()->extension_prefs(); 102 ExtensionPrefs* prefs = profile->GetExtensionService()->extension_prefs();
92 prefs->SetActiveBit(extension->id(), true); 103 prefs->SetActiveBit(extension->id(), true);
93 104
94 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); 105 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100);
95 #if defined(OS_CHROMEOS) 106 #if defined(OS_CHROMEOS)
96 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) 107 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled())
97 chromeos::KioskModeMetrics::Get()->UserOpenedApp(); 108 chromeos::KioskModeMetrics::Get()->UserOpenedApp();
98 #endif 109 #endif
99 110
100 if (extension->is_platform_app()) { 111 if (extension->is_platform_app()) {
101 extensions::LaunchPlatformApp(profile, extension, command_line); 112 extensions::LaunchPlatformApp(profile, extension, params.command_line);
102 return NULL; 113 return NULL;
103 } 114 }
104 115
105 switch (container) { 116 switch (container) {
106 case extension_misc::LAUNCH_NONE: { 117 case extension_misc::LAUNCH_NONE: {
107 NOTREACHED(); 118 NOTREACHED();
108 break; 119 break;
109 } 120 }
110 case extension_misc::LAUNCH_PANEL: { 121 case extension_misc::LAUNCH_PANEL: {
111 bool open_panel = false; 122 bool open_panel = false;
112 #if defined(USE_ASH) 123 #if defined(USE_ASH)
113 open_panel = CommandLine::ForCurrentProcess()->HasSwitch( 124 open_panel = CommandLine::ForCurrentProcess()->HasSwitch(
114 ash::switches::kAuraPanelManager); 125 ash::switches::kAuraPanelManager);
115 #else 126 #else
116 open_panel = CommandLine::ForCurrentProcess()->HasSwitch( 127 open_panel = CommandLine::ForCurrentProcess()->HasSwitch(
117 switches::kBrowserlessPanels); 128 switches::kBrowserlessPanels);
118 #endif 129 #endif
119 if (open_panel) { 130 if (open_panel) {
120 tab = OpenApplicationPanel(profile, extension, override_url); 131 tab = OpenApplicationPanel(profile, extension, override_url);
121 break; 132 break;
122 } 133 }
123 // else fall through to LAUNCH_WINDOW 134 // else fall through to LAUNCH_WINDOW
124 } 135 }
125 case extension_misc::LAUNCH_WINDOW: 136 case extension_misc::LAUNCH_WINDOW:
126 tab = OpenApplicationWindow(profile, extension, container, 137 tab = OpenApplicationWindow(profile, extension, container,
127 override_url, NULL); 138 override_url, NULL);
128 break; 139 break;
129 case extension_misc::LAUNCH_TAB: { 140 case extension_misc::LAUNCH_TAB: {
130 tab = OpenApplicationTab(profile, extension, override_url, 141 tab = OpenApplicationTab(profile, extension, override_url,
131 disposition); 142 params.disposition);
132 break; 143 break;
133 } 144 }
134 default: 145 default:
135 NOTREACHED(); 146 NOTREACHED();
136 break; 147 break;
137 } 148 }
138 return tab; 149 return tab;
139 } 150 }
140 151
141 WebContents* OpenApplicationPanel( 152 WebContents* OpenApplicationPanel(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && 355 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN &&
345 !browser->window()->IsFullscreen()) { 356 !browser->window()->IsFullscreen()) {
346 browser->ToggleFullscreenMode(); 357 browser->ToggleFullscreenMode();
347 } 358 }
348 #endif 359 #endif
349 360
350 return contents; 361 return contents;
351 } 362 }
352 363
353 } // namespace application_launch 364 } // namespace application_launch
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698