| OLD | NEW |
| (Empty) | |
| 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"); |
| 13 // |
| 14 goog.provide('i18n.input.chrome.WindowUtil'); |
| 15 |
| 16 goog.require('goog.events'); |
| 17 goog.require('goog.object'); |
| 18 |
| 19 |
| 20 goog.scope(function() { |
| 21 var WindowUtil = i18n.input.chrome.WindowUtil; |
| 22 |
| 23 |
| 24 /** |
| 25 * The empty floating window url. |
| 26 * |
| 27 * @private {string} |
| 28 */ |
| 29 WindowUtil.EMPTY_WINDOW_URL_ = 'imewindows/window.html'; |
| 30 |
| 31 |
| 32 /** |
| 33 * Create an empty floating window. |
| 34 * |
| 35 * @param {!Function} callback . |
| 36 * @param {Object.<string, *>=} opt_overridedOption . |
| 37 * @param {string=} opt_urlParameter . |
| 38 */ |
| 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 }); |
| 51 } |
| 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)); |
| 59 } |
| 60 }; |
| 61 |
| 62 |
| 63 /** |
| 64 * Callback for "inputview.createWindow". |
| 65 * |
| 66 * @param {!Function} callback . |
| 67 * @param {chrome.app.window.AppWindow} newWindow . |
| 68 * @private |
| 69 */ |
| 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 }); |
| 76 } |
| 77 }; |
| 78 }); // goog.scope |
| 79 |
| OLD | NEW |