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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 "The color specification could not be parsed."; | 47 "The color specification could not be parsed."; |
48 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; | 48 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; |
49 const char kInactiveColorWithoutColor[] = | 49 const char kInactiveColorWithoutColor[] = |
50 "frame.inactiveColor must be used with frame.color."; | 50 "frame.inactiveColor must be used with frame.color."; |
51 const char kConflictingBoundsOptions[] = | 51 const char kConflictingBoundsOptions[] = |
52 "The $1 property cannot be specified for both inner and outer bounds."; | 52 "The $1 property cannot be specified for both inner and outer bounds."; |
53 const char kAlwaysOnTopPermission[] = | 53 const char kAlwaysOnTopPermission[] = |
54 "The \"app.window.alwaysOnTop\" permission is required."; | 54 "The \"app.window.alwaysOnTop\" permission is required."; |
55 const char kInvalidUrlParameter[] = | 55 const char kInvalidUrlParameter[] = |
56 "The URL used for window creation must be local for security reasons."; | 56 "The URL used for window creation must be local for security reasons."; |
57 const char kAlphaEnabledWrongChannel[] = | |
58 "The alphaEnabled option requires beta channel or newer."; | |
benwells
2014/08/05 23:37:05
Normally we restrict to dev, not beta. Any reason
garykac
2014/08/07 03:54:00
I was matching the Shape permissions, but that's n
| |
59 const char kAlphaEnabledMissingPermission[] = | |
60 "The alphaEnabled option requires app.window.alpha permission."; | |
57 } // namespace app_window_constants | 61 } // namespace app_window_constants |
58 | 62 |
59 const char kNoneFrameOption[] = "none"; | 63 const char kNoneFrameOption[] = "none"; |
60 // TODO(benwells): Remove HTML titlebar injection. | 64 // TODO(benwells): Remove HTML titlebar injection. |
61 const char kHtmlFrameOption[] = "experimental-html"; | 65 const char kHtmlFrameOption[] = "experimental-html"; |
62 | 66 |
63 namespace { | 67 namespace { |
64 | 68 |
65 // Opens an inspector window and delays the response to the | 69 // Opens an inspector window and delays the response to the |
66 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is | 70 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || | 231 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || |
228 extension()->location() == extensions::Manifest::COMPONENT) { | 232 extension()->location() == extensions::Manifest::COMPONENT) { |
229 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { | 233 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { |
230 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 234 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
231 } | 235 } |
232 } | 236 } |
233 | 237 |
234 if (!GetFrameOptions(*options, &create_params)) | 238 if (!GetFrameOptions(*options, &create_params)) |
235 return false; | 239 return false; |
236 | 240 |
237 if (options->transparent_background.get() && | 241 if (options->alpha_enabled.get()) { |
238 (extension()->permissions_data()->HasAPIPermission( | 242 if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_BETA) { |
239 APIPermission::kExperimental) || | 243 error_ = app_window_constants::kAlphaEnabledWrongChannel; |
240 CommandLine::ForCurrentProcess()->HasSwitch( | 244 return false; |
241 switches::kEnableExperimentalExtensionApis))) { | 245 } |
242 create_params.transparent_background = *options->transparent_background; | 246 if (!extension()->permissions_data()->HasAPIPermission( |
247 APIPermission::kAlphaEnabled)) { | |
248 error_ = app_window_constants::kAlphaEnabledMissingPermission; | |
249 return false; | |
250 } | |
251 #if defined(USE_AURA) | |
252 create_params.alpha_enabled = *options->alpha_enabled; | |
253 #else | |
254 // Transparency is only supported on Aura. | |
255 // Fallback to creating an opaque window (by ignoring alphaEnabled). | |
256 #endif | |
243 } | 257 } |
244 | 258 |
245 if (options->hidden.get()) | 259 if (options->hidden.get()) |
246 create_params.hidden = *options->hidden.get(); | 260 create_params.hidden = *options->hidden.get(); |
247 | 261 |
248 if (options->resizable.get()) | 262 if (options->resizable.get()) |
249 create_params.resizable = *options->resizable.get(); | 263 create_params.resizable = *options->resizable.get(); |
250 | 264 |
251 if (options->always_on_top.get()) { | 265 if (options->always_on_top.get()) { |
252 create_params.always_on_top = *options->always_on_top.get(); | 266 create_params.always_on_top = *options->always_on_top.get(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 | 506 |
493 if (options.frame->as_frame_options->inactive_color.get()) { | 507 if (options.frame->as_frame_options->inactive_color.get()) { |
494 error_ = app_window_constants::kInactiveColorWithoutColor; | 508 error_ = app_window_constants::kInactiveColorWithoutColor; |
495 return false; | 509 return false; |
496 } | 510 } |
497 | 511 |
498 return true; | 512 return true; |
499 } | 513 } |
500 | 514 |
501 } // namespace extensions | 515 } // namespace extensions |
OLD | NEW |