• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2011 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
5cr.define('options', function() {
6
7  //////////////////////////////////////////////////////////////////////////////
8  // ContentSettingsRadio class:
9
10  // Define a constructor that uses an input element as its underlying element.
11  var ContentSettingsRadio = cr.ui.define('input');
12
13  ContentSettingsRadio.prototype = {
14    __proto__: HTMLInputElement.prototype,
15
16    /**
17     * Initialization function for the cr.ui framework.
18     */
19    decorate: function() {
20      this.type = 'radio';
21      var self = this;
22
23      this.addEventListener('change',
24          function(e) {
25            chrome.send('setContentFilter', [this.name, this.value]);
26          });
27    },
28  };
29
30  /**
31   * Whether the content setting is controlled by something else than the user's
32   * settings (either 'policy' or 'extension').
33   * @type {string}
34   */
35  cr.defineProperty(ContentSettingsRadio, 'controlledBy', cr.PropertyKind.ATTR);
36
37  //////////////////////////////////////////////////////////////////////////////
38  // HandlersEnabledRadio class:
39
40  // Define a constructor that uses an input element as its underlying element.
41  var HandlersEnabledRadio = cr.ui.define('input');
42
43  HandlersEnabledRadio.prototype = {
44    __proto__: HTMLInputElement.prototype,
45
46    /**
47     * Initialization function for the cr.ui framework.
48     */
49    decorate: function() {
50      this.type = 'radio';
51      var self = this;
52
53      this.addEventListener('change',
54          function(e) {
55            chrome.send('setHandlersEnabled', [this.value == 'allow']);
56          });
57    },
58  };
59
60  // Export
61  return {
62    ContentSettingsRadio: ContentSettingsRadio,
63    HandlersEnabledRadio: HandlersEnabledRadio
64  };
65
66});
67
68