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

Side by Side Diff: chrome/browser/extensions/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: more tests Created 6 years, 3 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 "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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 kAlphaEnabledWrongChannel[] = 53 const char kAlphaEnabledWrongChannel[] =
54 "The alphaEnabled option requires dev channel or newer."; 54 "The alphaEnabled option requires dev channel or newer.";
55 const char kAlphaEnabledMissingPermission[] = 55 const char kAlphaEnabledMissingPermission[] =
56 "The alphaEnabled option requires app.window.alpha permission."; 56 "The alphaEnabled option requires app.window.alpha permission.";
57 const char kAlphaEnabledNeedsFrameNone[] = 57 const char kAlphaEnabledNeedsFrameNone[] =
58 "The alphaEnabled option can only be used with \"frame: 'none'\"."; 58 "The alphaEnabled option can only be used with \"frame: 'none'\".";
59 const char kImeWindowMissingPermission[] =
60 "The ime option requires app.window.ime permission.";
61 const char kImeWindowNeedsFrameNone[] =
62 "The ime option can only be used with \"frame: 'none'\".";
63 #if !defined(OS_CHROMEOS)
64 const char kImeWindowUnsupportedPlatform[] =
65 "The ime option can only be used on ChromeOS.";
66 #endif
59 } // namespace app_window_constants 67 } // namespace app_window_constants
60 68
61 const char kNoneFrameOption[] = "none"; 69 const char kNoneFrameOption[] = "none";
62 // TODO(benwells): Remove HTML titlebar injection. 70 // TODO(benwells): Remove HTML titlebar injection.
63 const char kHtmlFrameOption[] = "experimental-html"; 71 const char kHtmlFrameOption[] = "experimental-html";
64 72
65 namespace { 73 namespace {
66 74
67 // If the same property is specified for the inner and outer bounds, raise an 75 // If the same property is specified for the inner and outer bounds, raise an
68 // error. 76 // error.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() || 204 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() ||
197 extension()->location() == extensions::Manifest::COMPONENT) { 205 extension()->location() == extensions::Manifest::COMPONENT) {
198 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) { 206 if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) {
199 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; 207 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL;
200 } 208 }
201 } 209 }
202 210
203 if (!GetFrameOptions(*options, &create_params)) 211 if (!GetFrameOptions(*options, &create_params))
204 return false; 212 return false;
205 213
214 if (options->ime.get()) {
benwells 2014/09/11 19:35:10 It is important that non-app extensions MUST speci
bshe 2014/09/11 22:35:59 I see what you mean. I thought whitelist is enough
215 #if defined(OS_CHROMEOS)
216 if (!extension()->permissions_data()->HasAPIPermission(
217 APIPermission::kImeWindowEnabled)) {
218 error_ = app_window_constants::kImeWindowMissingPermission;
219 return false;
220 }
221 if (create_params.frame != AppWindow::FRAME_NONE) {
222 error_ = app_window_constants::kImeWindowNeedsFrameNone;
223 return false;
224 }
225 create_params.is_ime_window = *options->ime;
226 #else
227 // IME window is only supported on ChromeOS.
228 error_ = app_window_constants::kImeWindowUnsupportedPlatform;
229 return false;
230 #endif
231 }
232
206 if (options->alpha_enabled.get()) { 233 if (options->alpha_enabled.get()) {
207 const char* whitelist[] = { 234 const char* whitelist[] = {
208 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 235 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773
209 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", 236 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7",
210 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 237 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200
211 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", 238 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3",
212 "312745D9BF916161191143F6490085EEA0434997", 239 "312745D9BF916161191143F6490085EEA0434997",
213 "53041A2FA309EECED01FFC751E7399186E860B2C" 240 "53041A2FA309EECED01FFC751E7399186E860B2C"
214 }; 241 };
215 if (AppsClient::Get()->IsCurrentChannelOlderThanDev() && 242 if (AppsClient::Get()->IsCurrentChannelOlderThanDev() &&
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 515
489 if (options.frame->as_frame_options->inactive_color.get()) { 516 if (options.frame->as_frame_options->inactive_color.get()) {
490 error_ = app_window_constants::kInactiveColorWithoutColor; 517 error_ = app_window_constants::kInactiveColorWithoutColor;
491 return false; 518 return false;
492 } 519 }
493 520
494 return true; 521 return true;
495 } 522 }
496 523
497 } // namespace extensions 524 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698