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

Unified Diff: chrome/browser/resources/settings/location_page/location_page.js

Issue 1368973003: Flesh out the location-page class to make it more general. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/settings/location_page/location_page.js
diff --git a/chrome/browser/resources/settings/location_page/location_page.js b/chrome/browser/resources/settings/location_page/location_page.js
index 1d8201bb641ed66a583086969914c07b7f65bd5d..3456e335765264bacc8cad4109f248a7040fcda7 100644
--- a/chrome/browser/resources/settings/location_page/location_page.js
+++ b/chrome/browser/resources/settings/location_page/location_page.js
@@ -59,15 +59,6 @@ Polymer({
},
/**
- * Name of the 'iron-icon' to show.
- */
- icon: {
- type: String,
- value: 'communication:location-on',
- readOnly: true,
- },
-
- /**
* Array of objects with url members.
*/
block: {
@@ -80,15 +71,170 @@ Polymer({
allow: {
type: Array,
},
+
+ /**
+ * The content_settings_type value for the category we are displaying.
+ * TODO(finnur): Get this working so that it can be set from outside.
+ */
+ contentSettingsType: {
+ type: Number,
+ value: 8,
+ },
+
+ /**
+ * What the main toggle for the category is set to (the global default if
+ * no other policy is in effect).
+ */
+ globalDefault: {
+ type: Boolean,
+ value: false,
+ },
+
+ /**
+ * The site selected by the user in the dropdown list.
+ */
+ siteSelected: {
+ type: String,
+ notify: true,
+ }
},
ready: function() {
- this.block = [];
- this.allow = [];
+ chrome.send('fetchContentSettingsData', [this.contentSettingsType]);
},
- getTitleAndCount_: function(title, count) {
+ receiveData_: function(allowedList, blockedList, defaultValue) {
+ this.block = blockedList;
+ this.allow = allowedList;
+ this.globalDefault = defaultValue;
+ },
+
+ handleToggleChange_: function(event) {
+ chrome.send(
+ 'toggleChanged', [this.contentSettingsType, this.globalDefault]);
+ },
+
+ handleDblClick_: function(event) {
+ this.siteSelected = event.model.item.url;
+ },
+
+ attached: function() {
+ var self = this;
+ cr.define('Settings', function() {
+ return {
+ receiveData: function() {
+ return self.receiveData_.apply(self, arguments);
+ },
+ };
+ });
+ },
+
+ computeIcon_: function(contentSettingsType) {
+ // Wonder if any of these enum values are directly accessible from .js?
+ switch (contentSettingsType) {
+ case 0: // COOKIES.
+ return ''; // Haven't found a good cookies icon under iron-icons.
+ case 2: // JAVASCRIPT.
+ return 'icons:input';
+ case 8: // FULLSCREEN.
+ return 'icons:fullscreen';
+ case 4: // POPUPS.
+ return 'icons:open-in-new';
+ case 5: // LOCATION.
+ return 'communication:location-on';
+ case 6: // NOTIFICATION.
+ return 'social:notifications';
+ case 13: // CAMERA.
+ return 'av:videocam';
+ case 14: // MIC.
+ return 'av:mic';
+ default:
+ return '';
+ }
+ },
+
+ computeTitle_: function(contentSettingsType) {
+ switch (contentSettingsType) {
+ case 0:
+ return loadTimeData.getString('siteSettingsCookies');
+ case 2:
+ return loadTimeData.getString('siteSettingsJavascript');
+ case 8:
+ return loadTimeData.getString('siteSettingsFullscreen');
+ case 4:
+ return loadTimeData.getString('siteSettingsPopups');
+ case 5:
+ return loadTimeData.getString('siteSettingsLocation');
+ case 6:
+ return loadTimeData.getString('siteSettingsNotifications');
+ case 13:
+ return loadTimeData.getString('siteSettingsCamera');
+ case 14:
+ return loadTimeData.getString('siteSettingsMic');
+ default:
+ return 'unknown';
+ }
+ },
+
+ computeDesc_: function(contentSettingsType, globalDefault) {
+ switch (contentSettingsType) {
+ case 2: // JAVASCRIPT.
+ // "Allowed (recommended)" vs "Blocked".
+ return globalDefault ?
+ loadTimeData.getString('siteSettingsAllowedRecommended') :
+ loadTimeData.getString('siteSettingsBlocked');
+ case 4: // POPUPS.
+ // "Allowed" vs "Blocked (recommended)".
+ return globalDefault ?
+ loadTimeData.getString('siteSettingsAllowed') :
+ loadTimeData.getString('siteSettingsBlockedRecommended');
+ case 6:
+ // "Ask before sending (recommended)" vs "Blocked".
+ return globalDefault ?
+ loadTimeData.getString('siteSettingsAskBeforeSending') :
+ loadTimeData.getString('siteSettingsBlocked');
+ case 5: // LOCATION.
+ case 13: // CAMERA.
+ case 14: // MIC.
+ // "Ask before accessing (recommended)" vs "Blocked".
+ return globalDefault ?
+ loadTimeData.getString('siteSettingsAskBeforeAccessing') :
+ loadTimeData.getString('siteSettingsBlocked');
+ case 8: // FULLSCREEN.
+ // "Allowed" vs. "Ask first (recommended)".
+ return globalDefault ?
+ loadTimeData.getString('siteSettingsAllowed') :
+ loadTimeData.getString('siteSettingsAskFirstRecommended');
+ case 0: // COOKIES.
+ // "Allow sites to save and read cookie data" vs "Blocked".
+ return globalDefault ?
+ loadTimeData.getString('siteSettingsCookiesAllowed') :
+ loadTimeData.getString('siteSettingsBlocked');
+ default:
+ return 'unknown';
+ }
+ },
+
+ computeBlockedListHeader_: function(blockList) {
+ return loadTimeData.getStringF(
+ 'titleAndCount',
+ loadTimeData.getString('siteSettingsBlock'),
+ blockList.length);
+ },
+
+ computeAllowedListHeader_: function(allowedList, globalDefault) {
return loadTimeData.getStringF(
- 'titleAndCount', loadTimeData.getString(title), count);
+ 'titleAndCount',
+ loadTimeData.getString(
+ globalDefault ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
+ allowedList.length);
+ },
+
+ showAllowedList_: function(allowedList) {
+ return allowedList.length > 0;
+ },
+
+ showBlockedList_: function(blockedList, defaultValue) {
+ return blockedList.length > 0 && defaultValue;
},
});

Powered by Google App Engine
This is Rietveld 408576698