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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "extensions/common/extension.h" | 46 #include "extensions/common/extension.h" |
47 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
48 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
49 #include "ui/base/window_open_disposition.h" | 49 #include "ui/base/window_open_disposition.h" |
50 #include "ui/gfx/rect.h" | 50 #include "ui/gfx/rect.h" |
51 | 51 |
52 #if defined(OS_MACOSX) | 52 #if defined(OS_MACOSX) |
53 #include "chrome/browser/ui/browser_commands_mac.h" | 53 #include "chrome/browser/ui/browser_commands_mac.h" |
54 #endif | 54 #endif |
55 | 55 |
56 #if defined(OS_WIN) | |
57 #include "win8/util/win8_util.h" | |
58 #endif | |
59 | |
60 using content::WebContents; | 56 using content::WebContents; |
61 using extensions::Extension; | 57 using extensions::Extension; |
62 using extensions::ExtensionPrefs; | 58 using extensions::ExtensionPrefs; |
63 using extensions::ExtensionRegistry; | 59 using extensions::ExtensionRegistry; |
64 | 60 |
65 namespace { | 61 namespace { |
66 | 62 |
67 // Attempts to launch a packaged app, prompting the user to enable it if | 63 // Attempts to launch a packaged app, prompting the user to enable it if |
68 // necessary. If a prompt is required it will be shown inside the AppList. | 64 // necessary. If a prompt is required it will be shown inside the AppList. |
69 // This class manages its own lifetime. | 65 // This class manages its own lifetime. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 Browser::CreateParams::CreateForApp(app_name, | 204 Browser::CreateParams::CreateForApp(app_name, |
209 true /* trusted_source */, | 205 true /* trusted_source */, |
210 initial_bounds, | 206 initial_bounds, |
211 profile, | 207 profile, |
212 params.desktop_type)); | 208 params.desktop_type)); |
213 | 209 |
214 browser_params.initial_show_state = DetermineWindowShowState(profile, | 210 browser_params.initial_show_state = DetermineWindowShowState(profile, |
215 params.container, | 211 params.container, |
216 extension); | 212 extension); |
217 | 213 |
218 Browser* browser = NULL; | 214 Browser* browser = new Browser(browser_params); |
219 #if defined(OS_WIN) | |
220 // On Windows 8's single window Metro mode we don't allow multiple Chrome | |
221 // windows to be created. We instead attempt to reuse an existing Browser | |
222 // window. | |
223 if (win8::IsSingleWindowMetroMode()) | |
224 browser = chrome::FindBrowserWithProfile(profile, params.desktop_type); | |
225 | |
226 #endif | |
227 if (!browser) | |
228 browser = new Browser(browser_params); | |
229 | 215 |
230 WebContents* web_contents = chrome::AddSelectedTabWithURL( | 216 WebContents* web_contents = chrome::AddSelectedTabWithURL( |
231 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 217 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
232 web_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 218 web_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
233 web_contents->GetRenderViewHost()->SyncRendererPrefs(); | 219 web_contents->GetRenderViewHost()->SyncRendererPrefs(); |
234 | 220 |
235 browser->window()->Show(); | 221 browser->window()->Show(); |
236 | 222 |
237 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | 223 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial |
238 // focus explicitly. | 224 // focus explicitly. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when | 488 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when |
503 // the web app info is available, extensions::TabHelper notifies Browser via | 489 // the web app info is available, extensions::TabHelper notifies Browser via |
504 // OnDidGetApplicationInfo, which calls | 490 // OnDidGetApplicationInfo, which calls |
505 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 491 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
506 // pending web app action. | 492 // pending web app action. |
507 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 493 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
508 extensions::TabHelper::UPDATE_SHORTCUT); | 494 extensions::TabHelper::UPDATE_SHORTCUT); |
509 | 495 |
510 return tab; | 496 return tab; |
511 } | 497 } |
OLD | NEW |