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

Side by Side Diff: chrome/test/data/webui/settings/fake_language_settings_private.js

Issue 2255043002: Remove input methods when removing languages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Fake implementation of chrome.languageSettingsPrivate 6 * @fileoverview Fake implementation of chrome.languageSettingsPrivate
7 * for testing. 7 * for testing.
8 */ 8 */
9 cr.define('settings', function() { 9 cr.define('settings', function() {
10 /** 10 /**
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 this.componentExtensionImes = [{ 78 this.componentExtensionImes = [{
79 id: '_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us::eng', 79 id: '_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us::eng',
80 displayName: 'US keyboard', 80 displayName: 'US keyboard',
81 languageCodes: ['en', 'en-US'], 81 languageCodes: ['en', 'en-US'],
82 enabled: true, 82 enabled: true,
83 }, { 83 }, {
84 id: '_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us:dvorak:eng', 84 id: '_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us:dvorak:eng',
85 displayName: 'US Dvorak keyboard', 85 displayName: 'US Dvorak keyboard',
86 languageCodes: ['en', 'en-US'], 86 languageCodes: ['en', 'en-US'],
87 enabled: true, 87 enabled: true,
88 }, {
89 id: '_comp_ime_abcdefghijklmnopqrstuvwxyzabcdefxkb:sw:sw',
90 displayName: 'Swahili keyboard',
91 languageCodes: ['sw', 'tk'],
92 enabled: false,
93 }, {
94 id: '_comp_ime_abcdefghijklmnopqrstuvwxyzabcdefxkb:us:sw',
95 displayName: 'US Swahili keyboard',
96 languageCodes: ['en', 'en-US', 'sw'],
97 enabled: false,
88 }]; 98 }];
89 } 99 }
90 100
91 FakeLanguageSettingsPrivate.prototype = { 101 FakeLanguageSettingsPrivate.prototype = {
92 // Methods for use in testing. 102 // Methods for use in testing.
93 103
94 /** @param {SettingsPrefsElement} */ 104 /** @param {SettingsPrefsElement} */
95 setSettingsPrefs: function(settingsPrefs) { 105 setSettingsPrefs: function(settingsPrefs) {
96 this.settingsPrefs_ = settingsPrefs; 106 this.settingsPrefs_ = settingsPrefs;
97 }, 107 },
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 JSON.parse(JSON.stringify(this.componentExtensionImes)), 182 JSON.parse(JSON.stringify(this.componentExtensionImes)),
173 thirdPartyExtensionImes: [], 183 thirdPartyExtensionImes: [],
174 }); 184 });
175 }, 185 },
176 186
177 /** 187 /**
178 * Adds the input method to the current user's list of enabled input 188 * Adds the input method to the current user's list of enabled input
179 * methods, enabling the input method for the current user. Chrome OS only. 189 * methods, enabling the input method for the current user. Chrome OS only.
180 * @param {string} inputMethodId 190 * @param {string} inputMethodId
181 */ 191 */
182 addInputMethod: wrapAssertNotReached('addInputMethod'), 192 addInputMethod: function(inputMethodId) {
193 assert(cr.isChromeOS);
194 var inputMethod = this.componentExtensionImes.find(function(ime) {
195 return ime.id == inputMethodId;
196 });
197 assertTrue(!!inputMethod);
198 inputMethod.enabled = true;
199 var prefPath = 'prefs.settings.language.preload_engines.value';
200 var enabledInputMethods = this.settingsPrefs_.get(prefPath).split(',');
201 enabledInputMethods.push(inputMethodId);
202 this.settingsPrefs_.set(prefPath, enabledInputMethods.join(','))
203 },
183 204
184 /** 205 /**
185 * Removes the input method from the current user's list of enabled input 206 * Removes the input method from the current user's list of enabled input
186 * methods, disabling the input method for the current user. Chrome OS only. 207 * methods, disabling the input method for the current user. Chrome OS only.
187 * @param {string} inputMethodId 208 * @param {string} inputMethodId
188 */ 209 */
189 removeInputMethod: function(inputMethodId) { 210 removeInputMethod: function(inputMethodId) {
190 assert(cr.isChromeOS); 211 assert(cr.isChromeOS);
191 var inputMethod = this.componentExtensionImes.find(function(ime) { 212 var inputMethod = this.componentExtensionImes.find(function(ime) {
192 return ime.id == inputMethodId; 213 return ime.id == inputMethodId;
(...skipping 28 matching lines...) Expand all
221 242
222 /** 243 /**
223 * Called when an input method is removed. 244 * Called when an input method is removed.
224 * @type {!ChromeEvent} 245 * @type {!ChromeEvent}
225 */ 246 */
226 onInputMethodRemoved: new FakeChromeEvent(), 247 onInputMethodRemoved: new FakeChromeEvent(),
227 }; 248 };
228 249
229 return {FakeLanguageSettingsPrivate: FakeLanguageSettingsPrivate}; 250 return {FakeLanguageSettingsPrivate: FakeLanguageSettingsPrivate};
230 }); 251 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/languages_page/languages.js ('k') | chrome/test/data/webui/settings/languages_page_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698