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

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

Issue 674153004: Add third_party/google-input-tools: Take 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@google_input_tools
Patch Set: Created 6 years, 1 month 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 2014 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.DataSource');
15
16 goog.require('goog.events');
17 goog.require('goog.events.Event');
18 goog.require('goog.events.EventTarget');
19 goog.require('goog.functions');
20
21
22 /**
23 * The data source.
24 *
25 * @param {number} numOfCanddiate The number of canddiate to fetch.
26 * @param {function(string, !Array.<!Object>)} callback .
27 * @constructor
28 * @extends {goog.events.EventTarget}
29 */
30 i18n.input.chrome.DataSource = function(numOfCanddiate, callback) {
31 goog.base(this);
32
33 /**
34 * The number of candidates to fetch.
35 *
36 * @type {number}
37 */
38 this.numOfCandidate = numOfCanddiate;
39
40 /** @protected {function(string, !Array.<!Object>)} */
41 this.callback = callback;
42 };
43 goog.inherits(i18n.input.chrome.DataSource, goog.events.EventTarget);
44
45
46 /** @type {boolean} */
47 i18n.input.chrome.DataSource.prototype.ready = false;
48
49
50 /**
51 * The correction level.
52 *
53 * @protected {number}
54 */
55 i18n.input.chrome.DataSource.prototype.correctionLevel = 0;
56
57
58 /**
59 * The language code.
60 *
61 * @type {string}
62 * @protected
63 */
64 i18n.input.chrome.DataSource.prototype.language;
65
66
67 /**
68 * Sets the langauge code.
69 *
70 * @param {string} language The language code.
71 */
72 i18n.input.chrome.DataSource.prototype.setLanguage = function(
73 language) {
74 this.language = language;
75 };
76
77
78 /**
79 * True if the datasource is ready.
80 *
81 * @return {boolean} .
82 */
83 i18n.input.chrome.DataSource.prototype.isReady = function() {
84 return this.ready;
85 };
86
87
88 /**
89 * Creates the common payload for completion or prediction request.
90 *
91 * @return {!Object} The payload.
92 * @protected
93 */
94 i18n.input.chrome.DataSource.prototype.createCommonPayload =
95 function() {
96 return {
97 'itc': this.getInputToolCode(),
98 'num': this.numOfCandidate
99 };
100 };
101
102
103 /**
104 * Gets the input tool code.
105 *
106 * @return {string} .
107 */
108 i18n.input.chrome.DataSource.prototype.getInputToolCode = function() {
109 return this.language + '-t-i0-und';
110 };
111
112
113 /**
114 * Sends completion request.
115 *
116 * @param {string} query The query .
117 * @param {string} context The context .
118 * @param {!Object=} opt_spatialData .
119 */
120 i18n.input.chrome.DataSource.prototype.sendCompletionRequest =
121 goog.functions.NULL;
122
123
124 /**
125 * Sends prediciton request.
126 *
127 * @param {string} context The context.
128 */
129 i18n.input.chrome.DataSource.prototype.sendPredictionRequest =
130 goog.functions.NULL;
131
132
133 /**
134 * Sets the correction level.
135 *
136 * @param {number} level .
137 */
138 i18n.input.chrome.DataSource.prototype.setCorrectionLevel = function(level) {
139 this.correctionLevel = level;
140 };
141
142
143 /**
144 * Clears the data source.
145 */
146 i18n.input.chrome.DataSource.prototype.clear = goog.functions.NULL;
147
148
149 /**
150 * The event type.
151 *
152 * @enum {string}
153 */
154 i18n.input.chrome.DataSource.EventType = {
155 CANDIDATES_BACK: goog.events.getUniqueId('cb'),
156 READY: goog.events.getUniqueId('r')
157 };
158
159
160
161 /**
162 * The candidates is fetched back.
163 *
164 * @param {string} source The source.
165 * @param {!Array.<!Object>} candidates The candidates.
166 * @constructor
167 * @extends {goog.events.Event}
168 */
169 i18n.input.chrome.DataSource.CandidatesBackEvent =
170 function(source, candidates) {
171 goog.base(this, i18n.input.chrome.DataSource.EventType.CANDIDATES_BACK);
172
173 /**
174 * The source.
175 *
176 * @type {string}
177 */
178 this.source = source;
179
180 /**
181 * The candidate list.
182 *
183 * @type {!Array.<!Object>}
184 */
185 this.candidates = candidates;
186 };
187 goog.inherits(i18n.input.chrome.DataSource.CandidatesBackEvent,
188 goog.events.Event);
189
OLDNEW
« no previous file with comments | « third_party/google_input_tools/README.chromium ('k') | third_party/google_input_tools/src/chrome/os/inputview/adapter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698