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 <string> | 7 #include <string> |
8 | 8 |
9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 return ui::SHOW_STATE_DEFAULT; | 183 return ui::SHOW_STATE_DEFAULT; |
184 } | 184 } |
185 | 185 |
186 WebContents* OpenApplicationWindow(const AppLaunchParams& params) { | 186 WebContents* OpenApplicationWindow(const AppLaunchParams& params) { |
187 Profile* const profile = params.profile; | 187 Profile* const profile = params.profile; |
188 const Extension* const extension = GetExtension(params); | 188 const Extension* const extension = GetExtension(params); |
189 const GURL url_input = params.override_url; | 189 const GURL url_input = params.override_url; |
190 | 190 |
191 DCHECK(!url_input.is_empty() || extension); | 191 DCHECK(!url_input.is_empty() || extension); |
192 GURL url = UrlForExtension(extension, url_input); | 192 GURL url = UrlForExtension(extension, url_input); |
193 Browser::CreateParams browser_params( | 193 std::string app_name = extension ? |
194 Browser::TYPE_POPUP, profile, params.desktop_type); | |
195 | |
196 browser_params.app_name = extension ? | |
197 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : | 194 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : |
198 web_app::GenerateApplicationNameFromURL(url); | 195 web_app::GenerateApplicationNameFromURL(url); |
199 | 196 |
| 197 gfx::Rect initial_bounds; |
200 if (!params.override_bounds.IsEmpty()) { | 198 if (!params.override_bounds.IsEmpty()) { |
201 browser_params.initial_bounds = params.override_bounds; | 199 initial_bounds = params.override_bounds; |
202 } else if (extension) { | 200 } else if (extension) { |
203 browser_params.initial_bounds.set_width( | 201 initial_bounds.set_width( |
204 extensions::AppLaunchInfo::GetLaunchWidth(extension)); | 202 extensions::AppLaunchInfo::GetLaunchWidth(extension)); |
205 browser_params.initial_bounds.set_height( | 203 initial_bounds.set_height( |
206 extensions::AppLaunchInfo::GetLaunchHeight(extension)); | 204 extensions::AppLaunchInfo::GetLaunchHeight(extension)); |
207 } | 205 } |
208 | 206 |
| 207 Browser::CreateParams browser_params( |
| 208 Browser::CreateParams::CreateForApp( |
| 209 Browser::TYPE_TRUSTED_POPUP, app_name, initial_bounds, |
| 210 profile, params.desktop_type)); |
| 211 |
209 browser_params.initial_show_state = DetermineWindowShowState(profile, | 212 browser_params.initial_show_state = DetermineWindowShowState(profile, |
210 params.container, | 213 params.container, |
211 extension); | 214 extension); |
212 | 215 |
213 Browser* browser = NULL; | 216 Browser* browser = NULL; |
214 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
215 // On Windows 8's single window Metro mode we don't allow multiple Chrome | 218 // On Windows 8's single window Metro mode we don't allow multiple Chrome |
216 // windows to be created. We instead attempt to reuse an existing Browser | 219 // windows to be created. We instead attempt to reuse an existing Browser |
217 // window. | 220 // window. |
218 if (win8::IsSingleWindowMetroMode()) | 221 if (win8::IsSingleWindowMetroMode()) |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when | 500 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when |
498 // the web app info is available, extensions::TabHelper notifies Browser via | 501 // the web app info is available, extensions::TabHelper notifies Browser via |
499 // OnDidGetApplicationInfo, which calls | 502 // OnDidGetApplicationInfo, which calls |
500 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 503 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
501 // pending web app action. | 504 // pending web app action. |
502 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 505 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
503 extensions::TabHelper::UPDATE_SHORTCUT); | 506 extensions::TabHelper::UPDATE_SHORTCUT); |
504 | 507 |
505 return tab; | 508 return tab; |
506 } | 509 } |
OLD | NEW |