Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: extensions/browser/api/app_window/app_window_api.cc

Issue 503383002: Allow component IME extension use app.window and add 'ime' window type for app window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
18 #include "extensions/browser/app_window/app_window.h" 18 #include "extensions/browser/app_window/app_window.h"
19 #include "extensions/browser/app_window/app_window_client.h" 19 #include "extensions/browser/app_window/app_window_client.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/native_app_window.h" 22 #include "extensions/browser/app_window/native_app_window.h"
23 #include "extensions/browser/extensions_browser_client.h" 23 #include "extensions/browser/extensions_browser_client.h"
24 #include "extensions/browser/image_util.h" 24 #include "extensions/browser/image_util.h"
25 #include "extensions/common/api/app_window.h" 25 #include "extensions/common/api/app_window.h"
26 #include "extensions/common/features/simple_feature.h" 26 #include "extensions/common/features/simple_feature.h"
27 #include "extensions/common/manifest.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::core_api::app_window; 35 namespace app_window = extensions::core_api::app_window;
35 namespace Create = app_window::Create; 36 namespace Create = app_window::Create;
36 37
(...skipping 14 matching lines...) Expand all
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'\".";
59 const char kVisibleOnAllWorkspacesWrongChannel[] = 60 const char kVisibleOnAllWorkspacesWrongChannel[] =
60 "The visibleOnAllWorkspaces option requires dev channel or newer."; 61 "The visibleOnAllWorkspaces option requires dev channel or newer.";
62 const char kImeWindowMissingPermission[] =
63 "Extensions require the \"app.window.ime\" permission to create windows.";
64 const char kImeOptionIsNotSupported[] =
65 "The \"ime\" option is not supported for platform app.";
66 #if !defined(OS_CHROMEOS)
67 const char kImeWindowUnsupportedPlatform[] =
68 "The \"ime\" option can only be used on ChromeOS.";
69 #else
70 const char kImeOptionMustBeTrueAndNeedsFrameNone[] =
71 "IME extensions must create window with \"ime: true\" and "
72 "\"frame: 'none'\".";
73 #endif
61 } // namespace app_window_constants 74 } // namespace app_window_constants
62 75
63 const char kNoneFrameOption[] = "none"; 76 const char kNoneFrameOption[] = "none";
64 // TODO(benwells): Remove HTML titlebar injection. 77 // TODO(benwells): Remove HTML titlebar injection.
65 const char kHtmlFrameOption[] = "experimental-html"; 78 const char kHtmlFrameOption[] = "experimental-html";
66 79
67 namespace { 80 namespace {
68 81
69 // If the same property is specified for the inner and outer bounds, raise an 82 // If the same property is specified for the inner and outer bounds, raise an
70 // error. 83 // error.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (!AppWindowClient::Get()->IsCurrentChannelOlderThanDev() || 210 if (!AppWindowClient::Get()->IsCurrentChannelOlderThanDev() ||
198 extension()->location() == extensions::Manifest::COMPONENT) { 211 extension()->location() == extensions::Manifest::COMPONENT) {
199 if (options->type == app_window::WINDOW_TYPE_PANEL) { 212 if (options->type == app_window::WINDOW_TYPE_PANEL) {
200 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; 213 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL;
201 } 214 }
202 } 215 }
203 216
204 if (!GetFrameOptions(*options, &create_params)) 217 if (!GetFrameOptions(*options, &create_params))
205 return false; 218 return false;
206 219
220 if (extension()->GetType() == extensions::Manifest::TYPE_EXTENSION) {
221 // Whitelisted IME extensions are allowed to use this API to create IME
222 // specific windows to show accented characters or suggestions.
223 if (!extension()->permissions_data()->HasAPIPermission(
224 APIPermission::kImeWindowEnabled)) {
225 error_ = app_window_constants::kImeWindowMissingPermission;
226 return false;
227 }
228
229 #if !defined(OS_CHROMEOS)
230 // IME window is only supported on ChromeOS.
231 error_ = app_window_constants::kImeWindowUnsupportedPlatform;
232 return false;
233 #else
234 // IME extensions must create window with "ime: true" and "frame: none".
235 if (!options->ime.get() || !*options->ime.get() ||
236 create_params.frame != AppWindow::FRAME_NONE) {
237 error_ = app_window_constants::kImeOptionMustBeTrueAndNeedsFrameNone;
238 return false;
239 }
240 create_params.is_ime_window = true;
241 #endif // OS_CHROMEOS
242 } else {
243 if (options->ime.get()) {
244 error_ = app_window_constants::kImeOptionIsNotSupported;
245 return false;
246 }
247 }
248
207 if (options->alpha_enabled.get()) { 249 if (options->alpha_enabled.get()) {
208 const char* whitelist[] = { 250 const char* whitelist[] = {
209 #if defined(OS_CHROMEOS) 251 #if defined(OS_CHROMEOS)
210 "B58B99751225318C7EB8CF4688B5434661083E07", // http://crbug.com/410550 252 "B58B99751225318C7EB8CF4688B5434661083E07", // http://crbug.com/410550
211 #endif 253 #endif
212 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 254 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773
213 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", 255 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7",
214 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 256 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200
215 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", 257 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3",
216 "312745D9BF916161191143F6490085EEA0434997", 258 "312745D9BF916161191143F6490085EEA0434997",
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 546
505 if (options.frame->as_frame_options->inactive_color.get()) { 547 if (options.frame->as_frame_options->inactive_color.get()) {
506 error_ = app_window_constants::kInactiveColorWithoutColor; 548 error_ = app_window_constants::kInactiveColorWithoutColor;
507 return false; 549 return false;
508 } 550 }
509 551
510 return true; 552 return true;
511 } 553 }
512 554
513 } // namespace extensions 555 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698