summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/options/chromeos/third_party_ime_confirm_overlay.js
blob: 1f2d6c3eaf4ff69cf58be881b2a89b712a01b96f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

cr.define('options', function() {
  /** @const */ var PageManager = cr.ui.pageManager.PageManager;
  /** @const */ var SettingsDialog = options.SettingsDialog;

  /**
   * HomePageOverlay class
   * Dialog that allows users to set the home page.
   * @constructor
   * @extends {options.SettingsDialog}
   */
  function ThirdPartyImeConfirmOverlay() {
    SettingsDialog.call(
        this, 'thirdPartyImeConfirm',
        loadTimeData.getString('thirdPartyImeConfirmOverlayTabTitle'),
        'third-party-ime-confirm-overlay',
        assertInstanceof($('third-party-ime-confirm-ok'), HTMLButtonElement),
        assertInstanceof($('third-party-ime-confirm-cancel'),
                         HTMLButtonElement));
  }

  cr.addSingletonGetter(ThirdPartyImeConfirmOverlay);

  ThirdPartyImeConfirmOverlay.prototype = {
    __proto__: SettingsDialog.prototype,

   /**
    * Callback to authorize use of an input method.
    * @type {Function}
    * @private
    */
   confirmationCallback_: null,

   /**
    * Callback to cancel enabling an input method.
    * @type {Function}
    * @private
    */
   cancellationCallback_: null,

    /**
     * Confirms enabling of a third party IME.
     */
    handleConfirm: function() {
      SettingsDialog.prototype.handleConfirm.call(this);
      this.confirmationCallback_();
    },

    /**
     * Resets state of the checkobx.
     */
    handleCancel: function() {
      SettingsDialog.prototype.handleCancel.call(this);
      this.cancellationCallback_();
    },

    /**
     * Displays a confirmation dialog indicating the risk fo enabling
     * a third party IME.
     * @param {{extension: string, confirm: Function, cancel: Function}} data
     *     Options for the confirmation dialog.
     * @private
     */
    showConfirmationDialog_: function(data) {
      this.confirmationCallback_ = data.confirm;
      this.cancellationCallback_ = data.cancel;
      var message = loadTimeData.getStringF('thirdPartyImeConfirmMessage',
                                             data.extension);
      $('third-party-ime-confirm-text').textContent = message;
      PageManager.showPageByName(this.name, false);
    },
  };

  /**
   * Displays a confirmation dialog indicating the risk fo enabling
   * a third party IME.
   * @param {{extension: string, confirm: Function, cancel: Function}} data
   *     Options for the confirmation dialog.
   */
  ThirdPartyImeConfirmOverlay.showConfirmationDialog = function(data) {
    ThirdPartyImeConfirmOverlay.getInstance().showConfirmationDialog_(data);
  };

  // Export
  return {
    ThirdPartyImeConfirmOverlay: ThirdPartyImeConfirmOverlay
  };
});