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

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

Issue 542203003: Split the Website Settings page's origin list into Allowed and Blocked lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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 ///////////////////////////////////////////////////////////////////////////// 10 /////////////////////////////////////////////////////////////////////////////
11 // WebsiteSettingsManager class: 11 // WebsiteSettingsManager class:
12 12
13 /** 13 /**
14 * Encapsulated handling of the website settings page. 14 * Encapsulated handling of the website settings page.
15 * @constructor 15 * @constructor
16 */ 16 */
17 function WebsiteSettingsManager() { 17 function WebsiteSettingsManager() {
18 Page.call(this, 'websiteSettings', 18 Page.call(this, 'websiteSettings',
19 loadTimeData.getString('websitesOptionsPageTabTitle'), 19 loadTimeData.getString('websitesOptionsPageTabTitle'),
20 'website-settings-page'); 20 'website-settings-page');
21 } 21 }
22 22
23 cr.addSingletonGetter(WebsiteSettingsManager); 23 cr.addSingletonGetter(WebsiteSettingsManager);
24 24
25 WebsiteSettingsManager.prototype = { 25 WebsiteSettingsManager.prototype = {
26 __proto__: Page.prototype, 26 __proto__: Page.prototype,
27 27
28 /** 28 /**
29 * The saved origins list. 29 * The saved allowed origins list.
30 * @type {OriginList} 30 * @type {OriginList}
31 * @private 31 * @private
32 */ 32 */
33 originList_: null, 33 allowedList_: null,
34
35 /**
36 * The saved blocked origins list.
37 * @type {OriginList}
38 * @private
39 */
40 blockedList_: null,
34 41
35 /** @override */ 42 /** @override */
36 initializePage: function() { 43 initializePage: function() {
37 Page.prototype.initializePage.call(this); 44 Page.prototype.initializePage.call(this);
38 45
39 $('website-settings-overlay-confirm').onclick = 46 $('website-settings-overlay-confirm').onclick =
40 PageManager.closeOverlay.bind(PageManager); 47 PageManager.closeOverlay.bind(PageManager);
41 48
42 $('resourceType').onchange = function() { 49 $('resourceType').onchange = function() {
43 var target = event.target; 50 var target = event.target;
(...skipping 17 matching lines...) Expand all
61 68
62 this.createOriginsList_(); 69 this.createOriginsList_();
63 chrome.send('updateOrigins', ['geolocation']); 70 chrome.send('updateOrigins', ['geolocation']);
64 }, 71 },
65 72
66 /** 73 /**
67 * Creates, decorates and initializes the origin list. 74 * Creates, decorates and initializes the origin list.
68 * @private 75 * @private
69 */ 76 */
70 createOriginsList_: function() { 77 createOriginsList_: function() {
71 this.originList_ = this.pageDiv.querySelector('.origin-list'); 78 this.allowedList_ = $('allowed-origin-list');
72 options.OriginList.decorate(this.originList_); 79 options.OriginList.decorate(this.allowedList_);
73 this.originList_.autoExpands = true; 80 this.allowedList_.autoExpands = true;
81
82 this.blockedList_ = $('blocked-origin-list');
83 options.OriginList.decorate(this.blockedList_);
84 this.blockedList_.autoExpands = true;
74 }, 85 },
75 86
76 /** 87 /**
77 * Populate the origin list with all of the origins with a given permission 88 * Populate an origin list with all of the origins with a given permission
78 * or that are using a given resource. 89 * or that are using a given resource.
90 * @param {OriginList} originList A list to populate.
79 * @param {!Object} originDict A dictionary of origins to their usage, which 91 * @param {!Object} originDict A dictionary of origins to their usage, which
80 will be used to sort the origins. 92 will be used to sort the origins.
81 * @private 93 * @private
82 */ 94 */
83 populateOrigins_: function(originDict) { 95 populateOriginsHelper_: function(originList, originDict) {
84 var origins = Object.keys(originDict).map(function(origin) { 96 var origins = Object.keys(originDict).map(function(origin) {
85 // |usage| means the time of last usage in seconds since epoch 97 // |usage| means the time of last usage in seconds since epoch
86 // (Jan 1, 1970) for permissions and means the amount of local storage 98 // (Jan 1, 1970) for permissions and means the amount of local storage
87 // in bytes used for local storage. 99 // in bytes used for local storage.
88 return { 100 return {
89 origin: origin, 101 origin: origin,
90 usage: originDict[origin].usage, 102 usage: originDict[origin].usage,
91 usageString: originDict[origin].usageString, 103 usageString: originDict[origin].usageString,
92 readableName: originDict[origin].readableName, 104 readableName: originDict[origin].readableName,
93 }; 105 };
94 }); 106 });
95 origins.sort(function(first, second) { 107 origins.sort(function(first, second) {
96 return second.usage - first.usage; 108 return second.usage - first.usage;
97 }); 109 });
98 this.originList_.dataModel = new ArrayDataModel(origins); 110 originList.dataModel = new ArrayDataModel(origins);
111 },
112
113
114 /**
115 * Populate the origin lists with all of the origins with a given permission
116 * or that are using a given resource, potentially split by if allowed or
117 * denied. If no blocked dictionary is provided, only the allowed list is
118 * shown.
119 * @param {!Object} allowedDict A dictionary of origins to their usage,
120 which will be used to sort the origins in the main/allowed list.
121 * @param {!Object} blockedDict An optional dictionary of origins to their
122 usage, which will be used to sort the origins in the blocked list.
123 * @private
124 */
125 populateOrigins: function(allowedDict, blockedDict) {
126 this.populateOriginsHelper_(this.allowedList_, allowedDict);
127 if (blockedDict) {
128 this.populateOriginsHelper_(this.blockedList_, blockedDict);
129 this.blockedList_.hidden = false;
130 $('blocked-origin-list-title').hidden = false;
131 this.allowedList_.classList.remove('nonsplit-origin-list');
132 } else {
133 this.blockedList_.hidden = true;
134 $('blocked-origin-list-title').hidden = true;
135 this.allowedList_.classList.add('nonsplit-origin-list');
136 }
99 }, 137 },
100 138
101 /** 139 /**
102 * Update the table with the origins filtered by the value in the search 140 * Update the table with the origins filtered by the value in the search
103 * box. 141 * box.
104 * @private 142 * @private
105 */ 143 */
106 searchOrigins: function() { 144 searchOrigins: function() {
107 var filter = $('website-settings-search-box').value; 145 var filter = $('website-settings-search-box').value;
108 chrome.send('updateOriginsSearchResults', [filter]); 146 chrome.send('updateOriginsSearchResults', [filter]);
109 }, 147 },
110 148
111 /** 149 /**
112 * Handle and delay search query changes. 150 * Handle and delay search query changes.
113 * @param {!Event} e The event object. 151 * @param {!Event} e The event object.
114 * @private 152 * @private
115 */ 153 */
116 handleSearchQueryChange_: function(e) { 154 handleSearchQueryChange_: function(e) {
117 if (this.queryDelayTimerId_) 155 if (this.queryDelayTimerId_)
118 window.clearTimeout(this.queryDelayTimerId_); 156 window.clearTimeout(this.queryDelayTimerId_);
119 157
120 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this), 158 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this),
121 160); 159 160);
122 }, 160 },
123 }; 161 };
124 162
125 WebsiteSettingsManager.populateOrigins = function(originDict) { 163 WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict) {
126 WebsiteSettingsManager.getInstance().populateOrigins_(originDict); 164 WebsiteSettingsManager.getInstance().populateOrigins(allowedDict,
165 blockedDict);
127 }; 166 };
128 167
129 WebsiteSettingsManager.showEditPage = function(url) { 168 WebsiteSettingsManager.showEditPage = function(url) {
130 WebsiteSettingsEditor.getInstance().populatePage(url); 169 WebsiteSettingsEditor.getInstance().populatePage(url);
131 }; 170 };
132 171
133 // Export 172 // Export
134 return { 173 return {
135 WebsiteSettingsManager: WebsiteSettingsManager 174 WebsiteSettingsManager: WebsiteSettingsManager
136 }; 175 };
137 }); 176 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/website_settings.html ('k') | chrome/browser/ui/webui/options/website_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698