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 11 matching lines...) Expand all Loading... | |
22 cr.addSingletonGetter(WebsiteSettingsEditor); | 22 cr.addSingletonGetter(WebsiteSettingsEditor); |
23 | 23 |
24 WebsiteSettingsEditor.prototype = { | 24 WebsiteSettingsEditor.prototype = { |
25 __proto__: Page.prototype, | 25 __proto__: Page.prototype, |
26 | 26 |
27 | 27 |
28 /** @override */ | 28 /** @override */ |
29 initializePage: function() { | 29 initializePage: function() { |
30 Page.prototype.initializePage.call(this); | 30 Page.prototype.initializePage.call(this); |
31 | 31 |
32 $('websiteSettingsStorageDeleteButton').onclick = function(event) { | |
33 chrome.send('deleteLocalStorage'); | |
34 }; | |
35 | |
32 $('websiteSettingsEditorCancelButton').onclick = | 36 $('websiteSettingsEditorCancelButton').onclick = |
33 PageManager.closeOverlay.bind(PageManager); | 37 PageManager.closeOverlay.bind(PageManager); |
34 | 38 |
35 $('websiteSettingsEditorDoneButton').onclick = function(event) { | 39 $('websiteSettingsEditorDoneButton').onclick = function(event) { |
36 WebsiteSettingsEditor.getInstance().updatePermissions(); | 40 WebsiteSettingsEditor.getInstance().updatePermissions(); |
37 PageManager.closeOverlay.bind(PageManager)(); | 41 PageManager.closeOverlay.bind(PageManager)(); |
38 }; | 42 }; |
39 }, | 43 }, |
40 | 44 |
41 /** | 45 /** |
42 * Populates the page with the proper information for a given URL. | 46 * Populates the page with the proper information for a given URL. |
43 * @param {string} url The URL of the page. | 47 * @param {string} url The URL of the page. |
44 * @private | 48 * @private |
45 */ | 49 */ |
46 populatePage: function(url) { | 50 populatePage: function(url) { |
47 this.url = url; | 51 this.url = url; |
48 | 52 |
49 var titleEl = $('website-title'); | 53 var titleEl = $('website-title'); |
50 titleEl.textContent = url; | 54 titleEl.textContent = url; |
51 titleEl.style.backgroundImage = getFaviconImageSet(url); | 55 titleEl.style.backgroundImage = getFaviconImageSet(url); |
52 | 56 |
53 chrome.send('getOriginInfo', [url]); | 57 chrome.send('getOriginInfo', [url]); |
54 }, | 58 }, |
55 | 59 |
56 /** | 60 /** |
57 * Populates and displays the page with given origin information. | 61 * Populates and displays the page with given origin information. |
58 * @param {string} local_storage A string describing the local storage use. | 62 * @param {string} local_storage A string describing the local storage use. |
59 * @param {Object} permissions A dictionary of permissions to their | 63 * @param {Object} permissions A dictionary of permissions to their |
60 * available and current settings, and if it is editable. | 64 * available and current settings, and if it is editable. |
65 * @param {boolean} show_page If the page should raised. | |
61 * @private | 66 * @private |
62 */ | 67 */ |
63 populateOrigin_: function(local_storage, permissions) { | 68 populateOrigin_: function(local_storage, permissions, show_page) { |
Bernhard Bauer
2014/08/22 20:42:38
This should be named showPage (same goes for local
Daniel Nishi
2014/08/22 21:45:25
Done.
| |
64 $('local-storage-title').textContent = local_storage; | 69 $('local-storage-title').textContent = local_storage; |
65 for (var key in permissions) { | 70 for (var key in permissions) { |
66 var selector = $(key + '-select-option'); | 71 var selector = $(key + '-select-option'); |
67 | 72 |
68 var options = permissions[key].options; | 73 var options = permissions[key].options; |
69 selector.options.length = 0; | 74 selector.options.length = 0; |
70 for (var option in options) { | 75 for (var option in options) { |
71 selector.options[selector.options.length] = | 76 selector.options[selector.options.length] = |
72 new Option(loadTimeData.getString(options[option] + 'Exception'), | 77 new Option(loadTimeData.getString(options[option] + 'Exception'), |
73 options[option]); | 78 options[option]); |
74 } | 79 } |
75 | 80 |
76 selector.value = permissions[key].setting; | 81 selector.value = permissions[key].setting; |
77 selector.originalValue = permissions[key].setting; | 82 selector.originalValue = permissions[key].setting; |
78 selector.disabled = !permissions[key].editable; | 83 selector.disabled = !permissions[key].editable; |
79 } | 84 } |
80 PageManager.showPageByName('websiteEdit', false); | 85 if (show_page) |
86 PageManager.showPageByName('websiteEdit', false); | |
81 }, | 87 }, |
82 | 88 |
83 updatePermissions: function() { | 89 updatePermissions: function() { |
84 for (var key in this.permissions) { | 90 for (var key in this.permissions) { |
85 var selection = $(this.permissions[key] + '-select-option'); | 91 var selection = $(this.permissions[key] + '-select-option'); |
86 if (selection.value != selection.originalValue) { | 92 if (selection.value != selection.originalValue) { |
87 chrome.send('setOriginPermission', | 93 chrome.send('setOriginPermission', |
88 [this.permissions[key], selection.value]); | 94 [this.permissions[key], selection.value]); |
89 } | 95 } |
90 } | 96 } |
91 }, | 97 }, |
92 }; | 98 }; |
93 | 99 |
94 WebsiteSettingsEditor.populateOrigin = function(local_storage, permissions) { | 100 WebsiteSettingsEditor.populateOrigin = function(local_storage, permissions, |
101 show_page) { | |
95 WebsiteSettingsEditor.getInstance().populateOrigin_(local_storage, | 102 WebsiteSettingsEditor.getInstance().populateOrigin_(local_storage, |
96 permissions); | 103 permissions, |
104 show_page); | |
97 }; | 105 }; |
98 | 106 |
99 // Export | 107 // Export |
100 return { | 108 return { |
101 WebsiteSettingsEditor: WebsiteSettingsEditor | 109 WebsiteSettingsEditor: WebsiteSettingsEditor |
102 }; | 110 }; |
103 | 111 |
104 }); | 112 }); |
OLD | NEW |