OLD | NEW |
---|---|
(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 | |
Dan Beam
2014/07/15 03:39:15
nit: remove \n
Daniel Nishi
2014/07/15 17:12:55
Done.
| |
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 $('website-settings-overlay-confirm').onclick = | |
40 OptionsPage.closeOverlay.bind(OptionsPage); | |
41 | |
42 this.pageDiv.querySelector('.resource-type-select').onchange = | |
43 function(event) { | |
44 assert(event.target.tagName == 'SELECT'); | |
45 chrome.send('updateOrigins', | |
46 [event.target.options[event.target.selectedIndex].value]); | |
Dan Beam
2014/07/15 03:39:15
nit: remove 4 \s indent inside this function
Daniel Nishi
2014/07/15 17:12:55
I think this solves the indent.
| |
47 }; | |
48 | |
49 var searchBox = | |
50 this.pageDiv.querySelector('.website-settings-search-box'); | |
51 searchBox.addEventListener('search', | |
52 this.handleSearchQueryChange_.bind(this)); | |
53 | |
54 searchBox.onkeydown = function(e) { | |
55 if (e.keyIdentifier == 'Enter') | |
56 e.preventDefault(); | |
57 }; | |
58 | |
59 this.createOriginsList_(); | |
60 chrome.send('updateOrigins', ['geolocation']); | |
61 }, | |
62 | |
63 /** | |
64 * Creates, decorates and initializes the origin list. | |
65 * @private | |
66 */ | |
67 createOriginsList_: function() { | |
68 this.originList_ = this.pageDiv.querySelector('.origin-list'); | |
69 options.OriginList.decorate(this.originList_); | |
70 this.originList_.autoExpands = true; | |
71 }, | |
72 | |
73 /** | |
74 * Populate the origin list with all of the origins with a given permission | |
75 * or that are using a given resource. | |
76 * @private | |
77 */ | |
78 populateOrigins_: function(originDict) { | |
79 // TODO(dhnishi): Include the last usage time instead of just pushing the | |
80 // keys. | |
81 this.originList_.dataModel = new ArrayDataModel(Object.keys(originDict)); | |
82 }, | |
83 | |
84 /** | |
85 * Update the table with the origins filtered by the value in the search | |
86 * box. | |
87 * @private | |
88 */ | |
89 searchOrigins: function() { | |
90 var filter = | |
91 this.pageDiv.querySelector('.website-settings-search-box').value; | |
Dan Beam
2014/07/15 03:39:15
indent off (4 \s for continuations)
Daniel Nishi
2014/07/15 17:12:54
Done.
| |
92 chrome.send('updateOriginsSearchResults', [filter]); | |
93 }, | |
94 | |
95 /** | |
96 * Handle and delay search query changes. | |
97 * @param {!Event} e The event object. | |
98 * @private | |
99 */ | |
100 handleSearchQueryChange_: function() { | |
101 if (this.queryDelayTimerId_) | |
102 window.clearTimeout(this.queryDelayTimerId_); | |
103 | |
104 this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this), | |
105 160); | |
106 }, | |
107 }; | |
108 | |
109 WebsiteSettingsManager.populateOrigins = function(originDict) { | |
110 WebsiteSettingsManager.getInstance().populateOrigins_(originDict); | |
111 }; | |
112 | |
113 // Export | |
114 return { | |
115 WebsiteSettingsManager: WebsiteSettingsManager | |
116 }; | |
117 | |
Dan Beam
2014/07/15 03:39:15
remove \n
Daniel Nishi
2014/07/15 17:12:54
Done.
| |
118 }); | |
OLD | NEW |