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

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

Issue 975453003: Update Google Input Tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « third_party/google_input_tools/src/chrome/os/message/name.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License. 2 // limitations under the License.
3 // See the License for the specific language governing permissions and 3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS, 5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software 6 // Unless required by applicable law or agreed to in writing, software
7 // 7 //
8 // http://www.apache.org/licenses/LICENSE-2.0 8 // http://www.apache.org/licenses/LICENSE-2.0
9 // 9 //
10 // You may obtain a copy of the License at 10 // You may obtain a copy of the License at
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 /** 89 /**
90 * Whether recording for physical keyboard specially. 90 * Whether recording for physical keyboard specially.
91 * 91 *
92 * @private {boolean} 92 * @private {boolean}
93 */ 93 */
94 Statistics.prototype.isPhysicalKeyboard_ = false; 94 Statistics.prototype.isPhysicalKeyboard_ = false;
95 95
96 96
97 /** 97 /**
98 * The length of the last text commit.
99 *
100 * @private {number}
101 */
102 Statistics.prototype.lastCommitLength_ = 0;
103
104
105 /**
106 * The number of characters typed in this session.
107 *
108 * @private {number}
109 */
110 Statistics.prototype.charactersCommitted_ = 0;
111
112
113 /**
98 * Sets whether recording for physical keyboard. 114 * Sets whether recording for physical keyboard.
99 * 115 *
100 * @param {boolean} isPhysicalKeyboard . 116 * @param {boolean} isPhysicalKeyboard .
101 */ 117 */
102 Statistics.prototype.setPhysicalKeyboard = function(isPhysicalKeyboard) { 118 Statistics.prototype.setPhysicalKeyboard = function(isPhysicalKeyboard) {
103 this.isPhysicalKeyboard_ = isPhysicalKeyboard; 119 this.isPhysicalKeyboard_ = isPhysicalKeyboard;
104 }; 120 };
105 121
106 122
107 /** 123 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return 3; 161 return 3;
146 } 162 }
147 if (target.length > source.length) { 163 if (target.length > source.length) {
148 return 2; 164 return 2;
149 } 165 }
150 return 1; 166 return 1;
151 }; 167 };
152 168
153 169
154 /** 170 /**
171 * Records that the controller session ended.
172 */
173 Statistics.prototype.recordSessionEnd = function() {
174 // Do not record cases where we gain and immediately lose focus. This also
175 // excudes the focus loss-gain on the new tab page from being counted.
176 if (this.charactersCommitted_ > 0) {
177 this.recordValue('InputMethod.VirtualKeyboard.CharactersCommitted',
178 this.charactersCommitted_, 16384, 50);
179 // TODO: Add WPM metrics.
180 }
181 this.charactersCommitted_ = 0;
182 this.lastCommitLength_ = 0;
183 };
184
185
186 /**
155 * Records the metrics for each commit. 187 * Records the metrics for each commit.
156 * 188 *
157 * @param {string} source . 189 * @param {string} source .
158 * @param {string} target . 190 * @param {string} target .
159 * @param {number} targetIndex The target index. 191 * @param {number} targetIndex The target index.
160 * @param {number} triggerType The trigger type: 192 * @param {number} triggerType The trigger type:
161 * 0: BySpace; 1: ByReset; 2: ByCandidate; 3: BySymbolOrNumber; 193 * 0: BySpace; 1: ByReset; 2: ByCandidate; 3: BySymbolOrNumber;
162 * 4: ByDoubleSpaceToPeriod; 5: ByRevert; 6: ByVoice. 194 * 4: ByDoubleSpaceToPeriod; 5: ByRevert; 6: ByVoice.
163 */ 195 */
164 Statistics.prototype.recordCommit = function( 196 Statistics.prototype.recordCommit = function(
165 source, target, targetIndex, triggerType) { 197 source, target, targetIndex, triggerType) {
166 if (!this.inputMethodId_) { 198 if (!this.inputMethodId_) {
167 return; 199 return;
168 } 200 }
201 var length = target.length;
202 // Increment to include space.
203 if (triggerType == 0) {
204 length++;
205 } else if (triggerType == 5) {
206 length -= this.lastCommitLength_;
207 }
208 this.lastCommitLength_ = length;
209 this.charactersCommitted_ += length;
210
169 var CommitTypes = Statistics.CommitTypes; 211 var CommitTypes = Statistics.CommitTypes;
170 var commitType = -1; 212 var commitType = -1;
171 if (targetIndex == 0 && source == target) { 213 if (targetIndex == 0 && source == target) {
172 commitType = CommitTypes.X_X0; 214 commitType = CommitTypes.X_X0;
173 } else if (targetIndex == 0 && source != target) { 215 } else if (targetIndex == 0 && source != target) {
174 commitType = CommitTypes.X_Y0; 216 commitType = CommitTypes.X_Y0;
175 } else if (targetIndex > 0 && source == target) { 217 } else if (targetIndex > 0 && source == target) {
176 commitType = CommitTypes.X_X1; 218 commitType = CommitTypes.X_X1;
177 } else if (targetIndex > 0 && source != target) { 219 } else if (targetIndex > 0 && source != target) {
178 commitType = CommitTypes.X_Y1; 220 commitType = CommitTypes.X_Y1;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 Statistics.prototype.recordBackspace = function() { 373 Statistics.prototype.recordBackspace = function() {
332 // Ignore multiple backspaces typed in succession. 374 // Ignore multiple backspaces typed in succession.
333 if (this.charactersBetweenBackspaces_ > 0) { 375 if (this.charactersBetweenBackspaces_ > 0) {
334 this.recordValue( 376 this.recordValue(
335 'InputMethod.VirtualKeyboard.CharactersBetweenBackspaces', 377 'InputMethod.VirtualKeyboard.CharactersBetweenBackspaces',
336 this.charactersBetweenBackspaces_, 4096, 50); 378 this.charactersBetweenBackspaces_, 4096, 50);
337 } 379 }
338 this.charactersBetweenBackspaces_ = 0; 380 this.charactersBetweenBackspaces_ = 0;
339 }; 381 };
340 }); // goog.scope 382 }); // goog.scope
OLDNEW
« no previous file with comments | « third_party/google_input_tools/src/chrome/os/message/name.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698