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

Unified 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: reviews 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/app_window/app_window_api.cc
diff --git a/chrome/browser/extensions/api/app_window/app_window_api.cc b/chrome/browser/extensions/api/app_window/app_window_api.cc
index 9b591a71f558bba21bcae2da008b0a17826940b4..1bd9ccd5c52846a1a4abdc5f72703ed6087cc04d 100644
--- a/chrome/browser/extensions/api/app_window/app_window_api.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_api.cc
@@ -24,6 +24,7 @@
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/image_util.h"
#include "extensions/common/features/simple_feature.h"
+#include "extensions/common/manifest.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/switches.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -56,6 +57,17 @@ const char kAlphaEnabledMissingPermission[] =
"The alphaEnabled option requires app.window.alpha permission.";
const char kAlphaEnabledNeedsFrameNone[] =
"The alphaEnabled option can only be used with \"frame: 'none'\".";
+const char kImeOptionMustTrueAndNeedsFrameNone[] =
jackhou1 2014/09/15 03:49:33 Nit: s/MustTrue/MustBeTrue/
bshe 2014/09/16 12:44:56 Done.
+ "IME extensions must create window with \"ime: true\" and " \
+ "\"frame: 'none'\".";
+const char kImeWindowMissingPermission[] =
+ "The \"ime\" option requires \"app.window.ime\" permission.";
jackhou1 2014/09/15 03:49:33 "Extensions require the \"app.window.ime\" permiss
bshe 2014/09/16 12:44:56 Done.
+const char kImeOptionIsNotSupported[] =
+ "The \"ime\" option is not supported for platform app.";
+#if !defined(OS_CHROMEOS)
+const char kImeWindowUnsupportedPlatform[] =
+ "The \"ime\" option can only be used on ChromeOS.";
+#endif
} // namespace app_window_constants
const char kNoneFrameOption[] = "none";
@@ -203,6 +215,35 @@ bool AppWindowCreateFunction::RunAsync() {
if (!GetFrameOptions(*options, &create_params))
return false;
+ if (extension()->GetType() == extensions::Manifest::TYPE_EXTENSION) {
+ // Whitelisted IME extensions are allowed to use this API to create IME
+ // specific windows to show accented characters or suggestions.
+ if (!extension()->permissions_data()->HasAPIPermission(
+ APIPermission::kImeWindowEnabled)) {
+ error_ = app_window_constants::kImeWindowMissingPermission;
+ return false;
+ }
+
+#if !defined(OS_CHROMEOS)
+ // IME window is only supported on ChromeOS.
+ error_ = app_window_constants::kImeWindowUnsupportedPlatform;
+ return false;
+#endif
+
+ // IME extensions must create window with "ime: true" and "frame: none".
+ if (!options->ime.get() || !*options->ime.get() ||
+ create_params.frame != AppWindow::FRAME_NONE) {
+ error_ = app_window_constants::kImeOptionMustTrueAndNeedsFrameNone;
+ return false;
+ }
+ create_params.is_ime_window = true;
+ } else {
+ if (options->ime.get()) {
+ error_ = app_window_constants::kImeOptionIsNotSupported;
+ return false;
+ }
+ }
+
if (options->alpha_enabled.get()) {
const char* whitelist[] = {
"0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773

Powered by Google App Engine
This is Rietveld 408576698