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

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

Issue 543983005: Add a dropdown to change the default content setting to the Website Settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CrOS build error. 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
9 9
10 // Lookup table to generate the i18n strings.
11 /** @const */ var permissionsLookup = {
12 'geolocation': 'location',
13 'notifications': 'notifications',
14 'media-stream': 'mediaStream',
15 'cookies': 'cookies',
16 'multiple-automatic-downloads': 'multipleAutomaticDownloads',
17 'images': 'images',
18 'plugins': 'plugins',
19 'popups': 'popups',
20 'javascript': 'javascript'
21 };
22
10 ///////////////////////////////////////////////////////////////////////////// 23 /////////////////////////////////////////////////////////////////////////////
11 // WebsiteSettingsManager class: 24 // WebsiteSettingsManager class:
12 25
13 /** 26 /**
14 * Encapsulated handling of the website settings page. 27 * Encapsulated handling of the website settings page.
15 * @constructor 28 * @constructor
16 */ 29 */
17 function WebsiteSettingsManager() { 30 function WebsiteSettingsManager() {
18 Page.call(this, 'websiteSettings', 31 Page.call(this, 'websiteSettings',
19 loadTimeData.getString('websitesOptionsPageTabTitle'), 32 loadTimeData.getString('websitesOptionsPageTabTitle'),
(...skipping 25 matching lines...) Expand all
45 58
46 $('website-settings-overlay-confirm').onclick = 59 $('website-settings-overlay-confirm').onclick =
47 PageManager.closeOverlay.bind(PageManager); 60 PageManager.closeOverlay.bind(PageManager);
48 61
49 $('resourceType').onchange = function(event) { 62 $('resourceType').onchange = function(event) {
50 var target = event.target; 63 var target = event.target;
51 assert(target.tagName == 'SELECT'); 64 assert(target.tagName == 'SELECT');
52 WebsiteSettingsManager.getInstance().updatePage_(target.value); 65 WebsiteSettingsManager.getInstance().updatePage_(target.value);
53 }; 66 };
54 67
68 $('global-setting').onchange = function(event) {
69 chrome.send('setDefaultContentSetting', [this.value]);
70 };
71
55 var searchBox = $('website-settings-search-box'); 72 var searchBox = $('website-settings-search-box');
56 searchBox.addEventListener('search', 73 searchBox.addEventListener('search',
57 this.handleSearchQueryChange_.bind(this)); 74 this.handleSearchQueryChange_.bind(this));
58 75
59 searchBox.onkeydown = function(e) { 76 searchBox.onkeydown = function(e) {
60 if (e.keyIdentifier == 'Enter') 77 if (e.keyIdentifier == 'Enter')
61 e.preventDefault(); 78 e.preventDefault();
62 }; 79 };
63 80
64 this.createOriginsList_(); 81 this.createOriginsList_();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 */ 180 */
164 handleSearchQueryChange_: function(e) { 181 handleSearchQueryChange_: function(e) {
165 if (this.queryDelayTimerId_) 182 if (this.queryDelayTimerId_)
166 window.clearTimeout(this.queryDelayTimerId_); 183 window.clearTimeout(this.queryDelayTimerId_);
167 184
168 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this), 185 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this),
169 160); 186 160);
170 }, 187 },
171 188
172 /** 189 /**
190 * Sets the default content setting dropdown on the page to the current
191 * default.
192 * @param {!Object} dict A dictionary with the management and value of the
193 * default setting for the last selected content setting..
194 */
195 updateDefault: function(dict) {
196 // TODO(dhnishi): Remove duplicate default handling in the Content
197 // Settings page and here.
198 var managedBy = dict.managedBy;
199 var controlledBy = managedBy == 'policy' || managedBy == 'extension' ?
200 managedBy : null;
201 $('global-setting').disabled = (managedBy != 'default');
202
203 var options = $('global-setting').options;
204 for (var i = 0; i < options.length; i++) {
205 if (options[i].value == dict.value) {
206 options.selectedIndex = i;
207 }
208 }
209 },
210
211 /**
173 * Updates the page with the given content setting or resource name's 212 * Updates the page with the given content setting or resource name's
174 * information. 213 * information.
175 * @param {string} typeName The name of the content setting or resource. 214 * @param {string} typeName The name of the content setting or resource.
176 */ 215 */
177 updatePage_: function(typeName) { 216 updatePage_: function(typeName) {
178 if (typeName == 'storage') 217 if (typeName == 'storage')
179 chrome.send('updateLocalStorage'); 218 chrome.send('updateLocalStorage');
180 else if (typeName == 'battery') 219 else if (typeName == 'battery')
181 chrome.send('updateBatteryUsage'); 220 chrome.send('updateBatteryUsage');
182 else 221 else
183 chrome.send('updateOrigins', [typeName]); 222 chrome.send('updateOrigins', [typeName]);
223
224 var options = $('global-setting').options;
225 options.length = 0;
226 var permissionString = permissionsLookup[typeName];
227 var permissions = ['Allow', 'Ask', 'Block'];
228 for (var i = 0; i < permissions.length; i++) {
229 var valueId = permissionString + permissions[i];
230 if (loadTimeData.valueExists(valueId)) {
231 options.add(new Option(loadTimeData.getString(valueId),
232 permissions[i].toLowerCase()));
233 }
234 }
235 if (options.length == 0) {
236 $('website-settings-global-controls').hidden = true;
237 } else {
238 $('website-settings-global-controls').hidden = false;
239 chrome.send('updateDefaultSetting');
240 }
184 } 241 }
185 }; 242 };
186 243
187 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) { 244 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) {
188 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, 245 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict,
189 blockedDict); 246 blockedDict);
190 }; 247 };
191 248
192 WebsiteSettingsManager.showEditPage = function(url) { 249 WebsiteSettingsManager.updateDefault = function(dict) {
193 WebsiteSettingsEditor.getInstance().populatePage(url); 250 WebsiteSettingsManager.getInstance().updateDefault(dict);
194 }; 251 };
195 252
196 // Export 253 // Export
197 return { 254 return {
198 WebsiteSettingsManager: WebsiteSettingsManager 255 WebsiteSettingsManager: WebsiteSettingsManager
199 }; 256 };
200 }); 257 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/website_settings.html ('k') | chrome/browser/resources/options/website_settings_edit_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698