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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/common/extensions/api/app_window.h" | 12 #include "chrome/common/extensions/api/app_window.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "content/public/browser/notification_types.h" | 14 #include "content/public/browser/notification_types.h" |
| 15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 19 #include "extensions/browser/app_window/app_window.h" | 19 #include "extensions/browser/app_window/app_window.h" |
| 20 #include "extensions/browser/app_window/app_window_contents.h" | 20 #include "extensions/browser/app_window/app_window_contents.h" |
| 21 #include "extensions/browser/app_window/app_window_registry.h" | 21 #include "extensions/browser/app_window/app_window_registry.h" |
| 22 #include "extensions/browser/app_window/apps_client.h" | 22 #include "extensions/browser/app_window/apps_client.h" |
| 23 #include "extensions/browser/app_window/native_app_window.h" | 23 #include "extensions/browser/app_window/native_app_window.h" |
| 24 #include "extensions/browser/extensions_browser_client.h" | 24 #include "extensions/browser/extensions_browser_client.h" |
| 25 #include "extensions/browser/image_util.h" | 25 #include "extensions/browser/image_util.h" |
| 26 #include "extensions/common/manifest.h" | |
| 26 #include "extensions/common/features/simple_feature.h" | 27 #include "extensions/common/features/simple_feature.h" |
| 27 #include "extensions/common/permissions/permissions_data.h" | 28 #include "extensions/common/permissions/permissions_data.h" |
| 28 #include "extensions/common/switches.h" | 29 #include "extensions/common/switches.h" |
| 29 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
| 30 #include "ui/base/ui_base_types.h" | 31 #include "ui/base/ui_base_types.h" |
| 31 #include "ui/gfx/rect.h" | 32 #include "ui/gfx/rect.h" |
| 32 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 33 | 34 |
| 34 namespace app_window = extensions::api::app_window; | 35 namespace app_window = extensions::api::app_window; |
| 35 namespace Create = app_window::Create; | 36 namespace Create = app_window::Create; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 49 const char kAlwaysOnTopPermission[] = | 50 const char kAlwaysOnTopPermission[] = |
| 50 "The \"app.window.alwaysOnTop\" permission is required."; | 51 "The \"app.window.alwaysOnTop\" permission is required."; |
| 51 const char kInvalidUrlParameter[] = | 52 const char kInvalidUrlParameter[] = |
| 52 "The URL used for window creation must be local for security reasons."; | 53 "The URL used for window creation must be local for security reasons."; |
| 53 const char kAlphaEnabledWrongChannel[] = | 54 const char kAlphaEnabledWrongChannel[] = |
| 54 "The alphaEnabled option requires dev channel or newer."; | 55 "The alphaEnabled option requires dev channel or newer."; |
| 55 const char kAlphaEnabledMissingPermission[] = | 56 const char kAlphaEnabledMissingPermission[] = |
| 56 "The alphaEnabled option requires app.window.alpha permission."; | 57 "The alphaEnabled option requires app.window.alpha permission."; |
| 57 const char kAlphaEnabledNeedsFrameNone[] = | 58 const char kAlphaEnabledNeedsFrameNone[] = |
| 58 "The alphaEnabled option can only be used with \"frame: 'none'\"."; | 59 "The alphaEnabled option can only be used with \"frame: 'none'\"."; |
| 60 const char kImeOptionIsRequired[] = | |
| 61 "The ime option must be set for non platform app."; | |
| 62 const char kImeWindowMissingPermission[] = | |
| 63 "The ime option requires app.window.ime permission."; | |
| 64 const char kImeWindowNeedsFrameNone[] = | |
| 65 "The ime option can only be used with \"frame: 'none'\"."; | |
| 66 const char kImeOptionIsNotSupported[] = | |
| 67 "The ime option is not supported for platform app."; | |
| 68 #if !defined(OS_CHROMEOS) | |
| 69 const char kImeWindowUnsupportedPlatform[] = | |
| 70 "The ime option can only be used on ChromeOS."; | |
| 71 #endif | |
| 59 } // namespace app_window_constants | 72 } // namespace app_window_constants |
| 60 | 73 |
| 61 const char kNoneFrameOption[] = "none"; | 74 const char kNoneFrameOption[] = "none"; |
| 62 // TODO(benwells): Remove HTML titlebar injection. | 75 // TODO(benwells): Remove HTML titlebar injection. |
| 63 const char kHtmlFrameOption[] = "experimental-html"; | 76 const char kHtmlFrameOption[] = "experimental-html"; |
| 64 | 77 |
| 65 namespace { | 78 namespace { |
| 66 | 79 |
| 67 // If the same property is specified for the inner and outer bounds, raise an | 80 // If the same property is specified for the inner and outer bounds, raise an |
| 68 // error. | 81 // error. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() || | 209 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() || |
| 197 extension()->location() == extensions::Manifest::COMPONENT) { | 210 extension()->location() == extensions::Manifest::COMPONENT) { |
| 198 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { | 211 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { |
| 199 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 212 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
| 200 } | 213 } |
| 201 } | 214 } |
| 202 | 215 |
| 203 if (!GetFrameOptions(*options, &create_params)) | 216 if (!GetFrameOptions(*options, &create_params)) |
| 204 return false; | 217 return false; |
| 205 | 218 |
| 219 if (extension()->GetType() == extensions::Manifest::TYPE_PLATFORM_APP) { | |
|
jackhou1
2014/09/12 03:24:51
Prior to this, this entire function assumed TYPE_P
bshe
2014/09/12 17:44:12
Done.
| |
| 220 if (options->ime.get()) { | |
| 221 error_ = app_window_constants::kImeOptionIsNotSupported; | |
| 222 return false; | |
| 223 } | |
| 224 } else { | |
| 225 #if defined(OS_CHROMEOS) | |
| 226 if (!options->ime.get()) { | |
|
jackhou1
2014/09/12 03:24:51
IIUC, extensions can only ever use chrome.app.wind
bshe
2014/09/12 17:44:12
Done.
| |
| 227 error_ = app_window_constants::kImeOptionIsRequired; | |
| 228 return false; | |
| 229 } | |
| 230 if (!extension()->permissions_data()->HasAPIPermission( | |
| 231 APIPermission::kImeWindowEnabled)) { | |
| 232 error_ = app_window_constants::kImeWindowMissingPermission; | |
| 233 return false; | |
| 234 } | |
| 235 if (create_params.frame != AppWindow::FRAME_NONE) { | |
| 236 error_ = app_window_constants::kImeWindowNeedsFrameNone; | |
| 237 return false; | |
| 238 } | |
| 239 create_params.is_ime_window = *options->ime; | |
| 240 #else | |
| 241 // IME window is only supported on ChromeOS. | |
| 242 error_ = app_window_constants::kImeWindowUnsupportedPlatform; | |
| 243 return false; | |
| 244 #endif | |
| 245 } | |
| 246 | |
| 206 if (options->alpha_enabled.get()) { | 247 if (options->alpha_enabled.get()) { |
| 207 const char* whitelist[] = { | 248 const char* whitelist[] = { |
| 208 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 | 249 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 |
| 209 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", | 250 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", |
| 210 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 | 251 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 |
| 211 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", | 252 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", |
| 212 "312745D9BF916161191143F6490085EEA0434997", | 253 "312745D9BF916161191143F6490085EEA0434997", |
| 213 "53041A2FA309EECED01FFC751E7399186E860B2C" | 254 "53041A2FA309EECED01FFC751E7399186E860B2C" |
| 214 }; | 255 }; |
| 215 if (AppsClient::Get()->IsCurrentChannelOlderThanDev() && | 256 if (AppsClient::Get()->IsCurrentChannelOlderThanDev() && |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 | 529 |
| 489 if (options.frame->as_frame_options->inactive_color.get()) { | 530 if (options.frame->as_frame_options->inactive_color.get()) { |
| 490 error_ = app_window_constants::kInactiveColorWithoutColor; | 531 error_ = app_window_constants::kInactiveColorWithoutColor; |
| 491 return false; | 532 return false; |
| 492 } | 533 } |
| 493 | 534 |
| 494 return true; | 535 return true; |
| 495 } | 536 } |
| 496 | 537 |
| 497 } // namespace extensions | 538 } // namespace extensions |
| OLD | NEW |