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

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: 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
7 /** @const */ var OptionsPage = options.OptionsPage;
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
9
10 /////////////////////////////////////////////////////////////////////////////
11 // WebsiteSettingsManager class:
12
13 /**
14 * Encapsulated handling of the website settings page.
15 * @constructor
16 */
17 function WebsiteSettingsManager() {
18 OptionsPage.call(this, 'websiteSettings',
19 loadTimeData.getString('websitesOptionsPageTabTitle'),
20 'website-settings-page');
21 }
22
23 cr.addSingletonGetter(WebsiteSettingsManager);
24
25 WebsiteSettingsManager.prototype = {
26 __proto__: OptionsPage.prototype,
27
28 /**
29 * The saved origins list.
30 * @type {OriginList}
31 * @private
32 */
33 originList_: null,
34
35 /** @override */
36 initializePage: function() {
37 OptionsPage.prototype.initializePage.call(this);
38
39 this.pageDiv.querySelector('.website-settings-overlay-confirm').onclick =
Bernhard Bauer 2014/07/10 08:47:42 Would it make sense to make this an ID instead of
Daniel Nishi 2014/07/10 19:00:09 I think so. Done.
Bernhard Bauer 2014/07/15 08:32:49 We can probably do that for the other elements her
40 OptionsPage.closeOverlay.bind(OptionsPage);
41
42 this.pageDiv.querySelector('.resource-type-select').onchange =
Dan Beam 2014/07/10 02:57:24 this.pageDiv.querySelector('.resource-type-select'
Daniel Nishi 2014/07/10 19:00:08 Done.
43 function(event) {
Dan Beam 2014/07/10 02:57:24 nit: assert(event.target.tagName == 'SELECT');
Daniel Nishi 2014/07/10 19:00:08 Done.
44 chrome.send('updateOrigins',
45 [event.target.options[event.target.selectedIndex].value]);
46 };
47
48 var searchBox =
49 this.pageDiv.querySelector('.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.stopPropagation();
Dan Beam 2014/07/10 02:57:24 do you want to stop the propagation or prevent the
Daniel Nishi 2014/07/10 19:00:09 Prevent the default is better. Done.
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 entries = [];
Dan Beam 2014/07/10 02:57:24 ^ always start with var, this is creating a global
Daniel Nishi 2014/07/10 19:00:09 Done.
81 for (var key in originDict) {
82 entries.push(key);
83 }
84 this.originList_.dataModel = new ArrayDataModel(entries);
Dan Beam 2014/07/10 02:57:24 |entries| => Object.keys(originDict)
Bernhard Bauer 2014/07/10 08:47:42 Alternatively, just pass an array to this method.
Daniel Nishi 2014/07/10 19:00:09 Done.
85 },
86
Dan Beam 2014/07/10 02:57:24 /** Doc comment */
Daniel Nishi 2014/07/10 19:00:09 Done.
87 searchOrigins: function() {
Dan Beam 2014/07/10 02:57:24 make @private
Daniel Nishi 2014/07/10 19:00:09 Done.
88 var filter =
89 this.pageDiv.querySelector('.website-settings-search-box').value;
90 chrome.send('updateOriginsSearchResults', [filter]);
Dan Beam 2014/07/10 02:57:24 indent off (needs 1 more \s)
Daniel Nishi 2014/07/10 19:00:09 Oops. I think I had the outside indented wrong. S
91 },
92
Dan Beam 2014/07/10 02:57:24 /** * Doc comment. * @private */
Daniel Nishi 2014/07/10 19:00:09 Done.
93 handleSearchQueryChange_: function() {
94 if (this.queryDelayTimerId_)
95 window.clearTimeout(this.queryDelayTimerId_);
96
97 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this),
98 160);
Dan Beam 2014/07/10 02:57:24 ident off (needs 1 more \s)
Daniel Nishi 2014/07/10 19:00:09 Fixed function indentation.
99 },
100 };
101
102 WebsiteSettingsManager.populateOrigins = function(originDict) {
103 WebsiteSettingsManager.getInstance().populateOrigins_(originDict);
104 };
105
106 // Export
107 return {
108 WebsiteSettingsManager: WebsiteSettingsManager
109 };
110
111 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698