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

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: Address feedback 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.addAllSitesCategory_();
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 the All Sites category to the page.
69 * @private
70 */
71 addAllSitesCategory_: function() {
72 var description = loadTimeData.getString('siteSettingsCategoryAllSites');
73 this.addCategoryImpl_(-1, 'list', description, '');
74 },
75
76 /**
68 * Adds a single category to the page. 77 * Adds a single category to the page.
69 * @param {number} category The category to add. 78 * @param {number} category The category to add.
79 * @private
70 */ 80 */
71 addCategory: function(category) { 81 addCategory_: function(category) {
72 var icon, title, categoryDescription; 82 var icon = this.computeIconForContentCategory(category);
73 if (category === -1) { 83 var title = this.computeTitleForContentCategory(category);
74 icon = 'list'; 84 var prefsProxy = settings.SiteSettingsPrefsBrowserProxy.getInstance();
75 title = loadTimeData.getString('siteSettingsCategoryAllSites'); 85 prefsProxy.getDefaultValueForContentType(
76 categoryDescription = ''; 86 category).then(function(enabled) {
77 } else { 87 var description = this.computeCategoryDesc(category, enabled, false);
78 icon = this.computeIconForContentCategory(category); 88 this.addCategoryImpl_(category, icon, title, description);
79 title = this.computeTitleForContentCategory(category); 89 }.bind(this));
80 categoryDescription = this.computeCategoryDesc( 90 },
81 category, this.isCategoryAllowed(category), false);
82 }
83 91
92 /**
93 * Constructs the actual HTML elements for the category.
94 * @param {number} category The category to add.
95 * @param {string} icon The icon to show with it.
96 * @param {string} title The title to show for the category.
97 * @param {string} defaultValue The default value (permission) for the
98 * category.
99 * @private
100 */
101 addCategoryImpl_: function(category, icon, title, defaultValue) {
84 var root = this.$.list; 102 var root = this.$.list;
85 var paperIcon = document.createElement('paper-icon-item'); 103 var paperIcon = document.createElement('paper-icon-item');
86 paperIcon.addEventListener('tap', this.onTapCategory.bind(this, category)); 104 paperIcon.addEventListener('tap', this.onTapCategory.bind(this, category));
87 105
88 var ironIcon = document.createElement('iron-icon'); 106 var ironIcon = document.createElement('iron-icon');
89 ironIcon.setAttribute('icon', icon); 107 ironIcon.setAttribute('icon', icon);
90 ironIcon.setAttribute('item-icon', ''); 108 ironIcon.setAttribute('item-icon', '');
91 109
92 var description = document.createElement('div'); 110 var description = document.createElement('div');
93 description.setAttribute('class', 'flex'); 111 description.setAttribute('class', 'flex');
94 description.appendChild(document.createTextNode(title)); 112 description.appendChild(document.createTextNode(title));
95 var setting = document.createElement('div'); 113 var setting = document.createElement('div');
96 setting.setAttribute('class', 'option-value'); 114 setting.setAttribute('class', 'option-value');
97 115
98 setting.appendChild(document.createTextNode(categoryDescription)); 116 setting.appendChild(document.createTextNode(defaultValue));
99 117
100 paperIcon.appendChild(ironIcon); 118 paperIcon.appendChild(ironIcon);
101 paperIcon.appendChild(description); 119 paperIcon.appendChild(description);
102 paperIcon.appendChild(setting); 120 paperIcon.appendChild(setting);
103 root.appendChild(paperIcon); 121 root.appendChild(paperIcon);
104 }, 122 },
105 123
106 /** 124 /**
107 * Handles selection of a single category and navigates to the details for 125 * Handles selection of a single category and navigates to the details for
108 * that category. 126 * that category.
(...skipping 11 matching lines...) Expand all
120 this.categorySelected = this.computeCategoryTextId(category); 138 this.categorySelected = this.computeCategoryTextId(category);
121 this.currentRoute = { 139 this.currentRoute = {
122 page: this.currentRoute.page, 140 page: this.currentRoute.page,
123 section: 'privacy', 141 section: 'privacy',
124 subpage: ['site-settings', 'site-settings-category-' + 142 subpage: ['site-settings', 'site-settings-category-' +
125 this.categorySelected], 143 this.categorySelected],
126 }; 144 };
127 } 145 }
128 }, 146 },
129 }); 147 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698