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

Unified 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: Last pass. 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 side-by-side diff with in-line comments
Download patch
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..c43c6fcfe880aba2c630d0da5c78e0ba9eaef1ef
--- /dev/null
+++ b/chrome/browser/resources/options/website_settings.js
@@ -0,0 +1,114 @@
+// 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() {
+ /** @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);
+
+ $('resourceType').onchange = function() {
+ var target = event.target;
Vitaly Pavlenko 2014/09/07 05:14:33 I don't understand why |event| is defined at this
+ assert(target.tagName == 'SELECT');
+ chrome.send('updateOrigins', [target.value]);
+ };
+
+ var searchBox = $('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 =
+ $('website-settings-search-box').value;
+ 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
+ };
+});
« no previous file with comments | « chrome/browser/resources/options/website_settings.html ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698