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 30 matching lines...) Expand all Loading... |
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 kInvalidColorSpecification[] = | 44 const char kInvalidColorSpecification[] = |
45 "The color specification could not be parsed."; | 45 "The color specification could not be parsed."; |
46 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; | 46 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; |
47 const char kInactiveColorWithoutColor[] = | 47 const char kInactiveColorWithoutColor[] = |
48 "frame.inactiveColor must be used with frame.color."; | 48 "frame.inactiveColor must be used with frame.color."; |
49 const char kConflictingBoundsOptions[] = | 49 const char kConflictingBoundsOptions[] = |
50 "The $1 property cannot be specified for both inner and outer bounds."; | 50 "The $1 property cannot be specified for both inner and outer bounds."; |
| 51 const char kAlwaysOnTopPermission[] = |
| 52 "The \"app.window.alwaysOnTop\" permission is required."; |
51 } // namespace app_window_constants | 53 } // namespace app_window_constants |
52 | 54 |
53 const char kNoneFrameOption[] = "none"; | 55 const char kNoneFrameOption[] = "none"; |
54 // TODO(benwells): Remove HTML titlebar injection. | 56 // TODO(benwells): Remove HTML titlebar injection. |
55 const char kHtmlFrameOption[] = "experimental-html"; | 57 const char kHtmlFrameOption[] = "experimental-html"; |
56 | 58 |
57 namespace { | 59 namespace { |
58 | 60 |
59 // Opens an inspector window and delays the response to the | 61 // Opens an inspector window and delays the response to the |
60 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is | 62 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 switches::kEnableExperimentalExtensionApis))) { | 229 switches::kEnableExperimentalExtensionApis))) { |
228 create_params.transparent_background = *options->transparent_background; | 230 create_params.transparent_background = *options->transparent_background; |
229 } | 231 } |
230 | 232 |
231 if (options->hidden.get()) | 233 if (options->hidden.get()) |
232 create_params.hidden = *options->hidden.get(); | 234 create_params.hidden = *options->hidden.get(); |
233 | 235 |
234 if (options->resizable.get()) | 236 if (options->resizable.get()) |
235 create_params.resizable = *options->resizable.get(); | 237 create_params.resizable = *options->resizable.get(); |
236 | 238 |
237 if (options->always_on_top.get() && | 239 if (options->always_on_top.get()) { |
238 GetExtension()->HasAPIPermission(APIPermission::kAlwaysOnTopWindows)) | |
239 create_params.always_on_top = *options->always_on_top.get(); | 240 create_params.always_on_top = *options->always_on_top.get(); |
240 | 241 |
| 242 if (create_params.always_on_top && !GetExtension()->HasAPIPermission( |
| 243 APIPermission::kAlwaysOnTopWindows)) { |
| 244 error_ = app_window_constants::kAlwaysOnTopPermission; |
| 245 return false; |
| 246 } |
| 247 } |
| 248 |
241 if (options->focused.get()) | 249 if (options->focused.get()) |
242 create_params.focused = *options->focused.get(); | 250 create_params.focused = *options->focused.get(); |
243 | 251 |
244 if (options->type != extensions::api::app_window::WINDOW_TYPE_PANEL) { | 252 if (options->type != extensions::api::app_window::WINDOW_TYPE_PANEL) { |
245 switch (options->state) { | 253 switch (options->state) { |
246 case extensions::api::app_window::STATE_NONE: | 254 case extensions::api::app_window::STATE_NONE: |
247 case extensions::api::app_window::STATE_NORMAL: | 255 case extensions::api::app_window::STATE_NORMAL: |
248 break; | 256 break; |
249 case extensions::api::app_window::STATE_FULLSCREEN: | 257 case extensions::api::app_window::STATE_FULLSCREEN: |
250 create_params.state = ui::SHOW_STATE_FULLSCREEN; | 258 create_params.state = ui::SHOW_STATE_FULLSCREEN; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 476 |
469 if (options.frame->as_frame_options->inactive_color.get()) { | 477 if (options.frame->as_frame_options->inactive_color.get()) { |
470 error_ = app_window_constants::kInactiveColorWithoutColor; | 478 error_ = app_window_constants::kInactiveColorWithoutColor; |
471 return false; | 479 return false; |
472 } | 480 } |
473 | 481 |
474 return true; | 482 return true; |
475 } | 483 } |
476 | 484 |
477 } // namespace extensions | 485 } // namespace extensions |
OLD | NEW |