OLD | NEW |
---|---|
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 Behavior common to Site Settings classes. | 6 * @fileoverview Behavior common to Site Settings classes. |
7 */ | 7 */ |
8 | 8 |
9 /** @polymerBehavior */ | 9 /** @polymerBehavior */ |
10 var SiteSettingsBehaviorImpl = { | 10 var SiteSettingsBehaviorImpl = { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 return loadTimeData.getString('siteSettingsUsbDevices'); | 241 return loadTimeData.getString('siteSettingsUsbDevices'); |
242 default: | 242 default: |
243 assertNotReached('Invalid category: ' + category); | 243 assertNotReached('Invalid category: ' + category); |
244 return ''; | 244 return ''; |
245 } | 245 } |
246 }, | 246 }, |
247 | 247 |
248 /** | 248 /** |
249 * A utility function to compute the description for the category. | 249 * A utility function to compute the description for the category. |
250 * @param {string} category The category to show the description for. | 250 * @param {string} category The category to show the description for. |
251 * @param {boolean} categoryEnabled The state of the global toggle. | 251 * @param {string} setting The string value of the setting. |
252 * @param {boolean} showRecommendation Whether to show the '(recommended)' | 252 * @param {boolean} showRecommendation Whether to show the '(recommended)' |
253 * label prefix. | 253 * label prefix. |
254 * @return {string} The category description. | 254 * @return {string} The category description. |
255 * @protected | 255 * @protected |
256 */ | 256 */ |
257 computeCategoryDesc: function(category, categoryEnabled, showRecommendation) { | 257 computeCategoryDesc: function(category, setting, showRecommendation) { |
258 var categoryEnabled = this.computeIsSettingEnabled(category, setting); | |
258 switch (category) { | 259 switch (category) { |
259 case settings.ContentSettingsTypes.JAVASCRIPT: | 260 case settings.ContentSettingsTypes.JAVASCRIPT: |
260 // "Allowed (recommended)" vs "Blocked". | 261 // "Allowed (recommended)" vs "Blocked". |
261 if (!categoryEnabled) { | 262 if (!categoryEnabled) { |
262 return loadTimeData.getString('siteSettingsBlocked'); | 263 return loadTimeData.getString('siteSettingsBlocked'); |
263 } | 264 } |
264 return showRecommendation ? | 265 return showRecommendation ? |
265 loadTimeData.getString('siteSettingsAllowedRecommended') : | 266 loadTimeData.getString('siteSettingsAllowedRecommended') : |
266 loadTimeData.getString('siteSettingsAllowed'); | 267 loadTimeData.getString('siteSettingsAllowed'); |
267 case settings.ContentSettingsTypes.POPUPS: | 268 case settings.ContentSettingsTypes.POPUPS: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 loadTimeData.getString('siteSettingsHandlersAskRecommended') : | 309 loadTimeData.getString('siteSettingsHandlersAskRecommended') : |
309 loadTimeData.getString('siteSettingsHandlersAsk'); | 310 loadTimeData.getString('siteSettingsHandlersAsk'); |
310 case settings.ContentSettingsTypes.IMAGES: | 311 case settings.ContentSettingsTypes.IMAGES: |
311 if (!categoryEnabled) { | 312 if (!categoryEnabled) { |
312 return loadTimeData.getString('siteSettingsDontShowImages'); | 313 return loadTimeData.getString('siteSettingsDontShowImages'); |
313 } | 314 } |
314 return showRecommendation ? | 315 return showRecommendation ? |
315 loadTimeData.getString('siteSettingsShowAllRecommended') : | 316 loadTimeData.getString('siteSettingsShowAllRecommended') : |
316 loadTimeData.getString('siteSettingsShowAll'); | 317 loadTimeData.getString('siteSettingsShowAll'); |
317 case settings.ContentSettingsTypes.PLUGINS: | 318 case settings.ContentSettingsTypes.PLUGINS: |
318 // "Detect and run important content (recommended)" vs "Let me choose". | 319 if (setting == settings.PermissionValues.ALLOW) |
319 if (!categoryEnabled) { | 320 return loadTimeData.getString('siteSettingsFlashAllow'); |
320 return loadTimeData.getString('siteSettingsLetMeChoose'); | 321 if (setting == settings.PermissionValues.BLOCK) |
321 } | 322 return loadTimeData.getString('siteSettingsFlashBlock'); |
322 return showRecommendation ? | 323 return loadTimeData.getString('siteSettingsFlashAskBefore'); |
Finnur
2016/08/30 10:58:11
Hmmm... I just noticed that when one presses Back
tommycli
2016/08/30 16:53:42
I noticed the same thing. Looking at the contents
| |
323 loadTimeData.getString( | |
324 'siteSettingsDetectAndRunImportantRecommended') : | |
325 loadTimeData.getString('siteSettingsDetectAndRunImportant'); | |
326 case settings.ContentSettingsTypes.BACKGROUND_SYNC: | 324 case settings.ContentSettingsTypes.BACKGROUND_SYNC: |
327 // "Allow sites to finish sending and receiving data" vs "Do not allow". | 325 // "Allow sites to finish sending and receiving data" vs "Do not allow". |
328 if (!categoryEnabled) { | 326 if (!categoryEnabled) { |
329 return loadTimeData.getString('siteSettingsBackgroundSyncBlocked'); | 327 return loadTimeData.getString('siteSettingsBackgroundSyncBlocked'); |
330 } | 328 } |
331 return showRecommendation ? | 329 return showRecommendation ? |
332 loadTimeData.getString( | 330 loadTimeData.getString( |
333 'siteSettingsAllowRecentlyClosedSitesRecommended') : | 331 'siteSettingsAllowRecentlyClosedSitesRecommended') : |
334 loadTimeData.getString('siteSettingsAllowRecentlyClosedSites'); | 332 loadTimeData.getString('siteSettingsAllowRecentlyClosedSites'); |
335 case settings.ContentSettingsTypes.KEYGEN: | 333 case settings.ContentSettingsTypes.KEYGEN: |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 computeIsSettingEnabled: function(category, setting) { | 441 computeIsSettingEnabled: function(category, setting) { |
444 // FullScreen is Allow vs. Ask. | 442 // FullScreen is Allow vs. Ask. |
445 return category == settings.ContentSettingsTypes.FULLSCREEN ? | 443 return category == settings.ContentSettingsTypes.FULLSCREEN ? |
446 setting != settings.PermissionValues.ASK : | 444 setting != settings.PermissionValues.ASK : |
447 setting != settings.PermissionValues.BLOCK; | 445 setting != settings.PermissionValues.BLOCK; |
448 }, | 446 }, |
449 }; | 447 }; |
450 | 448 |
451 /** @polymerBehavior */ | 449 /** @polymerBehavior */ |
452 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; | 450 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; |
OLD | NEW |