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   */
34  cr.defineProperty(ContentSettingsRadio, 'controlledBy', cr.PropertyKind.ATTR);
35
36  //////////////////////////////////////////////////////////////////////////////
37  // HandlersEnabledRadio class:
38
39  // Define a constructor that uses an input element as its underlying element.
40  var HandlersEnabledRadio = cr.ui.define('input');
41
42  HandlersEnabledRadio.prototype = {
43    __proto__: HTMLInputElement.prototype,
44
45    /**
46     * Initialization function for the cr.ui framework.
47     */
48    decorate: function() {
49      this.type = 'radio';
50      var self = this;
51
52      this.addEventListener('change',
53          function(e) {
54            chrome.send('setHandlersEnabled', [this.value == 'allow']);
55          });
56    },
57  };
58
59  // Export
60  return {
61    ContentSettingsRadio: ContentSettingsRadio,
62    HandlersEnabledRadio: HandlersEnabledRadio
63  };
64
65});
66
67