Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 if (extension->is_platform_app()) { | 99 if (extension->is_platform_app()) { |
| 100 extensions::LaunchPlatformApp(profile, extension, command_line); | 100 extensions::LaunchPlatformApp(profile, extension, command_line); |
| 101 return NULL; | 101 return NULL; |
| 102 } | 102 } |
| 103 | 103 |
| 104 switch (container) { | 104 switch (container) { |
| 105 case extension_misc::LAUNCH_NONE: { | 105 case extension_misc::LAUNCH_NONE: { |
| 106 NOTREACHED(); | 106 NOTREACHED(); |
| 107 break; | 107 break; |
| 108 } | 108 } |
| 109 case extension_misc::LAUNCH_PANEL: { | 109 case extension_misc::LAUNCH_PANEL: |
| 110 bool open_panel = false; | |
| 111 #if defined(USE_ASH) | |
| 112 open_panel = CommandLine::ForCurrentProcess()->HasSwitch( | |
| 113 ash::switches::kAuraPanelManager); | |
| 114 #else | |
| 115 open_panel = CommandLine::ForCurrentProcess()->HasSwitch( | |
| 116 switches::kBrowserlessPanels); | |
| 117 #endif | |
| 118 if (open_panel) { | |
| 119 tab = OpenApplicationPanel(profile, extension, override_url); | |
| 120 break; | |
| 121 } | |
| 122 // else fall through to LAUNCH_WINDOW | |
| 123 } | |
| 124 case extension_misc::LAUNCH_WINDOW: | 110 case extension_misc::LAUNCH_WINDOW: |
| 125 tab = OpenApplicationWindow(profile, extension, container, | 111 tab = OpenApplicationWindow(profile, extension, container, |
| 126 override_url, NULL); | 112 override_url, NULL); |
| 127 break; | 113 break; |
| 128 case extension_misc::LAUNCH_TAB: { | 114 case extension_misc::LAUNCH_TAB: { |
| 129 tab = OpenApplicationTab(profile, extension, override_url, | 115 tab = OpenApplicationTab(profile, extension, override_url, |
| 130 disposition); | 116 disposition); |
| 131 break; | 117 break; |
| 132 } | 118 } |
| 133 default: | 119 default: |
| 134 NOTREACHED(); | 120 NOTREACHED(); |
| 135 break; | 121 break; |
| 136 } | 122 } |
| 137 return tab; | 123 return tab; |
| 138 } | 124 } |
| 139 | 125 |
| 140 WebContents* OpenApplicationPanel( | |
|
jennb
2012/07/03 16:58:02
Delete in .h as well.
| |
| 141 Profile* profile, | |
| 142 const Extension* extension, | |
| 143 const GURL& url_input) { | |
| 144 GURL url = UrlForExtension(extension, url_input); | |
| 145 std::string app_name = | |
| 146 web_app::GenerateApplicationNameFromExtensionId(extension->id()); | |
| 147 gfx::Rect panel_bounds; | |
| 148 panel_bounds.set_width(extension->launch_width()); | |
| 149 panel_bounds.set_height(extension->launch_height()); | |
| 150 #if defined(USE_ASH) | |
| 151 PanelViewAura* panel_view = new PanelViewAura(app_name); | |
| 152 panel_view->Init(profile, url, panel_bounds); | |
| 153 return panel_view->WebContents(); | |
| 154 #else | |
| 155 Panel* panel = PanelManager::GetInstance()->CreatePanel( | |
| 156 app_name, profile, url, panel_bounds.size()); | |
| 157 panel->Show(); | |
| 158 return panel->WebContents(); | |
| 159 #endif | |
| 160 } | |
| 161 | |
| 162 WebContents* OpenApplicationWindow( | 126 WebContents* OpenApplicationWindow( |
| 163 Profile* profile, | 127 Profile* profile, |
| 164 const Extension* extension, | 128 const Extension* extension, |
| 165 extension_misc::LaunchContainer container, | 129 extension_misc::LaunchContainer container, |
| 166 const GURL& url_input, | 130 const GURL& url_input, |
| 167 Browser** app_browser) { | 131 Browser** app_browser) { |
| 168 DCHECK(!url_input.is_empty() || extension); | 132 DCHECK(!url_input.is_empty() || extension); |
| 169 GURL url = UrlForExtension(extension, url_input); | 133 GURL url = UrlForExtension(extension, url_input); |
| 170 | 134 |
| 171 std::string app_name; | 135 std::string app_name; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && | 305 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && |
| 342 !browser->window()->IsFullscreen()) { | 306 !browser->window()->IsFullscreen()) { |
| 343 browser->ToggleFullscreenMode(); | 307 browser->ToggleFullscreenMode(); |
| 344 } | 308 } |
| 345 #endif | 309 #endif |
| 346 | 310 |
| 347 return contents; | 311 return contents; |
| 348 } | 312 } |
| 349 | 313 |
| 350 } // namespace application_launch | 314 } // namespace application_launch |
| OLD | NEW |