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 attempt to reuse an existing | |
Mihai Parparita -not on Chrome
2012/10/16 23:57:18
This comment just repeats what the code does. Can
ananta
2012/10/17 00:06:06
Done.
| |
118 // Browser window if one exists. | |
119 if (base::win::IsMetroProcess()) { | |
120 browser = browser::FindBrowserWithProfile( | |
121 profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | |
122 } | |
123 #endif | |
124 if (!browser) | |
125 browser = new Browser(params); | |
112 | 126 |
113 if (app_browser) | 127 if (app_browser) |
114 *app_browser = browser; | 128 *app_browser = browser; |
115 | 129 |
116 TabContents* tab_contents = chrome::AddSelectedTabWithURL( | 130 TabContents* tab_contents = chrome::AddSelectedTabWithURL( |
117 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 131 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
118 WebContents* contents = tab_contents->web_contents(); | 132 WebContents* contents = tab_contents->web_contents(); |
119 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 133 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
120 contents->GetRenderViewHost()->SyncRendererPrefs(); | 134 contents->GetRenderViewHost()->SyncRendererPrefs(); |
121 | 135 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 // OnDidGetApplicationInfo, which calls | 308 // OnDidGetApplicationInfo, which calls |
295 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 309 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
296 // pending web app action. | 310 // pending web app action. |
297 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 311 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
298 extensions::TabHelper::UPDATE_SHORTCUT); | 312 extensions::TabHelper::UPDATE_SHORTCUT); |
299 | 313 |
300 return tab; | 314 return tab; |
301 } | 315 } |
302 | 316 |
303 } // namespace application_launch | 317 } // namespace application_launch |
OLD | NEW |