Chromium Code Reviews| 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 "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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 "The color specification could not be parsed."; | 43 "The color specification could not be parsed."; |
| 44 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; | 44 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; |
| 45 const char kInactiveColorWithoutColor[] = | 45 const char kInactiveColorWithoutColor[] = |
| 46 "frame.inactiveColor must be used with frame.color."; | 46 "frame.inactiveColor must be used with frame.color."; |
| 47 const char kConflictingBoundsOptions[] = | 47 const char kConflictingBoundsOptions[] = |
| 48 "The $1 property cannot be specified for both inner and outer bounds."; | 48 "The $1 property cannot be specified for both inner and outer bounds."; |
| 49 const char kAlwaysOnTopPermission[] = | 49 const char kAlwaysOnTopPermission[] = |
| 50 "The \"app.window.alwaysOnTop\" permission is required."; | 50 "The \"app.window.alwaysOnTop\" permission is required."; |
| 51 const char kInvalidUrlParameter[] = | 51 const char kInvalidUrlParameter[] = |
| 52 "The URL used for window creation must be local for security reasons."; | 52 "The URL used for window creation must be local for security reasons."; |
| 53 const char kImeWindowPermission[] = | |
| 54 "Only whitelisted component IME extensions can create ime window."; | |
|
benwells
2014/09/09 00:02:30
Nit: s/window/windows/
bshe
2014/09/10 22:34:54
Done.
| |
| 53 const char kAlphaEnabledWrongChannel[] = | 55 const char kAlphaEnabledWrongChannel[] = |
| 54 "The alphaEnabled option requires dev channel or newer."; | 56 "The alphaEnabled option requires dev channel or newer."; |
| 55 const char kAlphaEnabledMissingPermission[] = | 57 const char kAlphaEnabledMissingPermission[] = |
| 56 "The alphaEnabled option requires app.window.alpha permission."; | 58 "The alphaEnabled option requires app.window.alpha permission."; |
| 57 const char kAlphaEnabledNeedsFrameNone[] = | 59 const char kAlphaEnabledNeedsFrameNone[] = |
| 58 "The alphaEnabled option can only be used with \"frame: 'none'\"."; | 60 "The alphaEnabled option can only be used with \"frame: 'none'\"."; |
| 59 } // namespace app_window_constants | 61 } // namespace app_window_constants |
| 60 | 62 |
| 61 const char kNoneFrameOption[] = "none"; | 63 const char kNoneFrameOption[] = "none"; |
| 62 // TODO(benwells): Remove HTML titlebar injection. | 64 // TODO(benwells): Remove HTML titlebar injection. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 if (!GetBoundsSpec(*options, &create_params, &error_)) | 195 if (!GetBoundsSpec(*options, &create_params, &error_)) |
| 194 return false; | 196 return false; |
| 195 | 197 |
| 196 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() || | 198 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() || |
| 197 extension()->location() == extensions::Manifest::COMPONENT) { | 199 extension()->location() == extensions::Manifest::COMPONENT) { |
| 198 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { | 200 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { |
| 199 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 201 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
| 200 } | 202 } |
| 201 } | 203 } |
| 202 | 204 |
| 205 if (options->ime.get() && | |
| 206 extension()->location() == extensions::Manifest::COMPONENT) { | |
| 207 const char* whitelist[] = { | |
| 208 // Keep in sync with app.window's whitelist in _api_features.json | |
| 209 "06BE211D5F014BAB34BC22D9DDA09C63A81D828E", | |
|
benwells
2014/09/09 00:02:30
I think the best way to do this checking is to cre
bshe
2014/09/10 22:34:54
Done.
| |
| 210 "F94EE6AB36D6C6588670B2B01EB65212D9C64E33" | |
| 211 }; | |
| 212 if (!extensions::SimpleFeature::IsIdInList( | |
| 213 extension_id(), | |
| 214 std::set<std::string>(whitelist, | |
| 215 whitelist + arraysize(whitelist)))) { | |
| 216 error_ = app_window_constants::kImeWindowPermission; | |
| 217 return false; | |
| 218 } else { | |
| 219 create_params.is_ime_window = true; | |
|
benwells
2014/09/09 00:02:30
Should be setting to *options->ime.get() for cases
bshe
2014/09/10 22:34:54
Oops. I thought options->ime.get() returns the boo
| |
| 220 } | |
| 221 } | |
|
benwells
2014/09/09 00:02:30
There needs to be a check to make sure that if the
bshe
2014/09/10 22:34:54
It is now enforced by whitelist. Only two whitelis
| |
| 222 | |
| 203 if (!GetFrameOptions(*options, &create_params)) | 223 if (!GetFrameOptions(*options, &create_params)) |
| 204 return false; | 224 return false; |
| 205 | 225 |
| 206 if (options->alpha_enabled.get()) { | 226 if (options->alpha_enabled.get()) { |
| 207 const char* whitelist[] = { | 227 const char* whitelist[] = { |
| 208 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 | 228 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 |
| 209 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", | 229 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", |
| 210 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 | 230 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 |
| 211 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", | 231 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", |
| 212 "312745D9BF916161191143F6490085EEA0434997", | 232 "312745D9BF916161191143F6490085EEA0434997", |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 | 508 |
| 489 if (options.frame->as_frame_options->inactive_color.get()) { | 509 if (options.frame->as_frame_options->inactive_color.get()) { |
| 490 error_ = app_window_constants::kInactiveColorWithoutColor; | 510 error_ = app_window_constants::kInactiveColorWithoutColor; |
| 491 return false; | 511 return false; |
| 492 } | 512 } |
| 493 | 513 |
| 494 return true; | 514 return true; |
| 495 } | 515 } |
| 496 | 516 |
| 497 } // namespace extensions | 517 } // namespace extensions |
| OLD | NEW |