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 "extensions/browser/api/app_window/app_window_api.h" | 5 #include "extensions/browser/api/app_window/app_window_api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const char kAlphaEnabledNeedsFrameNone[] = | 59 const char kAlphaEnabledNeedsFrameNone[] = |
60 "The alphaEnabled option can only be used with \"frame: 'none'\"."; | 60 "The alphaEnabled option can only be used with \"frame: 'none'\"."; |
61 const char kImeWindowMissingPermission[] = | 61 const char kImeWindowMissingPermission[] = |
62 "Extensions require the \"app.window.ime\" permission to create windows."; | 62 "Extensions require the \"app.window.ime\" permission to create windows."; |
63 const char kImeOptionIsNotSupported[] = | 63 const char kImeOptionIsNotSupported[] = |
64 "The \"ime\" option is not supported for platform app."; | 64 "The \"ime\" option is not supported for platform app."; |
65 #if !defined(OS_CHROMEOS) | 65 #if !defined(OS_CHROMEOS) |
66 const char kImeWindowUnsupportedPlatform[] = | 66 const char kImeWindowUnsupportedPlatform[] = |
67 "The \"ime\" option can only be used on ChromeOS."; | 67 "The \"ime\" option can only be used on ChromeOS."; |
68 #else | 68 #else |
69 const char kImeOptionMustBeTrueAndNeedsFrameNone[] = | 69 const char kImeWindowMustBeImeWindowOrPanel[] = |
70 "IME extensions must create window with \"ime: true\" and " | 70 "IME extensions must create ime window ( with \"ime: true\" and " |
71 "\"frame: 'none'\"."; | 71 "\"frame: 'none'\") or panel window (with \"type: panel\")."; |
72 #endif | 72 #endif |
73 } // namespace app_window_constants | 73 } // namespace app_window_constants |
74 | 74 |
75 const char kNoneFrameOption[] = "none"; | 75 const char kNoneFrameOption[] = "none"; |
76 // TODO(benwells): Remove HTML titlebar injection. | 76 // TODO(benwells): Remove HTML titlebar injection. |
77 const char kHtmlFrameOption[] = "experimental-html"; | 77 const char kHtmlFrameOption[] = "experimental-html"; |
78 | 78 |
79 namespace { | 79 namespace { |
80 | 80 |
81 // If the same property is specified for the inner and outer bounds, raise an | 81 // If the same property is specified for the inner and outer bounds, raise an |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 APIPermission::kImeWindowEnabled)) { | 228 APIPermission::kImeWindowEnabled)) { |
229 error_ = app_window_constants::kImeWindowMissingPermission; | 229 error_ = app_window_constants::kImeWindowMissingPermission; |
230 return false; | 230 return false; |
231 } | 231 } |
232 | 232 |
233 #if !defined(OS_CHROMEOS) | 233 #if !defined(OS_CHROMEOS) |
234 // IME window is only supported on ChromeOS. | 234 // IME window is only supported on ChromeOS. |
235 error_ = app_window_constants::kImeWindowUnsupportedPlatform; | 235 error_ = app_window_constants::kImeWindowUnsupportedPlatform; |
236 return false; | 236 return false; |
237 #else | 237 #else |
238 // IME extensions must create window with "ime: true" and "frame: none". | 238 // IME extensions must create ime window (with "ime: true" and |
239 if (!options->ime.get() || !*options->ime.get() || | 239 // "frame: none") or panel window (with "type: panel"). |
240 create_params.frame != AppWindow::FRAME_NONE) { | 240 if (options->ime.get() && *options->ime.get() && |
241 error_ = app_window_constants::kImeOptionMustBeTrueAndNeedsFrameNone; | 241 create_params.frame == AppWindow::FRAME_NONE) { |
| 242 create_params.is_ime_window = true; |
| 243 } else if (options->type == app_window::WINDOW_TYPE_PANEL) { |
| 244 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
| 245 } else { |
| 246 error_ = app_window_constants::kImeWindowMustBeImeWindowOrPanel; |
242 return false; | 247 return false; |
243 } | 248 } |
244 create_params.is_ime_window = true; | |
245 #endif // OS_CHROMEOS | 249 #endif // OS_CHROMEOS |
246 } else { | 250 } else { |
247 if (options->ime.get()) { | 251 if (options->ime.get()) { |
248 error_ = app_window_constants::kImeOptionIsNotSupported; | 252 error_ = app_window_constants::kImeOptionIsNotSupported; |
249 return false; | 253 return false; |
250 } | 254 } |
251 } | 255 } |
252 | 256 |
253 if (options->alpha_enabled.get()) { | 257 if (options->alpha_enabled.get()) { |
254 const char* const kWhitelist[] = { | 258 const char* const kWhitelist[] = { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 563 |
560 if (options.frame->as_frame_options->inactive_color.get()) { | 564 if (options.frame->as_frame_options->inactive_color.get()) { |
561 error_ = app_window_constants::kInactiveColorWithoutColor; | 565 error_ = app_window_constants::kInactiveColorWithoutColor; |
562 return false; | 566 return false; |
563 } | 567 } |
564 | 568 |
565 return true; | 569 return true; |
566 } | 570 } |
567 | 571 |
568 } // namespace extensions | 572 } // namespace extensions |
OLD | NEW |