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/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (extension) { | 87 if (extension) { |
88 window_bounds.set_width(extension->launch_width()); | 88 window_bounds.set_width(extension->launch_width()); |
89 window_bounds.set_height(extension->launch_height()); | 89 window_bounds.set_height(extension->launch_height()); |
90 } else if (!override_bounds.IsEmpty()) { | 90 } else if (!override_bounds.IsEmpty()) { |
91 window_bounds = override_bounds; | 91 window_bounds = override_bounds; |
92 } | 92 } |
93 | 93 |
94 Browser::CreateParams params(type, profile); | 94 Browser::CreateParams params(type, profile); |
95 params.app_name = app_name; | 95 params.app_name = app_name; |
96 params.initial_bounds = window_bounds; | 96 params.initial_bounds = window_bounds; |
| 97 params.host_desktop_type = chrome::GetActiveDesktop(); |
97 | 98 |
98 #if defined(USE_ASH) | 99 #if defined(USE_ASH) |
99 if (extension && | 100 if (extension && |
100 container == extension_misc::LAUNCH_WINDOW) { | 101 container == extension_misc::LAUNCH_WINDOW) { |
101 // In ash, LAUNCH_FULLSCREEN launches in a maximized app window and | 102 // In ash, LAUNCH_FULLSCREEN launches in a maximized app window and |
102 // LAUNCH_WINDOW launches in a normal app window. | 103 // LAUNCH_WINDOW launches in a normal app window. |
103 ExtensionPrefs::LaunchType launch_type = | 104 ExtensionPrefs::LaunchType launch_type = |
104 profile->GetExtensionService()->extension_prefs()->GetLaunchType( | 105 profile->GetExtensionService()->extension_prefs()->GetLaunchType( |
105 extension, ExtensionPrefs::LAUNCH_DEFAULT); | 106 extension, ExtensionPrefs::LAUNCH_DEFAULT); |
106 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN) | 107 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN) |
(...skipping 29 matching lines...) Expand all Loading... |
136 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | 137 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial |
137 // focus explicitly. | 138 // focus explicitly. |
138 web_contents->GetView()->SetInitialFocus(); | 139 web_contents->GetView()->SetInitialFocus(); |
139 return web_contents; | 140 return web_contents; |
140 } | 141 } |
141 | 142 |
142 WebContents* OpenApplicationTab(Profile* profile, | 143 WebContents* OpenApplicationTab(Profile* profile, |
143 const Extension* extension, | 144 const Extension* extension, |
144 const GURL& override_url, | 145 const GURL& override_url, |
145 WindowOpenDisposition disposition) { | 146 WindowOpenDisposition disposition) { |
146 Browser* browser = browser::FindTabbedBrowserDeprecated(profile, false); | 147 Browser* browser = browser::FindTabbedBrowser(profile, |
| 148 false, |
| 149 chrome::GetActiveDesktop()); |
147 WebContents* contents = NULL; | 150 WebContents* contents = NULL; |
148 if (!browser) { | 151 if (!browser) { |
149 // No browser for this profile, need to open a new one. | 152 // No browser for this profile, need to open a new one. |
150 browser = new Browser(Browser::CreateParams(profile)); | 153 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, |
| 154 profile, |
| 155 chrome::GetActiveDesktop())); |
151 browser->window()->Show(); | 156 browser->window()->Show(); |
152 // There's no current tab in this browser window, so add a new one. | 157 // There's no current tab in this browser window, so add a new one. |
153 disposition = NEW_FOREGROUND_TAB; | 158 disposition = NEW_FOREGROUND_TAB; |
154 } else { | 159 } else { |
155 // For existing browser, ensure its window is activated. | 160 // For existing browser, ensure its window is activated. |
156 browser->window()->Activate(); | 161 browser->window()->Activate(); |
157 } | 162 } |
158 | 163 |
159 // Check the prefs for overridden mode. | 164 // Check the prefs for overridden mode. |
160 ExtensionService* extension_service = profile->GetExtensionService(); | 165 ExtensionService* extension_service = profile->GetExtensionService(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // OnDidGetApplicationInfo, which calls | 302 // OnDidGetApplicationInfo, which calls |
298 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 303 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
299 // pending web app action. | 304 // pending web app action. |
300 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 305 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
301 extensions::TabHelper::UPDATE_SHORTCUT); | 306 extensions::TabHelper::UPDATE_SHORTCUT); |
302 | 307 |
303 return tab; | 308 return tab; |
304 } | 309 } |
305 | 310 |
306 } // namespace application_launch | 311 } // namespace application_launch |
OLD | NEW |