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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'cr-settings-location-page' is the settings page for location access. 7 * 'cr-settings-location-page' is the settings page for location access.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 /** 53 /**
54 * Title for the page header and navigation menu. 54 * Title for the page header and navigation menu.
55 */ 55 */
56 pageTitle: { 56 pageTitle: {
57 type: String, 57 type: String,
58 value: '', 58 value: '',
59 }, 59 },
60 60
61 /** 61 /**
62 * Name of the 'iron-icon' to show.
63 */
64 icon: {
65 type: String,
66 value: 'communication:location-on',
67 readOnly: true,
68 },
69
70 /**
71 * Array of objects with url members. 62 * Array of objects with url members.
72 */ 63 */
73 block: { 64 block: {
74 type: Array, 65 type: Array,
75 }, 66 },
76 67
77 /** 68 /**
78 * Array of objects with url members. 69 * Array of objects with url members.
79 */ 70 */
80 allow: { 71 allow: {
81 type: Array, 72 type: Array,
82 }, 73 },
74
75 /**
76 * The content_settings_type value for the category we are displaying.
77 * TODO(finnur): Get this working so that it can be set from outside.
78 */
79 contentSettingsType: {
80 type: Number,
81 value: 8,
82 },
83
84 /**
85 * What the main toggle for the category is set to (the global default if
86 * no other policy is in effect).
87 */
88 globalDefault: {
89 type: Boolean,
90 value: false,
91 },
92
93 /**
94 * The site selected by the user in the dropdown list.
95 */
96 siteSelected: {
97 type: String,
98 notify: true,
99 }
83 }, 100 },
84 101
85 ready: function() { 102 ready: function() {
86 this.block = []; 103 chrome.send('fetchContentSettingsData', [this.contentSettingsType]);
87 this.allow = [];
88 }, 104 },
89 105
90 getTitleAndCount_: function(title, count) { 106 receiveData_: function(allowedList, blockedList, defaultValue) {
107 this.block = blockedList;
108 this.allow = allowedList;
109 this.globalDefault = defaultValue;
110 },
111
112 handleToggleChange_: function(event) {
113 chrome.send(
114 'toggleChanged', [this.contentSettingsType, this.globalDefault]);
115 },
116
117 handleDblClick_: function(event) {
118 this.siteSelected = event.model.item.url;
119 },
120
121 attached: function() {
122 var self = this;
123 cr.define('Settings', function() {
124 return {
125 receiveData: function() {
126 return self.receiveData_.apply(self, arguments);
127 },
128 };
129 });
130 },
131
132 computeIcon_: function(contentSettingsType) {
133 // Wonder if any of these enum values are directly accessible from .js?
134 switch (contentSettingsType) {
135 case 0: // COOKIES.
136 return ''; // Haven't found a good cookies icon under iron-icons.
137 case 2: // JAVASCRIPT.
138 return 'icons:input';
139 case 8: // FULLSCREEN.
140 return 'icons:fullscreen';
141 case 4: // POPUPS.
142 return 'icons:open-in-new';
143 case 5: // LOCATION.
144 return 'communication:location-on';
145 case 6: // NOTIFICATION.
146 return 'social:notifications';
147 case 13: // CAMERA.
148 return 'av:videocam';
149 case 14: // MIC.
150 return 'av:mic';
151 default:
152 return '';
153 }
154 },
155
156 computeTitle_: function(contentSettingsType) {
157 switch (contentSettingsType) {
158 case 0:
159 return loadTimeData.getString('siteSettingsCookies');
160 case 2:
161 return loadTimeData.getString('siteSettingsJavascript');
162 case 8:
163 return loadTimeData.getString('siteSettingsFullscreen');
164 case 4:
165 return loadTimeData.getString('siteSettingsPopups');
166 case 5:
167 return loadTimeData.getString('siteSettingsLocation');
168 case 6:
169 return loadTimeData.getString('siteSettingsNotifications');
170 case 13:
171 return loadTimeData.getString('siteSettingsCamera');
172 case 14:
173 return loadTimeData.getString('siteSettingsMic');
174 default:
175 return 'unknown';
176 }
177 },
178
179 computeDesc_: function(contentSettingsType, globalDefault) {
180 switch (contentSettingsType) {
181 case 2: // JAVASCRIPT.
182 // "Allowed (recommended)" vs "Blocked".
183 return globalDefault ?
184 loadTimeData.getString('siteSettingsAllowedRecommended') :
185 loadTimeData.getString('siteSettingsBlocked');
186 case 4: // POPUPS.
187 // "Allowed" vs "Blocked (recommended)".
188 return globalDefault ?
189 loadTimeData.getString('siteSettingsAllowed') :
190 loadTimeData.getString('siteSettingsBlockedRecommended');
191 case 6:
192 // "Ask before sending (recommended)" vs "Blocked".
193 return globalDefault ?
194 loadTimeData.getString('siteSettingsAskBeforeSending') :
195 loadTimeData.getString('siteSettingsBlocked');
196 case 5: // LOCATION.
197 case 13: // CAMERA.
198 case 14: // MIC.
199 // "Ask before accessing (recommended)" vs "Blocked".
200 return globalDefault ?
201 loadTimeData.getString('siteSettingsAskBeforeAccessing') :
202 loadTimeData.getString('siteSettingsBlocked');
203 case 8: // FULLSCREEN.
204 // "Allowed" vs. "Ask first (recommended)".
205 return globalDefault ?
206 loadTimeData.getString('siteSettingsAllowed') :
207 loadTimeData.getString('siteSettingsAskFirstRecommended');
208 case 0: // COOKIES.
209 // "Allow sites to save and read cookie data" vs "Blocked".
210 return globalDefault ?
211 loadTimeData.getString('siteSettingsCookiesAllowed') :
212 loadTimeData.getString('siteSettingsBlocked');
213 default:
214 return 'unknown';
215 }
216 },
217
218 computeBlockedListHeader_: function(blockList) {
91 return loadTimeData.getStringF( 219 return loadTimeData.getStringF(
92 'titleAndCount', loadTimeData.getString(title), count); 220 'titleAndCount',
221 loadTimeData.getString('siteSettingsBlock'),
222 blockList.length);
223 },
224
225 computeAllowedListHeader_: function(allowedList, globalDefault) {
226 return loadTimeData.getStringF(
227 'titleAndCount',
228 loadTimeData.getString(
229 globalDefault ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
230 allowedList.length);
231 },
232
233 showAllowedList_: function(allowedList) {
234 return allowedList.length > 0;
235 },
236
237 showBlockedList_: function(blockedList, defaultValue) {
238 return blockedList.length > 0 && defaultValue;
93 }, 239 },
94 }); 240 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698