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/extensions/api/app_window/app_window_api.h" | 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_contents.h" | 8 #include "apps/app_window_contents.h" |
9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
10 #include "apps/apps_client.h" | 10 #include "apps/apps_client.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 using apps::AppWindow; | 34 using apps::AppWindow; |
35 | 35 |
36 namespace app_window = extensions::api::app_window; | 36 namespace app_window = extensions::api::app_window; |
37 namespace Create = app_window::Create; | 37 namespace Create = app_window::Create; |
38 | 38 |
39 namespace extensions { | 39 namespace extensions { |
40 | 40 |
41 namespace app_window_constants { | 41 namespace app_window_constants { |
42 const char kInvalidWindowId[] = | 42 const char kInvalidWindowId[] = |
43 "The window id can not be more than 256 characters long."; | 43 "The window id can not be more than 256 characters long."; |
| 44 const char kMissingPermissionAlphaEnabled[] = |
| 45 "The alphaEnabled option requires app.window.alpha permission."; |
44 const char kInvalidColorSpecification[] = | 46 const char kInvalidColorSpecification[] = |
45 "The color specification could not be parsed."; | 47 "The color specification could not be parsed."; |
46 const char kInvalidChannelForFrameOptions[] = | 48 const char kInvalidChannelForFrameOptions[] = |
47 "Frame options are only available in dev channel."; | 49 "Frame options are only available in dev channel."; |
48 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; | 50 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; |
49 const char kInactiveColorWithoutColor[] = | 51 const char kInactiveColorWithoutColor[] = |
50 "frame.inactiveColor must be used with frame.color."; | 52 "frame.inactiveColor must be used with frame.color."; |
51 const char kConflictingBoundsOptions[] = | 53 const char kConflictingBoundsOptions[] = |
52 "The $1 property cannot be specified for both inner and outer bounds."; | 54 "The $1 property cannot be specified for both inner and outer bounds."; |
53 } // namespace app_window_constants | 55 } // namespace app_window_constants |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || | 218 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || |
217 GetExtension()->location() == extensions::Manifest::COMPONENT) { | 219 GetExtension()->location() == extensions::Manifest::COMPONENT) { |
218 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { | 220 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { |
219 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 221 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
220 } | 222 } |
221 } | 223 } |
222 | 224 |
223 if (!GetFrameOptions(*options, &create_params)) | 225 if (!GetFrameOptions(*options, &create_params)) |
224 return false; | 226 return false; |
225 | 227 |
226 if (options->transparent_background.get() && | 228 #if defined(USE_AURA) |
227 (GetExtension()->HasAPIPermission(APIPermission::kExperimental) || | 229 if (options->alpha_enabled.get()) { |
228 CommandLine::ForCurrentProcess()->HasSwitch( | 230 bool allow_alpha_enabled = false; |
229 switches::kEnableExperimentalExtensionApis))) { | 231 // For now, continue to support this if Experimental is set (any channel). |
230 create_params.transparent_background = *options->transparent_background; | 232 // TODO(garykac) Remove this once the permission moves to stable. |
| 233 if (GetExtension()->HasAPIPermission(APIPermission::kExperimental) || |
| 234 CommandLine::ForCurrentProcess()->HasSwitch( |
| 235 switches::kEnableExperimentalExtensionApis)) { |
| 236 allow_alpha_enabled = true; |
| 237 } |
| 238 // Support alphaEnabled permission on dev channel. |
| 239 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { |
| 240 if (GetExtension()->HasAPIPermission(APIPermission::kAlphaEnabled)) { |
| 241 allow_alpha_enabled = true; |
| 242 } else { |
| 243 error_ = app_window_constants::kMissingPermissionAlphaEnabled; |
| 244 return false; |
| 245 } |
| 246 } |
| 247 if (allow_alpha_enabled) { |
| 248 create_params.alpha_enabled = *options->alpha_enabled; |
| 249 } |
231 } | 250 } |
| 251 #endif |
232 | 252 |
233 if (options->hidden.get()) | 253 if (options->hidden.get()) |
234 create_params.hidden = *options->hidden.get(); | 254 create_params.hidden = *options->hidden.get(); |
235 | 255 |
236 if (options->resizable.get()) | 256 if (options->resizable.get()) |
237 create_params.resizable = *options->resizable.get(); | 257 create_params.resizable = *options->resizable.get(); |
238 | 258 |
239 if (options->always_on_top.get() && | 259 if (options->always_on_top.get() && |
240 GetExtension()->HasAPIPermission(APIPermission::kAlwaysOnTopWindows)) | 260 GetExtension()->HasAPIPermission(APIPermission::kAlwaysOnTopWindows)) |
241 create_params.always_on_top = *options->always_on_top.get(); | 261 create_params.always_on_top = *options->always_on_top.get(); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // TODO(benwells): Remove this code once we get agreement to use the new | 512 // TODO(benwells): Remove this code once we get agreement to use the new |
493 // native style frame. | 513 // native style frame. |
494 create_params->has_frame_color = true; | 514 create_params->has_frame_color = true; |
495 create_params->active_frame_color = SK_ColorWHITE; | 515 create_params->active_frame_color = SK_ColorWHITE; |
496 create_params->inactive_frame_color = SK_ColorWHITE; | 516 create_params->inactive_frame_color = SK_ColorWHITE; |
497 } | 517 } |
498 #endif | 518 #endif |
499 } | 519 } |
500 | 520 |
501 } // namespace extensions | 521 } // namespace extensions |
OLD | NEW |