Chromium Code Reviews| Index: chrome/browser/resources/options/website_settings.js |
| diff --git a/chrome/browser/resources/options/website_settings.js b/chrome/browser/resources/options/website_settings.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ce9b14828d93a5a516136417ca5dd3a46c3aa920 |
| --- /dev/null |
| +++ b/chrome/browser/resources/options/website_settings.js |
| @@ -0,0 +1,118 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('options', function() { |
| + |
|
Dan Beam
2014/07/15 03:39:15
nit: remove \n
Daniel Nishi
2014/07/15 17:12:55
Done.
|
| + /** @const */ var OptionsPage = options.OptionsPage; |
| + /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| + |
| + ///////////////////////////////////////////////////////////////////////////// |
| + // WebsiteSettingsManager class: |
| + |
| + /** |
| + * Encapsulated handling of the website settings page. |
| + * @constructor |
| + */ |
| + function WebsiteSettingsManager() { |
| + OptionsPage.call(this, 'websiteSettings', |
| + loadTimeData.getString('websitesOptionsPageTabTitle'), |
| + 'website-settings-page'); |
| + } |
| + |
| + cr.addSingletonGetter(WebsiteSettingsManager); |
| + |
| + WebsiteSettingsManager.prototype = { |
| + __proto__: OptionsPage.prototype, |
| + |
| + /** |
| + * The saved origins list. |
| + * @type {OriginList} |
| + * @private |
| + */ |
| + originList_: null, |
| + |
| + /** @override */ |
| + initializePage: function() { |
| + OptionsPage.prototype.initializePage.call(this); |
| + |
| + $('website-settings-overlay-confirm').onclick = |
| + OptionsPage.closeOverlay.bind(OptionsPage); |
| + |
| + this.pageDiv.querySelector('.resource-type-select').onchange = |
| + function(event) { |
| + assert(event.target.tagName == 'SELECT'); |
| + chrome.send('updateOrigins', |
| + [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.
|
| + }; |
| + |
| + var searchBox = |
| + this.pageDiv.querySelector('.website-settings-search-box'); |
| + searchBox.addEventListener('search', |
| + this.handleSearchQueryChange_.bind(this)); |
| + |
| + searchBox.onkeydown = function(e) { |
| + if (e.keyIdentifier == 'Enter') |
| + e.preventDefault(); |
| + }; |
| + |
| + this.createOriginsList_(); |
| + chrome.send('updateOrigins', ['geolocation']); |
| + }, |
| + |
| + /** |
| + * Creates, decorates and initializes the origin list. |
| + * @private |
| + */ |
| + createOriginsList_: function() { |
| + this.originList_ = this.pageDiv.querySelector('.origin-list'); |
| + options.OriginList.decorate(this.originList_); |
| + this.originList_.autoExpands = true; |
| + }, |
| + |
| + /** |
| + * Populate the origin list with all of the origins with a given permission |
| + * or that are using a given resource. |
| + * @private |
| + */ |
| + populateOrigins_: function(originDict) { |
| + // TODO(dhnishi): Include the last usage time instead of just pushing the |
| + // keys. |
| + this.originList_.dataModel = new ArrayDataModel(Object.keys(originDict)); |
| + }, |
| + |
| + /** |
| + * Update the table with the origins filtered by the value in the search |
| + * box. |
| + * @private |
| + */ |
| + searchOrigins: function() { |
| + var filter = |
| + 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.
|
| + chrome.send('updateOriginsSearchResults', [filter]); |
| + }, |
| + |
| + /** |
| + * Handle and delay search query changes. |
| + * @param {!Event} e The event object. |
| + * @private |
| + */ |
| + handleSearchQueryChange_: function() { |
| + if (this.queryDelayTimerId_) |
| + window.clearTimeout(this.queryDelayTimerId_); |
| + |
| + this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this), |
| + 160); |
| + }, |
| + }; |
| + |
| + WebsiteSettingsManager.populateOrigins = function(originDict) { |
| + WebsiteSettingsManager.getInstance().populateOrigins_(originDict); |
| + }; |
| + |
| + // Export |
| + return { |
| + WebsiteSettingsManager: WebsiteSettingsManager |
| + }; |
| + |
|
Dan Beam
2014/07/15 03:39:15
remove \n
Daniel Nishi
2014/07/15 17:12:54
Done.
|
| +}); |