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

Side by Side Diff: third_party/google_input_tools/src/chrome/os/env.js

Issue 1257313003: Update Google Input Tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free up grd resources. Created 5 years, 4 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
(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.Env');
15
16 goog.require('goog.array');
17 goog.require('i18n.input.chrome.Constant');
18 goog.require('i18n.input.chrome.inputview.FeatureTracker');
19 goog.require('i18n.input.lang.InputTool');
20 goog.require('i18n.input.lang.InputToolType');
21
22 goog.scope(function() {
23 var Constant = i18n.input.chrome.Constant;
24 var FeatureTracker = i18n.input.chrome.inputview.FeatureTracker;
25 var InputTool = i18n.input.lang.InputTool;
26 var InputToolType = i18n.input.lang.InputToolType;
27
28
29
30 /**
31 * The Environment class which holds some status' of ChromeOS for input methods.
32 * e.g. the current input field context, the current input method engine ID,
33 * the flags, etc.
34 *
35 * @constructor
36 */
37 i18n.input.chrome.Env = function() {
38
39 /**
40 * Tracker for which FeatureName are enabled.
41 *
42 * @type {!FeatureTracker};
43 */
44 this.featureTracker = new FeatureTracker();
45
46 /** @private {!Function} */
47 this.compositionBoundsChangedHandler_ =
48 this.onBoundsChanged_.bind(this);
49
50 /**
51 * The current initial bounds.
52 * @type {!BoundSize}
53 */
54 this.currentBounds = /** @type {!BoundSize} */ ({x: 0, y: 0, w: 0, h: 0});
55
56
57 /**
58 * The current bounds list.
59 * @type {!Array.<!BoundSize>}
60 */
61 this.currentBoundsList = [
62 /** @type {!BoundSize} */ ({x: 0, y: 0, w: 0, h: 0})];
63
64
65 if (chrome.accessibilityFeatures &&
66 chrome.accessibilityFeatures.spokenFeedback) {
67 chrome.accessibilityFeatures.spokenFeedback.get({}, (function(details) {
68 this.isChromeVoxOn = details['value'];
69 }).bind(this));
70
71 chrome.accessibilityFeatures.spokenFeedback.onChange.addListener(
72 function(details) {
73 this.isChromeVoxOn = details['value'];
74 }.bind(this));
75 }
76
77 if (window.inputview && window.inputview.getKeyboardConfig) {
78 window.inputview.getKeyboardConfig((function(config) {
79 this.featureTracker.initialize(config);
80 }).bind(this));
81 }
82 };
83 var Env = i18n.input.chrome.Env;
84 goog.addSingletonGetter(Env);
85
86
87 /** @type {string} */
88 Env.prototype.engineId = '';
89
90
91 /** @type {InputContext} */
92 Env.prototype.context = null;
93
94
95 /** @type {string} */
96 Env.prototype.screenType = 'normal';
97
98
99 /** @type {boolean} */
100 Env.prototype.isPhysicalKeyboardAutocorrectEnabled = false;
101
102
103 /** @type {string} */
104 Env.prototype.textBeforeCursor = '';
105
106
107 /** @type {Object.<{text: string, focus: number, anchor: number}>} */
108 Env.prototype.surroundingInfo = null;
109
110
111 /** @type {boolean} */
112 Env.prototype.isChromeVoxOn = false;
113
114
115 /** @type {boolean} */
116 Env.prototype.isOnScreenKeyboardShown = false;
117
118
119 /**
120 * Handler for onCompositionBoundsChanged event.
121 *
122 * @param {!BoundSize} bounds The bounds of the composition text.
123 * @param {!Array.<!BoundSize>} boundsList The list of bounds of each
124 * composition character.
125 * @private
126 */
127 Env.prototype.onBoundsChanged_ = function(bounds, boundsList) {
128 this.currentBounds = bounds;
129 this.currentBoundsList = boundsList;
130 };
131
132
133 /**
134 * Let Env listen "onCompositionBoundsChanged" event.
135 */
136 Env.prototype.listenCompositionBoundsChanged = function() {
137 if (chrome.inputMethodPrivate &&
138 chrome.inputMethodPrivate.onCompositionBoundsChanged) {
139 chrome.inputMethodPrivate.onCompositionBoundsChanged.addListener(
140 this.compositionBoundsChangedHandler_);
141 }
142 };
143
144
145 /**
146 * Let Env unlisten "onCompositionBoundsChanged" event.
147 */
148 Env.prototype.unlistenCompositionBoundsChanged = function() {
149 if (chrome.inputMethodPrivate &&
150 chrome.inputMethodPrivate.onCompositionBoundsChanged) {
151 chrome.inputMethodPrivate.onCompositionBoundsChanged.removeListener(
152 this.compositionBoundsChangedHandler_);
153 }
154 };
155
156
157 /**
158 * Returns whether the XKB engine id supports NACL.
159 *
160 * @param {string} xkbEngineId The XKB engine Id.
161 * @return {boolean} supported or not.
162 */
163 Env.isXkbAndNaclEnabled = function(xkbEngineId) {
164 var inputTool = InputTool.get(xkbEngineId);
165 return !!inputTool && inputTool.type == InputToolType.XKB &&
166 goog.array.contains(Constant.NACL_LANGUAGES, inputTool.languageCode);
167 };
168 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698