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

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

Issue 566863005: Expose the Website Settings page in the Content Setting page if it is enabled via flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handler strings are handled elsewhere. Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 8
9 // Lookup table to generate the i18n strings.
10 /** @const */ var permissionsLookup = {
11 'location': 'location',
12 'notifications': 'notifications',
13 'media-stream': 'mediaStream',
14 'cookies': 'cookies',
15 'multiple-automatic-downloads': 'multipleAutomaticDownloads',
16 'images': 'images',
17 'plugins': 'plugins',
18 'popups': 'popups',
19 'javascript': 'javascript'
20 };
21
9 ////////////////////////////////////////////////////////////////////////////// 22 //////////////////////////////////////////////////////////////////////////////
10 // ContentSettings class: 23 // ContentSettings class:
11 24
12 /** 25 /**
13 * Encapsulated handling of content settings page. 26 * Encapsulated handling of content settings page.
14 * @constructor 27 * @constructor
15 */ 28 */
16 function ContentSettings() { 29 function ContentSettings() {
17 this.activeNavTab = null; 30 this.activeNavTab = null;
18 Page.call(this, 'content', 31 Page.call(this, 'content',
(...skipping 13 matching lines...) Expand all
32 var exceptionsButtons = 45 var exceptionsButtons =
33 this.pageDiv.querySelectorAll('.exceptions-list-button'); 46 this.pageDiv.querySelectorAll('.exceptions-list-button');
34 for (var i = 0; i < exceptionsButtons.length; i++) { 47 for (var i = 0; i < exceptionsButtons.length; i++) {
35 exceptionsButtons[i].onclick = function(event) { 48 exceptionsButtons[i].onclick = function(event) {
36 var hash = event.currentTarget.getAttribute('contentType'); 49 var hash = event.currentTarget.getAttribute('contentType');
37 PageManager.showPageByName('contentExceptions', true, 50 PageManager.showPageByName('contentExceptions', true,
38 {hash: '#' + hash}); 51 {hash: '#' + hash});
39 }; 52 };
40 } 53 }
41 54
55 var experimentalExceptionsButtons =
56 this.pageDiv.querySelectorAll('.website-settings-permission-button');
57 for (var i = 0; i < experimentalExceptionsButtons.length; i++) {
58 experimentalExceptionsButtons[i].onclick = function(event) {
59 var page = WebsiteSettingsManager.getInstance();
60 var hash = event.currentTarget.getAttribute('contentType');
61 var url = page.name + '#' + hash;
62 uber.pushState({pageName: page.name}, url);
63
64 // Navigate after the local history has been replaced in order to have
65 // the correct hash loaded.
66 PageManager.showPageByName('websiteSettings', false);
67 };
68 }
69
42 var manageHandlersButton = $('manage-handlers-button'); 70 var manageHandlersButton = $('manage-handlers-button');
43 if (manageHandlersButton) { 71 if (manageHandlersButton) {
44 manageHandlersButton.onclick = function(event) { 72 manageHandlersButton.onclick = function(event) {
45 PageManager.showPageByName('handlers'); 73 PageManager.showPageByName('handlers');
46 }; 74 };
47 } 75 }
48 76
49 if (cr.isChromeOS) { 77 if (cr.isChromeOS) {
50 // Disable some controls for Guest in Chrome OS. 78 // Disable some controls for Guest in Chrome OS.
51 UIAccountTweaks.applyGuestSessionVisibility(document); 79 UIAccountTweaks.applyGuestSessionVisibility(document);
(...skipping 11 matching lines...) Expand all
63 $('content-settings-overlay-confirm').onclick = 91 $('content-settings-overlay-confirm').onclick =
64 PageManager.closeOverlay.bind(PageManager); 92 PageManager.closeOverlay.bind(PageManager);
65 93
66 $('media-pepper-flash-default').hidden = true; 94 $('media-pepper-flash-default').hidden = true;
67 $('media-pepper-flash-exceptions').hidden = true; 95 $('media-pepper-flash-exceptions').hidden = true;
68 96
69 $('media-select-mic').addEventListener('change', 97 $('media-select-mic').addEventListener('change',
70 ContentSettings.setDefaultMicrophone_); 98 ContentSettings.setDefaultMicrophone_);
71 $('media-select-camera').addEventListener('change', 99 $('media-select-camera').addEventListener('change',
72 ContentSettings.setDefaultCamera_); 100 ContentSettings.setDefaultCamera_);
101
102 if (loadTimeData.getBoolean('websiteSettingsManagerEnabled')) {
103 var oldUI =
104 this.pageDiv.querySelectorAll('.replace-with-website-settings');
105 for (var i = 0; i < oldUI.length; i++) {
106 oldUI[i].hidden = true;
107 }
108
109 var newUI =
110 this.pageDiv.querySelectorAll('.experimental-website-settings');
111 for (var i = 0; i < newUI.length; i++) {
112 newUI[i].hidden = false;
113 }
114 }
73 }, 115 },
74 }; 116 };
75 117
76 ContentSettings.updateHandlersEnabledRadios = function(enabled) { 118 ContentSettings.updateHandlersEnabledRadios = function(enabled) {
77 var selector = '#content-settings-page input[type=radio][value=' + 119 var selector = '#content-settings-page input[type=radio][value=' +
78 (enabled ? 'allow' : 'block') + '].handler-radio'; 120 (enabled ? 'allow' : 'block') + '].handler-radio';
79 document.querySelector(selector).checked = true; 121 document.querySelector(selector).checked = true;
80 }; 122 };
81 123
82 /** 124 /**
83 * Sets the values for all the content settings radios. 125 * Sets the values for all the content settings radios and labels.
84 * @param {Object} dict A mapping from radio groups to the checked value for 126 * @param {Object} dict A mapping from radio groups to the checked value for
85 * that group. 127 * that group.
86 */ 128 */
87 ContentSettings.setContentFilterSettingsValue = function(dict) { 129 ContentSettings.setContentFilterSettingsValue = function(dict) {
88 for (var group in dict) { 130 for (var group in dict) {
131 var settingLabel = $(group + '-default-string');
132 if (settingLabel) {
133 var value = dict[group].value;
134 var valueId =
135 permissionsLookup[group] + value[0].toUpperCase() + value.slice(1);
136 settingLabel.textContent = loadTimeData.getString(valueId);
137 }
138
89 var managedBy = dict[group].managedBy; 139 var managedBy = dict[group].managedBy;
90 var controlledBy = managedBy == 'policy' || managedBy == 'extension' ? 140 var controlledBy = managedBy == 'policy' || managedBy == 'extension' ?
91 managedBy : null; 141 managedBy : null;
92 document.querySelector('input[type=radio][name=' + group + '][value=' + 142 document.querySelector('input[type=radio][name=' + group + '][value=' +
93 dict[group].value + ']').checked = true; 143 dict[group].value + ']').checked = true;
94 var radios = document.querySelectorAll('input[type=radio][name=' + 144 var radios = document.querySelectorAll('input[type=radio][name=' +
95 group + ']'); 145 group + ']');
96 for (var i = 0, len = radios.length; i < len; i++) { 146 for (var i = 0, len = radios.length; i < len; i++) {
97 radios[i].disabled = (managedBy != 'default'); 147 radios[i].disabled = (managedBy != 'default');
98 radios[i].controlledBy = controlledBy; 148 radios[i].controlledBy = controlledBy;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 var deviceSelect = $('media-select-camera'); 347 var deviceSelect = $('media-select-camera');
298 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); 348 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]);
299 }; 349 };
300 350
301 // Export 351 // Export
302 return { 352 return {
303 ContentSettings: ContentSettings 353 ContentSettings: ContentSettings
304 }; 354 };
305 355
306 }); 356 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings.html ('k') | chrome/browser/resources/options/options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698