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

Side by Side Diff: chrome/browser/resources/settings/site_settings_page/site_settings_page.js

Issue 1698093007: Convert SiteSettingsCategory to use the HostContentSettingsMap instead of (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'ed Created 4 years, 10 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 * 'settings-site-settings-page' is the settings page containing privacy and 7 * 'settings-site-settings-page' is the settings page containing privacy and
8 * security site settings. 8 * security site settings.
9 * 9 *
10 * Example: 10 * Example:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 * The category selected by the user. 44 * The category selected by the user.
45 */ 45 */
46 categorySelected: { 46 categorySelected: {
47 type: String, 47 type: String,
48 notify: true, 48 notify: true,
49 }, 49 },
50 }, 50 },
51 51
52 ready: function() { 52 ready: function() {
53 CrSettingsPrefs.initialized.then(function() { 53 CrSettingsPrefs.initialized.then(function() {
54 this.addCategory(-1); // Every category (All Sites). 54 this.addCategory_(-1); // Every category (All Sites).
tommycli 2016/02/18 22:15:19 Ahh... the -1 sentinel value seems confusing. What
55 this.addCategory(settings.ContentSettingsTypes.COOKIES); 55 this.addCategory_(settings.ContentSettingsTypes.COOKIES);
56 this.addCategory(settings.ContentSettingsTypes.GEOLOCATION); 56 this.addCategory_(settings.ContentSettingsTypes.GEOLOCATION);
57 this.addCategory(settings.ContentSettingsTypes.CAMERA); 57 this.addCategory_(settings.ContentSettingsTypes.CAMERA);
58 this.addCategory(settings.ContentSettingsTypes.MIC); 58 this.addCategory_(settings.ContentSettingsTypes.MIC);
59 this.addCategory(settings.ContentSettingsTypes.JAVASCRIPT); 59 this.addCategory_(settings.ContentSettingsTypes.JAVASCRIPT);
60 this.addCategory(settings.ContentSettingsTypes.POPUPS); 60 this.addCategory_(settings.ContentSettingsTypes.POPUPS);
61 this.addCategory(settings.ContentSettingsTypes.FULLSCREEN); 61 this.addCategory_(settings.ContentSettingsTypes.FULLSCREEN);
62 this.addCategory(settings.ContentSettingsTypes.NOTIFICATIONS); 62 this.addCategory_(settings.ContentSettingsTypes.NOTIFICATIONS);
63 this.addCategory(settings.ContentSettingsTypes.IMAGES); 63 this.addCategory_(settings.ContentSettingsTypes.IMAGES);
64 }.bind(this)); 64 }.bind(this));
65 }, 65 },
66 66
67 /** 67 /**
68 * Adds a single category to the page. 68 * Adds a single category to the page.
69 * @param {number} category The category to add. 69 * @param {number} category The category to add.
70 * @private
70 */ 71 */
71 addCategory: function(category) { 72 addCategory_: function(category) {
72 var icon, title, categoryDescription;
73 if (category === -1) { 73 if (category === -1) {
74 icon = 'list'; 74 var description = loadTimeData.getString('siteSettingsCategoryAllSites');
75 title = loadTimeData.getString('siteSettingsCategoryAllSites'); 75 this.addCategoryImpl_(category, 'list', description, '');
76 categoryDescription = ''; 76 return;
77 } else {
78 icon = this.computeIconForContentCategory(category);
79 title = this.computeTitleForContentCategory(category);
80 categoryDescription = this.computeCategoryDesc(
81 category, this.isCategoryAllowed(category), false);
82 } 77 }
83 78
79 var icon = this.computeIconForContentCategory(category);
80 var title = this.computeTitleForContentCategory(category);
81 settings.SiteSettingsPrefsProxy.getInstance().getDefaultValueForContentType(
82 category).then(function(enabled) {
83 var description = this.computeCategoryDesc(category, enabled, false);
84 this.addCategoryImpl_(category, icon, title, description);
85 }.bind(this));
86 },
87
88 /**
89 * Constructs the actual HTML elements for the category.
90 * @param {number} category The category to add.
91 * @param {string} icon The icon to show with it.
92 * @param {string} title The title to show for the category.
93 * @param {string} defaultValue The default value (permission) for the
94 * category.
95 * @private
96 */
97 addCategoryImpl_: function(category, icon, title, defaultValue) {
84 var root = this.$.list; 98 var root = this.$.list;
85 var paperIcon = document.createElement('paper-icon-item'); 99 var paperIcon = document.createElement('paper-icon-item');
86 paperIcon.addEventListener('tap', this.onTapCategory.bind(this, category)); 100 paperIcon.addEventListener('tap', this.onTapCategory.bind(this, category));
87 101
88 var ironIcon = document.createElement('iron-icon'); 102 var ironIcon = document.createElement('iron-icon');
89 ironIcon.setAttribute('icon', icon); 103 ironIcon.setAttribute('icon', icon);
90 ironIcon.setAttribute('item-icon', ''); 104 ironIcon.setAttribute('item-icon', '');
91 105
92 var description = document.createElement('div'); 106 var description = document.createElement('div');
93 description.setAttribute('class', 'flex'); 107 description.setAttribute('class', 'flex');
94 description.appendChild(document.createTextNode(title)); 108 description.appendChild(document.createTextNode(title));
95 var setting = document.createElement('div'); 109 var setting = document.createElement('div');
96 setting.setAttribute('class', 'option-value'); 110 setting.setAttribute('class', 'option-value');
97 111
98 setting.appendChild(document.createTextNode(categoryDescription)); 112 setting.appendChild(document.createTextNode(defaultValue));
99 113
100 paperIcon.appendChild(ironIcon); 114 paperIcon.appendChild(ironIcon);
101 paperIcon.appendChild(description); 115 paperIcon.appendChild(description);
102 paperIcon.appendChild(setting); 116 paperIcon.appendChild(setting);
103 root.appendChild(paperIcon); 117 root.appendChild(paperIcon);
104 }, 118 },
105 119
106 /** 120 /**
107 * Handles selection of a single category and navigates to the details for 121 * Handles selection of a single category and navigates to the details for
108 * that category. 122 * that category.
(...skipping 11 matching lines...) Expand all
120 this.categorySelected = this.computeCategoryTextId(category); 134 this.categorySelected = this.computeCategoryTextId(category);
121 this.currentRoute = { 135 this.currentRoute = {
122 page: this.currentRoute.page, 136 page: this.currentRoute.page,
123 section: 'privacy', 137 section: 'privacy',
124 subpage: ['site-settings', 'site-settings-category-' + 138 subpage: ['site-settings', 'site-settings-category-' +
125 this.categorySelected], 139 this.categorySelected],
126 }; 140 };
127 } 141 }
128 }, 142 },
129 }); 143 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698