Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / chromeos / third_party_ime_confirm_overlay.js
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.
4
5 cr.define('options', function() {
6   /** @const */ var OptionsPage = options.OptionsPage;
7   /** @const */ var SettingsDialog = options.SettingsDialog;
8
9   /**
10    * HomePageOverlay class
11    * Dialog that allows users to set the home page.
12    * @extends {SettingsDialog}
13    */
14   function ThirdPartyImeConfirmOverlay() {
15     SettingsDialog.call(
16         this, 'thirdPartyImeConfirm',
17         loadTimeData.getString('thirdPartyImeConfirmOverlayTabTitle'),
18         'third-party-ime-confirm-overlay',
19         $('third-party-ime-confirm-ok'),
20         $('third-party-ime-confirm-cancel'));
21   }
22
23   cr.addSingletonGetter(ThirdPartyImeConfirmOverlay);
24
25   ThirdPartyImeConfirmOverlay.prototype = {
26     __proto__: SettingsDialog.prototype,
27
28    /**
29     * Callback to authorize use of an input method.
30     * @type {Function}
31     * @private
32     */
33    confirmationCallback_: null,
34
35    /**
36     * Callback to cancel enabling an input method.
37     * @type {Function}
38     * @private
39     */
40    cancellationCallback_: null,
41
42     /**
43      * Confirms enabling of a third party IME.
44      */
45     handleConfirm: function() {
46       SettingsDialog.prototype.handleConfirm.call(this);
47       this.confirmationCallback_();
48     },
49
50     /**
51      * Resets state of the checkobx.
52      */
53     handleCancel: function() {
54       SettingsDialog.prototype.handleCancel.call(this);
55       this.cancellationCallback_();
56     },
57
58     /**
59      * Displays a confirmation dialog indicating the risk fo enabling
60      * a third party IME.
61      * @param {{extension: string, confirm: Function, cancel: Function}} data
62      *     Options for the confirmation dialog.
63      * @private
64      */
65     showConfirmationDialog_: function(data) {
66       this.confirmationCallback_ = data.confirm;
67       this.cancellationCallback_ = data.cancel;
68       var message = loadTimeData.getStringF('thirdPartyImeConfirmMessage',
69                                              data.extension);
70       $('third-party-ime-confirm-text').textContent = message;
71       OptionsPage.showPageByName(this.name, false);
72     },
73   };
74
75   /**
76    * Displays a confirmation dialog indicating the risk fo enabling
77    * a third party IME.
78    * @param {{extension: string, confirm: Function, cancel: Function}} data
79    *     Options for the confirmation dialog.
80    */
81   ThirdPartyImeConfirmOverlay.showConfirmationDialog = function(data) {
82     ThirdPartyImeConfirmOverlay.getInstance().showConfirmationDialog_(data);
83   };
84
85   // Export
86   return {
87     ThirdPartyImeConfirmOverlay: ThirdPartyImeConfirmOverlay
88   };
89 });