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

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

Issue 547753004: Allow the content setting or resource type to be passed into the Website Settings page by a hash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /////////////////////////////////////////////////////////////////////////////
(...skipping 24 matching lines...) Expand all
35 /** @override */ 35 /** @override */
36 initializePage: function() { 36 initializePage: function() {
37 Page.prototype.initializePage.call(this); 37 Page.prototype.initializePage.call(this);
38 38
39 $('website-settings-overlay-confirm').onclick = 39 $('website-settings-overlay-confirm').onclick =
40 PageManager.closeOverlay.bind(PageManager); 40 PageManager.closeOverlay.bind(PageManager);
41 41
42 $('resourceType').onchange = function() { 42 $('resourceType').onchange = function() {
43 var target = event.target; 43 var target = event.target;
44 assert(target.tagName == 'SELECT'); 44 assert(target.tagName == 'SELECT');
45 if (target.value == 'storage') 45 WebsiteSettingsManager.getInstance().updatePage_(target.value);
46 chrome.send('updateLocalStorage');
47 else if (target.value == 'battery')
48 chrome.send('updateBatteryUsage');
49 else
50 chrome.send('updateOrigins', [target.value]);
51 }; 46 };
52 47
53 var searchBox = $('website-settings-search-box'); 48 var searchBox = $('website-settings-search-box');
54 searchBox.addEventListener('search', 49 searchBox.addEventListener('search',
55 this.handleSearchQueryChange_.bind(this)); 50 this.handleSearchQueryChange_.bind(this));
56 51
57 searchBox.onkeydown = function(e) { 52 searchBox.onkeydown = function(e) {
58 if (e.keyIdentifier == 'Enter') 53 if (e.keyIdentifier == 'Enter')
59 e.preventDefault(); 54 e.preventDefault();
60 }; 55 };
61 56
62 this.createOriginsList_(); 57 this.createOriginsList_();
63 chrome.send('updateOrigins', ['geolocation']);
64 }, 58 },
65 59
66 /** 60 /**
61 * Called after the page has been shown. Show the content settings or
62 * resource auditing for the location's hash.
63 */
64 didShowPage: function() {
65 var hash = location.hash;
66 if (hash)
67 hash = hash.slice(1);
68 else
69 hash = 'geolocation';
70 this.updatePage_(hash);
71
72 var selectResource = $('resourceType');
73 for (var i = 0; i < selectResource.options.length; i++) {
Bernhard Bauer 2014/09/09 09:05:22 I think there's an easier way to do this... can yo
Daniel Nishi 2014/09/09 15:14:55 Huh. I thought I tested that and it didn't work, b
74 var value = selectResource.options[i].value;
75 if (value == hash)
76 selectResource.selectedIndex = i;
77 }
78 },
79
80 /**
67 * Creates, decorates and initializes the origin list. 81 * Creates, decorates and initializes the origin list.
68 * @private 82 * @private
69 */ 83 */
70 createOriginsList_: function() { 84 createOriginsList_: function() {
71 this.originList_ = this.pageDiv.querySelector('.origin-list'); 85 this.originList_ = this.pageDiv.querySelector('.origin-list');
72 options.OriginList.decorate(this.originList_); 86 options.OriginList.decorate(this.originList_);
73 this.originList_.autoExpands = true; 87 this.originList_.autoExpands = true;
74 }, 88 },
75 89
76 /** 90 /**
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 * @param {!Event} e The event object. 127 * @param {!Event} e The event object.
114 * @private 128 * @private
115 */ 129 */
116 handleSearchQueryChange_: function(e) { 130 handleSearchQueryChange_: function(e) {
117 if (this.queryDelayTimerId_) 131 if (this.queryDelayTimerId_)
118 window.clearTimeout(this.queryDelayTimerId_); 132 window.clearTimeout(this.queryDelayTimerId_);
119 133
120 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this), 134 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this),
121 160); 135 160);
122 }, 136 },
137
138 /**
139 * Updates the page with the given content setting or resource name's
140 * information.
141 * @param {string} typeName The name of the content setting or resource.
142 */
143 updatePage_: function(typeName) {
144 if (typeName == 'storage')
145 chrome.send('updateLocalStorage');
146 else if (typeName == 'battery')
147 chrome.send('updateBatteryUsage');
148 else
149 chrome.send('updateOrigins', [typeName]);
150 }
123 }; 151 };
124 152
125 WebsiteSettingsManager.populateOrigins = function(originDict) { 153 WebsiteSettingsManager.populateOrigins = function(originDict) {
126 WebsiteSettingsManager.getInstance().populateOrigins_(originDict); 154 WebsiteSettingsManager.getInstance().populateOrigins_(originDict);
127 }; 155 };
128 156
129 WebsiteSettingsManager.showEditPage = function(url) { 157 WebsiteSettingsManager.showEditPage = function(url) {
130 WebsiteSettingsEditor.getInstance().populatePage(url); 158 WebsiteSettingsEditor.getInstance().populatePage(url);
131 }; 159 };
132 160
133 // Export 161 // Export
134 return { 162 return {
135 WebsiteSettingsManager: WebsiteSettingsManager 163 WebsiteSettingsManager: WebsiteSettingsManager
136 }; 164 };
137 }); 165 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698