ApplicationImpl cleanup, part 1:
[chromium-blink-merge.git] / third_party / google_input_tools / src / chrome / os / floatingwindow / windowutil.js
blobf9ebf16a803caf05e4391240e0bc576f0331420d
1 // Copyright 2015 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
14 goog.provide('i18n.input.chrome.WindowUtil');
16 goog.require('goog.events');
17 goog.require('goog.object');
20 goog.scope(function() {
21 var WindowUtil = i18n.input.chrome.WindowUtil;
24 /**
25 * The empty floating window url.
27 * @private {string}
29 WindowUtil.EMPTY_WINDOW_URL_ = 'imewindows/window.html';
32 /**
33 * Create an empty floating window.
35 * @param {!Function} callback .
36 * @param {Object.<string, *>=} opt_overridedOption .
37 * @param {string=} opt_urlParameter .
39 WindowUtil.createWindow = function(callback, opt_overridedOption,
40 opt_urlParameter) {
41 var options = goog.object.create(
42 'ime', true,
43 'focused', false,
44 'frame', 'none',
45 'alphaEnabled', true,
46 'hidden', true);
47 if (opt_overridedOption) {
48 goog.object.forEach(opt_overridedOption, function(value, key) {
49 options[key] = value;
50 });
52 var url = opt_urlParameter ? WindowUtil.EMPTY_WINDOW_URL_ + opt_urlParameter :
53 WindowUtil.EMPTY_WINDOW_URL_;
54 // Right now Input Tool extension don't support floating window,
55 // will support later. So adds condition to guard it.
56 if (chrome.app.window && chrome.app.window.create) {
57 inputview.createWindow(url, options,
58 WindowUtil.createWindowCb_.bind(WindowUtil, callback));
63 /**
64 * Callback for "inputview.createWindow".
66 * @param {!Function} callback .
67 * @param {chrome.app.window.AppWindow} newWindow .
68 * @private
70 WindowUtil.createWindowCb_ = function(callback, newWindow) {
71 if (newWindow) {
72 var contentWindow = newWindow.contentWindow;
73 goog.events.listen(contentWindow, 'load', function() {
74 callback(newWindow);
75 });
78 }); // goog.scope