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

Side by Side Diff: chrome/browser/resources/options/language_options.js

Issue 325633003: Add confirmation dialog when enabling a 3rd party IME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // TODO(kochi): Generalize the notification as a component and put it 5 // TODO(kochi): Generalize the notification as a component and put it
6 // in js/cr/ui/notification.js . 6 // in js/cr/ui/notification.js .
7 7
8 cr.define('options', function() { 8 cr.define('options', function() {
9 /** @const */ var OptionsPage = options.OptionsPage; 9 /** @const */ var OptionsPage = options.OptionsPage;
10 /** @const */ var LanguageList = options.LanguageList; 10 /** @const */ var LanguageList = options.LanguageList;
11 /** @const */ var ThirdPartyImeConfirmOverlay =
12 options.ThirdPartyImeConfirmOverlay;
11 13
12 /** 14 /**
13 * Spell check dictionary download status. 15 * Spell check dictionary download status.
14 * @type {Enum} 16 * @type {Enum}
15 */ 17 */
16 /** @const*/ var DOWNLOAD_STATUS = { 18 /** @const*/ var DOWNLOAD_STATUS = {
17 IN_PROGRESS: 1, 19 IN_PROGRESS: 1,
18 FAILED: 2 20 FAILED: 2
19 }; 21 };
20 22
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 var inputMethodTemplate = $('language-options-input-method-template'); 313 var inputMethodTemplate = $('language-options-input-method-template');
312 314
313 for (var i = 0; i < inputMethods.length; i++) { 315 for (var i = 0; i < inputMethods.length; i++) {
314 var inputMethod = inputMethods[i]; 316 var inputMethod = inputMethods[i];
315 var element = inputMethodTemplate.cloneNode(true); 317 var element = inputMethodTemplate.cloneNode(true);
316 element.id = ''; 318 element.id = '';
317 element.languageCodeSet = inputMethod.languageCodeSet; 319 element.languageCodeSet = inputMethod.languageCodeSet;
318 320
319 var input = element.querySelector('input'); 321 var input = element.querySelector('input');
320 input.inputMethodId = inputMethod.id; 322 input.inputMethodId = inputMethod.id;
323 input.imeProvider = inputMethod.extensionName;
321 var span = element.querySelector('span'); 324 var span = element.querySelector('span');
322 span.textContent = inputMethod.displayName; 325 span.textContent = inputMethod.displayName;
323 326
324 if (inputMethod.optionsPage) { 327 if (inputMethod.optionsPage) {
325 var button = document.createElement('button'); 328 var button = document.createElement('button');
326 button.textContent = loadTimeData.getString('configure'); 329 button.textContent = loadTimeData.getString('configure');
327 button.inputMethodId = inputMethod.id; 330 button.inputMethodId = inputMethod.id;
328 button.onclick = function(inputMethodId, e) { 331 button.onclick = function(inputMethodId, e) {
329 chrome.send('inputMethodOptionsOpen', [inputMethodId]); 332 chrome.send('inputMethodOptionsOpen', [inputMethodId]);
330 }.bind(this, inputMethod.id); 333 }.bind(this, inputMethod.id);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 }, 819 },
817 820
818 /** 821 /**
819 * Handles input method checkbox's click event. 822 * Handles input method checkbox's click event.
820 * @param {Event} e Click event. 823 * @param {Event} e Click event.
821 * @private 824 * @private
822 */ 825 */
823 handleCheckboxClick_: function(e) { 826 handleCheckboxClick_: function(e) {
824 var checkbox = e.target; 827 var checkbox = e.target;
825 828
829 // Third party IMEs require additional confirmation prior to enabling due
830 // to privacy risk.
831 if (/^_ext_ime_/.test(checkbox.inputMethodId) && checkbox.checked) {
832 var confirmationCallback = this.handleCheckboxUpdate_.bind(this,
833 checkbox);
834 var cancellationCallback = function() {
835 checkbox.checked = false;
836 };
837 ThirdPartyImeConfirmOverlay.showConfirmationDialog({
838 extension: checkbox.imeProvider,
839 confirm: confirmationCallback,
840 cancel: cancellationCallback
841 });
842 } else {
843 this.handleCheckboxUpdate_(checkbox);
844 }
845 },
846
847 /**
848 * Updates active IMEs based on change in state of a checkbox for an input
849 * method.
850 * @param {!Element} checkbox Updated checkbox element.
851 * @private
852 */
853 handleCheckboxUpdate_: function(checkbox) {
826 if (checkbox.inputMethodId.match(/^_ext_ime_/)) { 854 if (checkbox.inputMethodId.match(/^_ext_ime_/)) {
827 this.updateEnabledExtensionsFromCheckboxes_(); 855 this.updateEnabledExtensionsFromCheckboxes_();
828 this.saveEnabledExtensionPref_(); 856 this.saveEnabledExtensionPref_();
829 return; 857 return;
830 } 858 }
831 if (this.preloadEngines_.length == 1 && !checkbox.checked) { 859 if (this.preloadEngines_.length == 1 && !checkbox.checked) {
832 // Don't allow disabling the last input method. 860 // Don't allow disabling the last input method.
833 this.showNotification_( 861 this.showNotification_(
834 loadTimeData.getString('pleaseAddAnotherInputMethod'), 862 loadTimeData.getString('pleaseAddAnotherInputMethod'),
835 loadTimeData.getString('okButton')); 863 loadTimeData.getString('okButton'));
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1356
1329 LanguageOptions.onComponentManagerInitialized = function(componentImes) { 1357 LanguageOptions.onComponentManagerInitialized = function(componentImes) {
1330 LanguageOptions.getInstance().appendComponentExtensionIme_(componentImes); 1358 LanguageOptions.getInstance().appendComponentExtensionIme_(componentImes);
1331 }; 1359 };
1332 1360
1333 // Export 1361 // Export
1334 return { 1362 return {
1335 LanguageOptions: LanguageOptions 1363 LanguageOptions: LanguageOptions
1336 }; 1364 };
1337 }); 1365 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698