OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/launch_util.h" | 5 #include "chrome/browser/extensions/launch_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
14 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 14 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
15 #include "components/user_prefs/pref_registry_syncable.h" | 15 #include "components/user_prefs/pref_registry_syncable.h" |
16 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
17 #include "extensions/browser/pref_names.h" | 17 #include "extensions/browser/pref_names.h" |
18 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
19 | 19 |
20 #if defined(OS_WIN) | |
21 #include "win8/util/win8_util.h" | |
22 #endif | |
23 | |
24 #if defined(USE_ASH) | 20 #if defined(USE_ASH) |
25 #include "ash/shell.h" | 21 #include "ash/shell.h" |
26 #endif | 22 #endif |
27 | 23 |
28 namespace extensions { | 24 namespace extensions { |
29 namespace { | 25 namespace { |
30 | 26 |
31 // A preference set by the the NTP to persist the desired launch container type | 27 // A preference set by the the NTP to persist the desired launch container type |
32 // used for apps. | 28 // used for apps. |
33 const char kPrefLaunchType[] = "launchType"; | 29 const char kPrefLaunchType[] = "launchType"; |
(...skipping 28 matching lines...) Expand all Loading... |
62 result = static_cast<LaunchType>(value); | 58 result = static_cast<LaunchType>(value); |
63 | 59 |
64 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
65 // App windows are not yet supported on mac. Pref sync could make | 61 // App windows are not yet supported on mac. Pref sync could make |
66 // the launch type LAUNCH_TYPE_WINDOW, even if there is no UI to set it | 62 // the launch type LAUNCH_TYPE_WINDOW, even if there is no UI to set it |
67 // on mac. | 63 // on mac. |
68 if (!extension->is_platform_app() && result == LAUNCH_TYPE_WINDOW) | 64 if (!extension->is_platform_app() && result == LAUNCH_TYPE_WINDOW) |
69 result = LAUNCH_TYPE_REGULAR; | 65 result = LAUNCH_TYPE_REGULAR; |
70 #endif | 66 #endif |
71 | 67 |
72 #if defined(OS_WIN) | |
73 // We don't support app windows in Windows 8 single window Metro mode. | |
74 if (win8::IsSingleWindowMetroMode() && result == LAUNCH_TYPE_WINDOW) | |
75 result = LAUNCH_TYPE_REGULAR; | |
76 #endif // OS_WIN | |
77 | |
78 return result; | 68 return result; |
79 } | 69 } |
80 | 70 |
81 LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs, | 71 LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs, |
82 const std::string& extension_id) { | 72 const std::string& extension_id) { |
83 int value = LAUNCH_TYPE_INVALID; | 73 int value = LAUNCH_TYPE_INVALID; |
84 return prefs->ReadPrefAsInteger(extension_id, kPrefLaunchType, &value) | 74 return prefs->ReadPrefAsInteger(extension_id, kPrefLaunchType, &value) |
85 ? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID; | 75 ? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID; |
86 } | 76 } |
87 | 77 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, | 149 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, |
160 const Extension* extension) { | 150 const Extension* extension) { |
161 int value = -1; | 151 int value = -1; |
162 LaunchContainer manifest_launch_container = | 152 LaunchContainer manifest_launch_container = |
163 AppLaunchInfo::GetLaunchContainer(extension); | 153 AppLaunchInfo::GetLaunchContainer(extension); |
164 return manifest_launch_container == LAUNCH_CONTAINER_TAB && | 154 return manifest_launch_container == LAUNCH_CONTAINER_TAB && |
165 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); | 155 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); |
166 } | 156 } |
167 | 157 |
168 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |