Index: chrome/browser/resources/options/website_settings_edit_page.js |
diff --git a/chrome/browser/resources/options/website_settings_edit_page.js b/chrome/browser/resources/options/website_settings_edit_page.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..19cdf512e60f2321a0b40e6075b5bb89a94bdbdb |
--- /dev/null |
+++ b/chrome/browser/resources/options/website_settings_edit_page.js |
@@ -0,0 +1,103 @@ |
+// 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.WebsiteSettings', function() { |
+ /** @const */ var Page = cr.ui.pageManager.Page; |
+ |
+ ///////////////////////////////////////////////////////////////////////////// |
+ // WebsiteSettingsEditor class: |
+ |
+ /** |
+ * Encapsulated handling of the website settings editor page. |
+ * @constructor |
+ */ |
+ function WebsiteSettingsEditor() { |
+ Page.call(this, 'websiteEdit', |
+ loadTimeData.getString('websitesOptionsPageTabTitle'), |
+ 'website-settings-edit-page'); |
+ this.permissions = ['geolocation', 'notifications', 'media-stream']; |
+ } |
+ |
+ cr.addSingletonGetter(WebsiteSettingsEditor); |
+ |
+ WebsiteSettingsEditor.prototype = { |
+ __proto__: Page.prototype, |
+ |
+ |
+ /** @override */ |
+ initializePage: function() { |
+ Page.prototype.initializePage.call(this); |
+ |
+ $('websiteSettingsEditorCancelButton').onclick = |
+ PageManager.closeOverlay.bind(PageManager); |
+ |
+ $('websiteSettingsEditorDoneButton').onclick = function(event) { |
+ WebsiteSettingsEditor.getInstance().updatePermissions(); |
+ PageManager.closeOverlay.bind(PageManager)(); |
+ }; |
+ }, |
+ |
+ /** |
+ * Populates the page with the proper information for a given URL. |
+ * @param {string} url The URL of the page. |
+ * @private |
+ */ |
+ populatePage: function(url) { |
+ this.url = url; |
+ |
+ var titleEl = $('website-title'); |
+ titleEl.textContent = url; |
+ titleEl.style.backgroundImage = getFaviconImageSet(url); |
+ |
+ chrome.send('getOriginInfo', [url]); |
+ }, |
+ |
+ /** |
+ * Populates and displays the page with given origin information. |
+ * @param {Array} args A list containing the amount of local storage used |
Bernhard Bauer
2014/08/15 14:53:05
From the code, it seems this is a dictionary?
Daniel Nishi
2014/08/15 16:56:45
chrome/browser/ui/webui/options/website_settings_h
Bernhard Bauer
2014/08/15 17:13:04
Oh, I overlooked it's the whole arguments array.
Daniel Nishi
2014/08/15 17:33:46
Done.
|
+ and its permission information. |
+ * @private |
+ */ |
+ populateOrigin_: function(args) { |
+ $('local-storage-title').textContent = args[0]; |
+ var permissions = args[1]; |
+ for (var key in permissions) { |
+ var selector = $(key + '-select-option'); |
+ |
+ var options = permissions[key].options; |
+ selector.options.length = 0; |
+ for (var option in options) { |
+ selector.options[selector.options.length] = |
+ new Option(loadTimeData.getString(options[option] + 'Exception'), |
+ options[option]); |
+ } |
+ |
+ selector.value = permissions[key].setting; |
+ selector.originalValue = permissions[key].setting; |
+ selector.disabled = !permissions[key].editable; |
+ } |
+ PageManager.showPageByName('websiteEdit', false); |
+ }, |
+ |
+ updatePermissions: function() { |
+ for (var key in this.permissions) { |
+ var selection = $(this.permissions[key] + '-select-option'); |
+ if (selection.value != selection.originalValue) { |
+ chrome.send('setOriginPermission', |
+ [this.permissions[key], selection.value]); |
+ } |
+ } |
+ }, |
+ }; |
+ |
+ WebsiteSettingsEditor.populateOrigin = function(args) { |
+ WebsiteSettingsEditor.getInstance().populateOrigin_(args); |
+ }; |
+ |
+ // Export |
+ return { |
+ WebsiteSettingsEditor: WebsiteSettingsEditor |
+ }; |
+ |
+}); |