Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Side by Side Diff: chrome/browser/resources/options/content_settings.js

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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
7 var OptionsPage = options.OptionsPage;
8
9 //////////////////////////////////////////////////////////////////////////////
10 // ContentSettings class:
11
12 /**
13 * Encapsulated handling of content settings page.
14 * @constructor
15 */
16 function ContentSettings() {
17 this.activeNavTab = null;
18 OptionsPage.call(this, 'content', templateData.contentSettingsPageTabTitle,
19 'content-settings-page');
20 }
21
22 cr.addSingletonGetter(ContentSettings);
23
24 ContentSettings.prototype = {
25 __proto__: OptionsPage.prototype,
26
27 initializePage: function() {
28 OptionsPage.prototype.initializePage.call(this);
29
30 chrome.send('getContentFilterSettings');
31
32 var exceptionsButtons =
33 this.pageDiv.querySelectorAll('.exceptions-list-button');
34 for (var i = 0; i < exceptionsButtons.length; i++) {
35 exceptionsButtons[i].onclick = function(event) {
36 var page = ContentSettingsExceptionsArea.getInstance();
37 page.showList(
38 event.target.getAttribute('contentType'));
39 OptionsPage.navigateToPage('contentExceptions');
40 // Add on the proper hash for the content type, and store that in the
41 // history so back/forward and tab restore works.
42 var hash = event.target.getAttribute('contentType');
43 window.history.replaceState({pageName: page.name}, page.title,
44 '/' + page.name + "#" + hash);
45 };
46 }
47
48 var manageHandlersButton = $('manage-handlers-button');
49 if (manageHandlersButton) {
50 manageHandlersButton.onclick = function(event) {
51 OptionsPage.navigateToPage('handlers');
52 };
53 }
54
55 // Cookies filter page ---------------------------------------------------
56 $('show-cookies-button').onclick = function(event) {
57 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']);
58 OptionsPage.navigateToPage('cookies');
59 };
60
61 // Remove from DOM instead of hiding so :last-of-type applies the style
62 // correctly.
63 var intentsSection = $('intents-section');
64 if (!templateData.enable_web_intents && intentsSection)
65 intentsSection.parentNode.removeChild(intentsSection);
66 },
67 };
68
69 ContentSettings.updateHandlersEnabledRadios = function(enabled) {
70 var selector = '#content-settings-page input[type=radio][value=' +
71 (enabled ? 'allow' : 'block') + '].handler-radio';
72 document.querySelector(selector).checked = true;
73 };
74
75 /**
76 * Sets the values for all the content settings radios.
77 * @param {Object} dict A mapping from radio groups to the checked value for
78 * that group.
79 */
80 ContentSettings.setContentFilterSettingsValue = function(dict) {
81 for (var group in dict) {
82 document.querySelector('input[type=radio][name=' + group + '][value=' +
83 dict[group]['value'] + ']').checked = true;
84 var radios = document.querySelectorAll('input[type=radio][name=' +
85 group + ']');
86 var managedBy = dict[group]['managedBy'];
87 for (var i = 0, len = radios.length; i < len; i++) {
88 radios[i].disabled = (managedBy != 'default');
89 radios[i].controlledBy = managedBy;
90 }
91 }
92 OptionsPage.updateManagedBannerVisibility();
93 };
94
95 /**
96 * Initializes an exceptions list.
97 * @param {string} type The content type that we are setting exceptions for.
98 * @param {Array} list An array of pairs, where the first element of each pair
99 * is the filter string, and the second is the setting (allow/block).
100 */
101 ContentSettings.setExceptions = function(type, list) {
102 var exceptionsList =
103 document.querySelector('div[contentType=' + type + ']' +
104 ' list[mode=normal]');
105 exceptionsList.setExceptions(list);
106 };
107
108 ContentSettings.setHandlers = function(list) {
109 $('handlers-list').setHandlers(list);
110 };
111
112 ContentSettings.setIgnoredHandlers = function(list) {
113 $('ignored-handlers-list').setHandlers(list);
114 };
115
116 ContentSettings.setOTRExceptions = function(type, list) {
117 var exceptionsList =
118 document.querySelector('div[contentType=' + type + ']' +
119 ' list[mode=otr]');
120
121 exceptionsList.parentNode.hidden = false;
122 exceptionsList.setExceptions(list);
123 };
124
125 /**
126 * The browser's response to a request to check the validity of a given URL
127 * pattern.
128 * @param {string} type The content type.
129 * @param {string} mode The browser mode.
130 * @param {string} pattern The pattern.
131 * @param {bool} valid Whether said pattern is valid in the context of
132 * a content exception setting.
133 */
134 ContentSettings.patternValidityCheckComplete =
135 function(type, mode, pattern, valid) {
136 var exceptionsList =
137 document.querySelector('div[contentType=' + type + '] ' +
138 'list[mode=' + mode + ']');
139 exceptionsList.patternValidityCheckComplete(pattern, valid);
140 };
141
142 // Export
143 return {
144 ContentSettings: ContentSettings
145 };
146
147 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698