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 | |
58 const char kAlphaEnabledMissingPermission[] = | |
59 "The alphaEnabled option requires app.window.alpha permission."; | |
60 #if !defined(USE_AURA) | |
jackhou1
2014/07/22 05:35:35
It might be better to just allow apps to set this
garykac
2014/07/25 22:50:31
Done. Actually, that matches the current doc for
jackhou1
2014/07/29 23:39:10
Oops, I should have been clearer. We should probab
garykac
2014/08/04 23:11:53
Done.
| |
61 const char kAlphaEnabledNotSupported[] = | |
62 "Alpha-blended windows are not supported on this platform."; | |
63 #endif | |
64 const char kAlphaEnabledWrongChannel[] = | |
65 "The alphaEnabled option requires beta channel or newer."; | |
57 } // namespace app_window_constants | 66 } // namespace app_window_constants |
58 | 67 |
59 const char kNoneFrameOption[] = "none"; | 68 const char kNoneFrameOption[] = "none"; |
60 // TODO(benwells): Remove HTML titlebar injection. | 69 // TODO(benwells): Remove HTML titlebar injection. |
61 const char kHtmlFrameOption[] = "experimental-html"; | 70 const char kHtmlFrameOption[] = "experimental-html"; |
62 | 71 |
63 namespace { | 72 namespace { |
64 | 73 |
65 // Opens an inspector window and delays the response to the | 74 // Opens an inspector window and delays the response to the |
66 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is | 75 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || | 234 if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || |
226 GetExtension()->location() == extensions::Manifest::COMPONENT) { | 235 GetExtension()->location() == extensions::Manifest::COMPONENT) { |
227 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { | 236 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { |
228 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 237 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
229 } | 238 } |
230 } | 239 } |
231 | 240 |
232 if (!GetFrameOptions(*options, &create_params)) | 241 if (!GetFrameOptions(*options, &create_params)) |
233 return false; | 242 return false; |
234 | 243 |
235 if (options->transparent_background.get() && | 244 if (options->alpha_enabled.get()) { |
236 (GetExtension()->permissions_data()->HasAPIPermission( | 245 if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_BETA) { |
237 APIPermission::kExperimental) || | 246 error_ = app_window_constants::kAlphaEnabledWrongChannel; |
238 CommandLine::ForCurrentProcess()->HasSwitch( | 247 return false; |
239 switches::kEnableExperimentalExtensionApis))) { | 248 } |
240 create_params.transparent_background = *options->transparent_background; | 249 if (!GetExtension()->permissions_data()->HasAPIPermission( |
250 APIPermission::kAlphaEnabled)) { | |
251 error_ = app_window_constants::kAlphaEnabledMissingPermission; | |
252 return false; | |
253 } | |
254 #if !defined(USE_AURA) | |
255 error_ = app_window_constants::kAlphaEnabledNotSupported; | |
256 return false; | |
257 #else | |
258 create_params.alpha_enabled = *options->alpha_enabled; | |
259 #endif | |
241 } | 260 } |
242 | 261 |
243 if (options->hidden.get()) | 262 if (options->hidden.get()) |
244 create_params.hidden = *options->hidden.get(); | 263 create_params.hidden = *options->hidden.get(); |
245 | 264 |
246 if (options->resizable.get()) | 265 if (options->resizable.get()) |
247 create_params.resizable = *options->resizable.get(); | 266 create_params.resizable = *options->resizable.get(); |
248 | 267 |
249 if (options->always_on_top.get()) { | 268 if (options->always_on_top.get()) { |
250 create_params.always_on_top = *options->always_on_top.get(); | 269 create_params.always_on_top = *options->always_on_top.get(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 | 509 |
491 if (options.frame->as_frame_options->inactive_color.get()) { | 510 if (options.frame->as_frame_options->inactive_color.get()) { |
492 error_ = app_window_constants::kInactiveColorWithoutColor; | 511 error_ = app_window_constants::kInactiveColorWithoutColor; |
493 return false; | 512 return false; |
494 } | 513 } |
495 | 514 |
496 return true; | 515 return true; |
497 } | 516 } |
498 | 517 |
499 } // namespace extensions | 518 } // namespace extensions |
OLD | NEW |