summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/api/input_ime/input_ime_apitest_nonchromeos.cc28
-rw-r--r--chrome/chrome_tests.gypi7
-rw-r--r--chrome/renderer/resources/extensions/input.ime_custom_bindings.js15
-rw-r--r--chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js25
-rw-r--r--chrome/test/data/extensions/api_test/input_ime_nonchromeos/manifest.json10
-rw-r--r--extensions/renderer/app_window_custom_bindings.cc11
-rw-r--r--extensions/renderer/resources/app_window_custom_bindings.js6
7 files changed, 96 insertions, 6 deletions
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_apitest_nonchromeos.cc b/chrome/browser/extensions/api/input_ime/input_ime_apitest_nonchromeos.cc
new file mode 100644
index 0000000..ce4c16f
--- /dev/null
+++ b/chrome/browser/extensions/api/input_ime/input_ime_apitest_nonchromeos.cc
@@ -0,0 +1,28 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/common/chrome_switches.h"
+
+namespace extensions {
+
+class InputImeApiTest : public ExtensionApiTest {
+ public:
+ InputImeApiTest() {}
+
+ protected:
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kEnableInputImeAPI);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(InputImeApiTest);
+};
+
+IN_PROC_BROWSER_TEST_F(InputImeApiTest, CreateWindowTest) {
+ ASSERT_TRUE(RunExtensionTest("input_ime_nonchromeos")) << message_;
+}
+
+} // namespace extensions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d952c5e..87bfb56 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2413,6 +2413,13 @@
'test/data/webui/settings/bluetooth_page_browsertest_chromeos.js',
'test/data/webui/settings/change_picture_browsertest_chromeos.js',
],
+ 'conditions': [
+ ['OS=="linux" or OS=="win"', {
+ 'sources': [
+ 'browser/extensions/api/input_ime/input_ime_apitest_nonchromeos.cc',
+ ]
+ }],
+ ]
}],
['configuration_policy==1', {
'sources': [ '<@(chrome_browser_tests_policy_sources)' ],
diff --git a/chrome/renderer/resources/extensions/input.ime_custom_bindings.js b/chrome/renderer/resources/extensions/input.ime_custom_bindings.js
index fb4f93a..f114124 100644
--- a/chrome/renderer/resources/extensions/input.ime_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/input.ime_custom_bindings.js
@@ -9,6 +9,8 @@ var binding = require('binding').Binding.create('input.ime');
var Event = require('event_bindings').Event;
+var appWindowNatives = requireNative('app_window_natives');
+
binding.registerCustomHook(function(api) {
var input_ime = api.compiledApi;
@@ -39,6 +41,19 @@ binding.registerCustomHook(function(api) {
}
$Function.call(Event.prototype.addListener, this, cb);
};
+
+ api.apiFunctions.setCustomCallback('createWindow',
+ function(name, request, callback, windowParams) {
+ if (!callback) {
+ return;
+ }
+ var view;
+ if (windowParams && windowParams.frameId) {
+ view = appWindowNatives.GetFrame(
+ windowParams.frameId, false /* notifyBrowser */);
+ }
+ callback(view);
+ });
});
exports.binding = binding.generate();
diff --git a/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js b/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js
new file mode 100644
index 0000000..98c7f8e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js
@@ -0,0 +1,25 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+chrome.test.runTests([
+ function testNormalCreateWindow() {
+ var options = { windowType: 'normal' };
+ chrome.input.ime.createWindow(options, function(win) {
+ chrome.test.assertTrue(!chrome.runtime.lastError);
+ chrome.test.assertTrue(!!win);
+ chrome.test.assertTrue(win instanceof Window);
+ chrome.test.assertFalse(win.document.webkitHidden);
+ chrome.test.succeed();
+ });
+ },
+ function testFollowCursorCreateWindow() {
+ var options = { windowType: 'followCursor' };
+ chrome.input.ime.createWindow(options, function(win) {
+ chrome.test.assertTrue(!chrome.runtime.lastError);
+ chrome.test.assertTrue(!!win);
+ chrome.test.assertFalse(win.document.webkitHidden);
+ chrome.test.succeed();
+ });
+ }
+]);
diff --git a/chrome/test/data/extensions/api_test/input_ime_nonchromeos/manifest.json b/chrome/test/data/extensions/api_test/input_ime_nonchromeos/manifest.json
new file mode 100644
index 0000000..5997d7c
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/input_ime_nonchromeos/manifest.json
@@ -0,0 +1,10 @@
+{
+ "name": "Test IME Extension",
+ "version": "0.1",
+ "manifest_version": 2,
+ "description": "IME Extension for Testing",
+ "permissions": [ "input" ],
+ "background": {
+ "scripts": ["background.js"]
+ }
+}
diff --git a/extensions/renderer/app_window_custom_bindings.cc b/extensions/renderer/app_window_custom_bindings.cc
index 04e45a1..02df633 100644
--- a/extensions/renderer/app_window_custom_bindings.cc
+++ b/extensions/renderer/app_window_custom_bindings.cc
@@ -34,13 +34,14 @@ void AppWindowCustomBindings::GetFrame(
const v8::FunctionCallbackInfo<v8::Value>& args) {
// TODO(jeremya): convert this to IDL nocompile to get validation, and turn
// these argument checks into CHECK().
- if (args.Length() != 1)
+ if (args.Length() != 2)
return;
- if (!args[0]->IsInt32())
+ if (!args[0]->IsInt32() || !args[1]->IsBoolean())
return;
int frame_id = args[0]->Int32Value();
+ bool notify_browser = args[1]->BooleanValue();
if (frame_id == MSG_ROUTING_NONE)
return;
@@ -62,8 +63,10 @@ void AppWindowCustomBindings::GetFrame(
blink::WebLocalFrame* app_web_frame = app_frame->GetWebFrame();
app_web_frame->setOpener(opener);
- content::RenderThread::Get()->Send(new ExtensionHostMsg_AppWindowReady(
- app_frame->GetRenderView()->GetRoutingID()));
+ if (notify_browser) {
+ content::RenderThread::Get()->Send(new ExtensionHostMsg_AppWindowReady(
+ app_frame->GetRenderView()->GetRoutingID()));
+ }
v8::Local<v8::Value> window =
app_web_frame->mainWorldScriptContext()->Global();
diff --git a/extensions/renderer/resources/app_window_custom_bindings.js b/extensions/renderer/resources/app_window_custom_bindings.js
index 3800bea..b0ae54f 100644
--- a/extensions/renderer/resources/app_window_custom_bindings.js
+++ b/extensions/renderer/resources/app_window_custom_bindings.js
@@ -118,8 +118,10 @@ appWindow.registerCustomHook(function(bindingsAPI) {
var view = null;
// When window creation fails, |windowParams| will be undefined.
- if (windowParams && windowParams.frameId)
- view = appWindowNatives.GetFrame(windowParams.frameId);
+ if (windowParams && windowParams.frameId) {
+ view = appWindowNatives.GetFrame(
+ windowParams.frameId, true /* notifyBrowser */);
+ }
if (!view) {
// No route to created window. If given a callback, trigger it with an