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

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

Issue 380893005: Add an option page for searching and managing resources and permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. Created 6 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('options', function() {
6 /** @const */ var OptionsPage = options.OptionsPage;
7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
8
9 /////////////////////////////////////////////////////////////////////////////
10 // WebsiteSettingsManager class:
11
12 /**
13 * Encapsulated handling of the website settings page.
14 * @constructor
15 */
16 function WebsiteSettingsManager() {
17 OptionsPage.call(this, 'websiteSettings',
18 loadTimeData.getString('websitesOptionsPageTabTitle'),
19 'website-settings-page');
20 }
21
22 cr.addSingletonGetter(WebsiteSettingsManager);
23
24 WebsiteSettingsManager.prototype = {
25 __proto__: OptionsPage.prototype,
26
27 /**
28 * The saved origins list.
29 * @type {OriginList}
30 * @private
31 */
32 originList_: null,
33
34 /** @override */
35 initializePage: function() {
36 OptionsPage.prototype.initializePage.call(this);
37
38 $('website-settings-overlay-confirm').onclick =
39 OptionsPage.closeOverlay.bind(OptionsPage);
40
41 $('resourceType').onchange =
Dan Beam 2014/07/15 21:46:19 $('resourceType').onchange = function() { var ta
Daniel Nishi 2014/07/15 22:18:23 Done.
42 function(event) {
43 var target = event.target;
44 assert(target.tagName == 'SELECT');
45 chrome.send('updateOrigins',
46 [target.options[target.selectedIndex].value]);
Dan Beam 2014/07/15 21:46:19 isn't this the same as target.value?
Daniel Nishi 2014/07/15 22:18:23 Appears to be so. Switched to the simpler value.
47 };
48
49 var searchBox = $('website-settings-search-box');
50 searchBox.addEventListener('search',
51 this.handleSearchQueryChange_.bind(this));
52
53 searchBox.onkeydown = function(e) {
54 if (e.keyIdentifier == 'Enter')
55 e.preventDefault();
56 };
57
58 this.createOriginsList_();
59 chrome.send('updateOrigins', ['geolocation']);
60 },
61
62 /**
63 * Creates, decorates and initializes the origin list.
64 * @private
65 */
66 createOriginsList_: function() {
67 this.originList_ = this.pageDiv.querySelector('.origin-list');
68 options.OriginList.decorate(this.originList_);
69 this.originList_.autoExpands = true;
70 },
71
72 /**
73 * Populate the origin list with all of the origins with a given permission
74 * or that are using a given resource.
75 * @private
76 */
77 populateOrigins_: function(originDict) {
78 // TODO(dhnishi): Include the last usage time instead of just pushing the
79 // keys.
80 this.originList_.dataModel = new ArrayDataModel(Object.keys(originDict));
81 },
82
83 /**
84 * Update the table with the origins filtered by the value in the search
85 * box.
86 * @private
87 */
88 searchOrigins: function() {
89 var filter =
90 $('website-settings-search-box').value;
91 chrome.send('updateOriginsSearchResults', [filter]);
Dan Beam 2014/07/15 21:46:19 indent off
Daniel Nishi 2014/07/15 22:18:23 Done.
92 },
93
94 /**
95 * Handle and delay search query changes.
96 * @param {!Event} e The event object.
97 * @private
98 */
99 handleSearchQueryChange_: function() {
100 if (this.queryDelayTimerId_)
101 window.clearTimeout(this.queryDelayTimerId_);
102
103 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this),
104 160);
105 },
106 };
107
108 WebsiteSettingsManager.populateOrigins = function(originDict) {
109 WebsiteSettingsManager.getInstance().populateOrigins_(originDict);
110 };
111
112 // Export
113 return {
114 WebsiteSettingsManager: WebsiteSettingsManager
115 };
116 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698