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

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: 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 (!!checkbox.imeProvider && checkbox.checked) {
Dan Beam 2014/06/09 21:37:36 you don't need the !!
Shu Chen 2014/06/10 01:02:18 I think it would be safer to check IME ID instead
kevers 2014/06/10 17:56:44 Done.
832 var self = this;
833 var confirmationCallback = function() {
834 self.handleCheckboxUpdate_(checkbox);
835 };
Dan Beam 2014/06/09 21:37:36 nit: var confirmationCallback = this.handleCheckbo
kevers 2014/06/10 17:56:44 Done.
836 var cancellationCallback = function() {
837 checkbox.checked = false;
838 }
Dan Beam 2014/06/09 21:37:36 };
kevers 2014/06/10 17:56:44 Done.
839 ThirdPartyImeConfirmOverlay.showConfirmationDialog({
840 extension: checkbox.imeProvider,
841 confirm: confirmationCallback,
842 cancel: cancellationCallback
843 });
844 } else {
845 this.handleCheckboxUpdate_(checkbox);
846 }
847 },
848
849 /**
850 * Updates active IMEs based on change in state of a checkbox for an input
851 * method.
852 * @param {!Element} checkbox Updated checkbox element.
853 * @private
854 */
855 handleCheckboxUpdate_: function(checkbox) {
826 if (checkbox.inputMethodId.match(/^_ext_ime_/)) { 856 if (checkbox.inputMethodId.match(/^_ext_ime_/)) {
827 this.updateEnabledExtensionsFromCheckboxes_(); 857 this.updateEnabledExtensionsFromCheckboxes_();
828 this.saveEnabledExtensionPref_(); 858 this.saveEnabledExtensionPref_();
829 return; 859 return;
830 } 860 }
831 if (this.preloadEngines_.length == 1 && !checkbox.checked) { 861 if (this.preloadEngines_.length == 1 && !checkbox.checked) {
832 // Don't allow disabling the last input method. 862 // Don't allow disabling the last input method.
833 this.showNotification_( 863 this.showNotification_(
834 loadTimeData.getString('pleaseAddAnotherInputMethod'), 864 loadTimeData.getString('pleaseAddAnotherInputMethod'),
835 loadTimeData.getString('okButton')); 865 loadTimeData.getString('okButton'));
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1358
1329 LanguageOptions.onComponentManagerInitialized = function(componentImes) { 1359 LanguageOptions.onComponentManagerInitialized = function(componentImes) {
1330 LanguageOptions.getInstance().appendComponentExtensionIme_(componentImes); 1360 LanguageOptions.getInstance().appendComponentExtensionIme_(componentImes);
1331 }; 1361 };
1332 1362
1333 // Export 1363 // Export
1334 return { 1364 return {
1335 LanguageOptions: LanguageOptions 1365 LanguageOptions: LanguageOptions
1336 }; 1366 };
1337 }); 1367 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698