OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('options.WebsiteSettings', function() { | 5 cr.define('options.WebsiteSettings', function() { |
6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 | 7 |
8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
9 // WebsiteSettingsEditor class: | 9 // WebsiteSettingsEditor class: |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 | 28 |
29 /** @override */ | 29 /** @override */ |
30 initializePage: function() { | 30 initializePage: function() { |
31 Page.prototype.initializePage.call(this); | 31 Page.prototype.initializePage.call(this); |
32 | 32 |
33 $('website-settings-storage-delete-button').onclick = function(event) { | 33 $('website-settings-storage-delete-button').onclick = function(event) { |
34 chrome.send('deleteLocalStorage'); | 34 chrome.send('deleteLocalStorage'); |
35 }; | 35 }; |
36 | 36 |
| 37 $('website-settings-battery-stop-button').onclick = function(event) { |
| 38 chrome.send('stopOrigin'); |
| 39 }; |
| 40 |
37 $('websiteSettingsEditorCancelButton').onclick = | 41 $('websiteSettingsEditorCancelButton').onclick = |
38 PageManager.closeOverlay.bind(PageManager); | 42 PageManager.closeOverlay.bind(PageManager); |
39 | 43 |
40 $('websiteSettingsEditorDoneButton').onclick = function(event) { | 44 $('websiteSettingsEditorDoneButton').onclick = function(event) { |
41 WebsiteSettingsEditor.getInstance().updatePermissions(); | 45 WebsiteSettingsEditor.getInstance().updatePermissions(); |
42 PageManager.closeOverlay.bind(PageManager)(); | 46 PageManager.closeOverlay.bind(PageManager)(); |
43 }; | 47 }; |
44 }, | 48 }, |
45 | 49 |
46 /** | 50 /** |
47 * Populates the page with the proper information for a given URL. | 51 * Populates the page with the proper information for a given URL. |
48 * @param {string} url The URL of the page. | 52 * @param {string} url The URL of the page. |
49 * @private | 53 * @private |
50 */ | 54 */ |
51 populatePage: function(url) { | 55 populatePage: function(url) { |
52 this.url = url; | 56 this.url = url; |
53 | 57 |
54 var titleEl = $('website-title'); | 58 var titleEl = $('website-title'); |
55 titleEl.textContent = url; | 59 titleEl.textContent = url; |
56 titleEl.style.backgroundImage = getFaviconImageSet(url); | 60 titleEl.style.backgroundImage = getFaviconImageSet(url); |
57 | 61 |
58 chrome.send('getOriginInfo', [url]); | 62 chrome.send('getOriginInfo', [url]); |
59 }, | 63 }, |
60 | 64 |
61 /** | 65 /** |
62 * Populates and displays the page with given origin information. | 66 * Populates and displays the page with given origin information. |
63 * @param {string} localStorage A string describing the local storage use. | 67 * @param {string} localStorage A string describing the local storage use. |
| 68 * @param {string} batteryUsage A string describing the battery use. |
64 * @param {Object} permissions A dictionary of permissions to their | 69 * @param {Object} permissions A dictionary of permissions to their |
65 * available and current settings, and if it is editable. | 70 * available and current settings, and if it is editable. |
66 * @param {boolean} showPage If the page should raised. | 71 * @param {boolean} showPage If the page should raised. |
67 * @private | 72 * @private |
68 */ | 73 */ |
69 populateOrigin_: function(localStorage, permissions, showPage) { | 74 populateOrigin_: function(localStorage, batteryUsage, permissions, |
| 75 showPage) { |
70 $('local-storage-title').textContent = localStorage; | 76 $('local-storage-title').textContent = localStorage; |
| 77 $('battery-title').textContent = batteryUsage; |
71 for (var key in permissions) { | 78 for (var key in permissions) { |
72 var selector = $(key + '-select-option'); | 79 var selector = $(key + '-select-option'); |
73 | 80 |
74 var options = permissions[key].options; | 81 var options = permissions[key].options; |
75 selector.options.length = 0; | 82 selector.options.length = 0; |
76 for (var option in options) { | 83 for (var option in options) { |
77 selector.options[selector.options.length] = | 84 selector.options[selector.options.length] = |
78 new Option(loadTimeData.getString(options[option] + 'Exception'), | 85 new Option(loadTimeData.getString(options[option] + 'Exception'), |
79 options[option]); | 86 options[option]); |
80 } | 87 } |
(...skipping 10 matching lines...) Expand all Loading... |
91 for (var key in this.permissions) { | 98 for (var key in this.permissions) { |
92 var selection = $(this.permissions[key] + '-select-option'); | 99 var selection = $(this.permissions[key] + '-select-option'); |
93 if (selection.value != selection.originalValue) { | 100 if (selection.value != selection.originalValue) { |
94 chrome.send('setOriginPermission', | 101 chrome.send('setOriginPermission', |
95 [this.permissions[key], selection.value]); | 102 [this.permissions[key], selection.value]); |
96 } | 103 } |
97 } | 104 } |
98 }, | 105 }, |
99 }; | 106 }; |
100 | 107 |
101 WebsiteSettingsEditor.populateOrigin = function(localStorage, permissions, | 108 WebsiteSettingsEditor.populateOrigin = function(localStorage, batteryUsage, |
102 showPage) { | 109 permissions, showPage) { |
103 WebsiteSettingsEditor.getInstance().populateOrigin_(localStorage, | 110 WebsiteSettingsEditor.getInstance().populateOrigin_(localStorage, |
| 111 batteryUsage, |
104 permissions, | 112 permissions, |
105 showPage); | 113 showPage); |
106 }; | 114 }; |
107 | 115 |
108 // Export | 116 // Export |
109 return { | 117 return { |
110 WebsiteSettingsEditor: WebsiteSettingsEditor | 118 WebsiteSettingsEditor: WebsiteSettingsEditor |
111 }; | 119 }; |
112 | 120 |
113 }); | 121 }); |
OLD | NEW |