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 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
30 #include "content/public/browser/web_contents_view.h" | 30 #include "content/public/browser/web_contents_view.h" |
31 #include "content/public/common/renderer_preferences.h" | 31 #include "content/public/common/renderer_preferences.h" |
32 #include "ui/gfx/rect.h" | 32 #include "ui/gfx/rect.h" |
33 | 33 |
| 34 #if defined(OS_WIN) |
| 35 #include "base/win/metro.h" |
| 36 #endif |
| 37 |
34 using content::WebContents; | 38 using content::WebContents; |
35 using extensions::Extension; | 39 using extensions::Extension; |
36 using extensions::ExtensionPrefs; | 40 using extensions::ExtensionPrefs; |
37 | 41 |
38 namespace { | 42 namespace { |
39 | 43 |
40 // Get the launch URL for a given extension, with optional override/fallback. | 44 // Get the launch URL for a given extension, with optional override/fallback. |
41 // |override_url|, if non-empty, will be preferred over the extension's | 45 // |override_url|, if non-empty, will be preferred over the extension's |
42 // launch url. | 46 // launch url. |
43 GURL UrlForExtension(const Extension* extension, | 47 GURL UrlForExtension(const Extension* extension, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 ExtensionPrefs::LaunchType launch_type = | 105 ExtensionPrefs::LaunchType launch_type = |
102 profile->GetExtensionService()->extension_prefs()->GetLaunchType( | 106 profile->GetExtensionService()->extension_prefs()->GetLaunchType( |
103 extension->id(), ExtensionPrefs::LAUNCH_DEFAULT); | 107 extension->id(), ExtensionPrefs::LAUNCH_DEFAULT); |
104 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN) | 108 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN) |
105 params.initial_show_state = ui::SHOW_STATE_MAXIMIZED; | 109 params.initial_show_state = ui::SHOW_STATE_MAXIMIZED; |
106 else if (launch_type == ExtensionPrefs::LAUNCH_WINDOW) | 110 else if (launch_type == ExtensionPrefs::LAUNCH_WINDOW) |
107 params.initial_show_state = ui::SHOW_STATE_NORMAL; | 111 params.initial_show_state = ui::SHOW_STATE_NORMAL; |
108 } | 112 } |
109 #endif | 113 #endif |
110 | 114 |
111 Browser* browser = new Browser(params); | 115 Browser* browser = NULL; |
| 116 #if defined(OS_WIN) |
| 117 // In Chrome on Windows 8 in metro mode we don't allow multiple chrome |
| 118 // windows to be created, as we don't have a good way to switch between |
| 119 // them. We attempt to reuse an existing Browser window. |
| 120 if (base::win::IsMetroProcess()) { |
| 121 browser = browser::FindBrowserWithProfile( |
| 122 profile, chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 123 } |
| 124 #endif |
| 125 if (!browser) |
| 126 browser = new Browser(params); |
112 | 127 |
113 if (app_browser) | 128 if (app_browser) |
114 *app_browser = browser; | 129 *app_browser = browser; |
115 | 130 |
116 TabContents* tab_contents = chrome::AddSelectedTabWithURL( | 131 TabContents* tab_contents = chrome::AddSelectedTabWithURL( |
117 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 132 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
118 WebContents* contents = tab_contents->web_contents(); | 133 WebContents* contents = tab_contents->web_contents(); |
119 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 134 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
120 contents->GetRenderViewHost()->SyncRendererPrefs(); | 135 contents->GetRenderViewHost()->SyncRendererPrefs(); |
121 | 136 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // OnDidGetApplicationInfo, which calls | 309 // OnDidGetApplicationInfo, which calls |
295 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 310 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
296 // pending web app action. | 311 // pending web app action. |
297 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 312 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
298 extensions::TabHelper::UPDATE_SHORTCUT); | 313 extensions::TabHelper::UPDATE_SHORTCUT); |
299 | 314 |
300 return tab; | 315 return tab; |
301 } | 316 } |
302 | 317 |
303 } // namespace application_launch | 318 } // namespace application_launch |
OLD | NEW |