OLD | NEW |
1 // Copyright 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_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "chrome/browser/ui/host_desktop.h" | 10 #include "chrome/browser/ui/host_desktop.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 LaunchContainer GetLaunchContainer(const ExtensionPrefs* prefs, | 74 LaunchContainer GetLaunchContainer(const ExtensionPrefs* prefs, |
75 const Extension* extension) { | 75 const Extension* extension) { |
76 LaunchContainer manifest_launch_container = | 76 LaunchContainer manifest_launch_container = |
77 AppLaunchInfo::GetLaunchContainer(extension); | 77 AppLaunchInfo::GetLaunchContainer(extension); |
78 | 78 |
79 const LaunchContainer kInvalidLaunchContainer = | 79 const LaunchContainer kInvalidLaunchContainer = |
80 static_cast<LaunchContainer>(-1); | 80 static_cast<LaunchContainer>(-1); |
81 | 81 |
82 LaunchContainer result = kInvalidLaunchContainer; | 82 LaunchContainer result = kInvalidLaunchContainer; |
83 | 83 |
84 if (manifest_launch_container == LAUNCH_PANEL) { | 84 if (manifest_launch_container == LAUNCH_CONTAINER_PANEL) { |
85 // Apps with app.launch.container = 'panel' should always respect the | 85 // Apps with app.launch.container = 'panel' should always respect the |
86 // manifest setting. | 86 // manifest setting. |
87 result = manifest_launch_container; | 87 result = manifest_launch_container; |
88 } else if (manifest_launch_container == LAUNCH_TAB) { | 88 } else if (manifest_launch_container == LAUNCH_CONTAINER_TAB) { |
89 // Look for prefs that indicate the user's choice of launch container. The | 89 // Look for prefs that indicate the user's choice of launch container. The |
90 // app's menu on the NTP provides a UI to set this preference. | 90 // app's menu on the NTP provides a UI to set this preference. |
91 LaunchType prefs_launch_type = GetLaunchType(prefs, extension); | 91 LaunchType prefs_launch_type = GetLaunchType(prefs, extension); |
92 | 92 |
93 if (prefs_launch_type == LAUNCH_TYPE_WINDOW) { | 93 if (prefs_launch_type == LAUNCH_TYPE_WINDOW) { |
94 // If the pref is set to launch a window (or no pref is set, and | 94 // If the pref is set to launch a window (or no pref is set, and |
95 // window opening is the default), make the container a window. | 95 // window opening is the default), make the container a window. |
96 result = LAUNCH_WINDOW; | 96 result = LAUNCH_CONTAINER_WINDOW; |
97 #if defined(USE_ASH) | 97 #if defined(USE_ASH) |
98 } else if (prefs_launch_type == LAUNCH_TYPE_FULLSCREEN && | 98 } else if (prefs_launch_type == LAUNCH_TYPE_FULLSCREEN && |
99 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) { | 99 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) { |
100 // LAUNCH_TYPE_FULLSCREEN launches in a maximized app window in ash. | 100 // LAUNCH_TYPE_FULLSCREEN launches in a maximized app window in ash. |
101 // For desktop chrome AURA on all platforms we should open the | 101 // For desktop chrome AURA on all platforms we should open the |
102 // application in full screen mode in the current tab, on the same | 102 // application in full screen mode in the current tab, on the same |
103 // lines as non AURA chrome. | 103 // lines as non AURA chrome. |
104 result = LAUNCH_WINDOW; | 104 result = LAUNCH_CONTAINER_WINDOW; |
105 #endif | 105 #endif |
106 } else { | 106 } else { |
107 // All other launch types (tab, pinned, fullscreen) are | 107 // All other launch types (tab, pinned, fullscreen) are |
108 // implemented as tabs in a window. | 108 // implemented as tabs in a window. |
109 result = LAUNCH_TAB; | 109 result = LAUNCH_CONTAINER_TAB; |
110 } | 110 } |
111 } else { | 111 } else { |
112 // If a new value for app.launch.container is added, logic for it should be | 112 // If a new value for app.launch.container is added, logic for it should be |
113 // added here. LAUNCH_WINDOW is not present because there is no way to set | 113 // added here. LAUNCH_CONTAINER_WINDOW is not present because there is no |
114 // it in a manifest. | 114 // way to set it in a manifest. |
115 NOTREACHED() << manifest_launch_container; | 115 NOTREACHED() << manifest_launch_container; |
116 } | 116 } |
117 | 117 |
118 // All paths should set |result|. | 118 // All paths should set |result|. |
119 if (result == kInvalidLaunchContainer) { | 119 if (result == kInvalidLaunchContainer) { |
120 DLOG(FATAL) << "Failed to set a launch container."; | 120 DLOG(FATAL) << "Failed to set a launch container."; |
121 result = LAUNCH_TAB; | 121 result = LAUNCH_CONTAINER_TAB; |
122 } | 122 } |
123 | 123 |
124 return result; | 124 return result; |
125 } | 125 } |
126 | 126 |
127 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, | 127 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, |
128 const Extension* extension) { | 128 const Extension* extension) { |
129 int value = -1; | 129 int value = -1; |
130 LaunchContainer manifest_launch_container = | 130 LaunchContainer manifest_launch_container = |
131 AppLaunchInfo::GetLaunchContainer(extension); | 131 AppLaunchInfo::GetLaunchContainer(extension); |
132 return manifest_launch_container == LAUNCH_TAB && | 132 return manifest_launch_container == LAUNCH_CONTAINER_TAB && |
133 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); | 133 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); |
134 } | 134 } |
135 | 135 |
136 } // namespace extensions | 136 } // namespace extensions |
OLD | NEW |