Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / resources / options / chromeos / third_party_ime_confirm_overlay.js
blob1f2d6c3eaf4ff69cf58be881b2a89b712a01b96f
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr.define('options', function() {
6   /** @const */ var PageManager = cr.ui.pageManager.PageManager;
7   /** @const */ var SettingsDialog = options.SettingsDialog;
9   /**
10    * HomePageOverlay class
11    * Dialog that allows users to set the home page.
12    * @constructor
13    * @extends {options.SettingsDialog}
14    */
15   function ThirdPartyImeConfirmOverlay() {
16     SettingsDialog.call(
17         this, 'thirdPartyImeConfirm',
18         loadTimeData.getString('thirdPartyImeConfirmOverlayTabTitle'),
19         'third-party-ime-confirm-overlay',
20         assertInstanceof($('third-party-ime-confirm-ok'), HTMLButtonElement),
21         assertInstanceof($('third-party-ime-confirm-cancel'),
22                          HTMLButtonElement));
23   }
25   cr.addSingletonGetter(ThirdPartyImeConfirmOverlay);
27   ThirdPartyImeConfirmOverlay.prototype = {
28     __proto__: SettingsDialog.prototype,
30    /**
31     * Callback to authorize use of an input method.
32     * @type {Function}
33     * @private
34     */
35    confirmationCallback_: null,
37    /**
38     * Callback to cancel enabling an input method.
39     * @type {Function}
40     * @private
41     */
42    cancellationCallback_: null,
44     /**
45      * Confirms enabling of a third party IME.
46      */
47     handleConfirm: function() {
48       SettingsDialog.prototype.handleConfirm.call(this);
49       this.confirmationCallback_();
50     },
52     /**
53      * Resets state of the checkobx.
54      */
55     handleCancel: function() {
56       SettingsDialog.prototype.handleCancel.call(this);
57       this.cancellationCallback_();
58     },
60     /**
61      * Displays a confirmation dialog indicating the risk fo enabling
62      * a third party IME.
63      * @param {{extension: string, confirm: Function, cancel: Function}} data
64      *     Options for the confirmation dialog.
65      * @private
66      */
67     showConfirmationDialog_: function(data) {
68       this.confirmationCallback_ = data.confirm;
69       this.cancellationCallback_ = data.cancel;
70       var message = loadTimeData.getStringF('thirdPartyImeConfirmMessage',
71                                              data.extension);
72       $('third-party-ime-confirm-text').textContent = message;
73       PageManager.showPageByName(this.name, false);
74     },
75   };
77   /**
78    * Displays a confirmation dialog indicating the risk fo enabling
79    * a third party IME.
80    * @param {{extension: string, confirm: Function, cancel: Function}} data
81    *     Options for the confirmation dialog.
82    */
83   ThirdPartyImeConfirmOverlay.showConfirmationDialog = function(data) {
84     ThirdPartyImeConfirmOverlay.getInstance().showConfirmationDialog_(data);
85   };
87   // Export
88   return {
89     ThirdPartyImeConfirmOverlay: ThirdPartyImeConfirmOverlay
90   };
91 });