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

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_settings_behavior.js

Issue 2769303004: [MD setting] tool tips on controlledBy site exceptions (Closed)
Patch Set: Created 3 years, 9 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 Behavior common to Site Settings classes. 6 * @fileoverview Behavior common to Site Settings classes.
7 */ 7 */
8 8
9
10 /**
11 * The source information on site exceptions doesn't exactly match the
12 * controlledBy values.
13 * TODO(dschuyler): Can they be unified (and this dictionary removed)?
14 * @type {!Object}
15 */
16 var kControlledByLookup = {
17 'extension': chrome.settingsPrivate.ControlledBy.EXTENSION,
18 'HostedApp': chrome.settingsPrivate.ControlledBy.EXTENSION,
19 'platform_app': chrome.settingsPrivate.ControlledBy.EXTENSION,
20 'policy': chrome.settingsPrivate.ControlledBy.USER_POLICY,
21 };
22
23
9 /** @polymerBehavior */ 24 /** @polymerBehavior */
10 var SiteSettingsBehaviorImpl = { 25 var SiteSettingsBehaviorImpl = {
11 properties: { 26 properties: {
12 /** 27 /**
13 * The string ID of the category this element is displaying data for. 28 * The string ID of the category this element is displaying data for.
14 * See site_settings/constants.js for possible values. 29 * See site_settings/constants.js for possible values.
15 * @type {!settings.ContentSettingsTypes} 30 * @type {!settings.ContentSettingsTypes}
16 */ 31 */
17 category: String, 32 category: String,
18 33
(...skipping 13 matching lines...) Expand all
32 ready: function() { 47 ready: function() {
33 this.PermissionValues = settings.PermissionValues; 48 this.PermissionValues = settings.PermissionValues;
34 }, 49 },
35 50
36 /** 51 /**
37 * Ensures the URL has a scheme (assumes http if omitted). 52 * Ensures the URL has a scheme (assumes http if omitted).
38 * @param {string} url The URL with or without a scheme. 53 * @param {string} url The URL with or without a scheme.
39 * @return {string} The URL with a scheme, or an empty string. 54 * @return {string} The URL with a scheme, or an empty string.
40 */ 55 */
41 ensureUrlHasScheme: function(url) { 56 ensureUrlHasScheme: function(url) {
42 if (url.length == 0) return url; 57 if (url.length == 0)
58 return url;
43 return url.includes('://') ? url : 'http://' + url; 59 return url.includes('://') ? url : 'http://' + url;
44 }, 60 },
45 61
46 /** 62 /**
47 * Removes redundant ports, such as port 80 for http and 443 for https. 63 * Removes redundant ports, such as port 80 for http and 443 for https.
48 * @param {string} url The URL to sanitize. 64 * @param {string} url The URL to sanitize.
49 * @return {string} The URL without redundant ports, if any. 65 * @return {string} The URL without redundant ports, if any.
50 */ 66 */
51 sanitizePort: function(url) { 67 sanitizePort: function(url) {
52 var urlWithScheme = this.ensureUrlHasScheme(url); 68 var urlWithScheme = this.ensureUrlHasScheme(url);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (embeddingOrigin == '') { 103 if (embeddingOrigin == '') {
88 if (category != settings.ContentSettingsTypes.GEOLOCATION) 104 if (category != settings.ContentSettingsTypes.GEOLOCATION)
89 return ''; 105 return '';
90 return loadTimeData.getStringF('embeddedOnHost', '*'); 106 return loadTimeData.getStringF('embeddedOnHost', '*');
91 } 107 }
92 return loadTimeData.getStringF( 108 return loadTimeData.getStringF(
93 'embeddedOnHost', this.sanitizePort(embeddingOrigin)); 109 'embeddedOnHost', this.sanitizePort(embeddingOrigin));
94 }, 110 },
95 111
96 /** 112 /**
97 * Returns true if this exception is controlled by, for example, a policy or
98 * set by an extension.
99 * @param {string} source The source controlling the extension
100 * @return {boolean} Whether it is being controlled.
101 * @protected
102 */
103 isExceptionControlled_: function(source) {
104 return source != undefined && source != 'preference';
105 },
106
107 /**
108 * Returns the icon to use for a given site. 113 * Returns the icon to use for a given site.
109 * @param {string} site The url of the site to fetch the icon for. 114 * @param {string} site The url of the site to fetch the icon for.
110 * @return {string} The background-image style with the favicon. 115 * @return {string} The background-image style with the favicon.
111 * @private 116 * @private
112 */ 117 */
113 computeSiteIcon: function(site) { 118 computeSiteIcon: function(site) {
114 var url = this.ensureUrlHasScheme(site); 119 var url = this.ensureUrlHasScheme(site);
115 return 'background-image: ' + cr.icon.getFavicon(url); 120 return 'background-image: ' + cr.icon.getFavicon(url);
116 }, 121 },
117 122
(...skipping 23 matching lines...) Expand all
141 // as well. 146 // as well.
142 originOrPattern = originOrPattern.replace('*://', ''); 147 originOrPattern = originOrPattern.replace('*://', '');
143 originOrPattern = originOrPattern.replace('[*.]', ''); 148 originOrPattern = originOrPattern.replace('[*.]', '');
144 return new URL(this.ensureUrlHasScheme(originOrPattern)); 149 return new URL(this.ensureUrlHasScheme(originOrPattern));
145 }, 150 },
146 151
147 /** 152 /**
148 * Convert an exception (received from the C++ handler) to a full 153 * Convert an exception (received from the C++ handler) to a full
149 * SiteException. 154 * SiteException.
150 * @param {!RawSiteException} exception The raw site exception from C++. 155 * @param {!RawSiteException} exception The raw site exception from C++.
151 * @return {SiteException} The expanded (full) SiteException. 156 * @return {!SiteException} The expanded (full) SiteException.
152 * @private 157 * @private
153 */ 158 */
154 expandSiteException: function(exception) { 159 expandSiteException: function(exception) {
155 var origin = exception.origin; 160 var origin = exception.origin;
156 var embeddingOrigin = exception.embeddingOrigin; 161 var embeddingOrigin = exception.embeddingOrigin;
157 var embeddingDisplayName = ''; 162 var embeddingDisplayName = '';
158 if (origin != embeddingOrigin) { 163 if (origin != embeddingOrigin) {
159 embeddingDisplayName = 164 embeddingDisplayName =
160 this.getEmbedderString(embeddingOrigin, this.category); 165 this.getEmbedderString(embeddingOrigin, this.category);
161 } 166 }
162 167
168 var enforcement = '';
tommycli 2017/03/27 16:02:07 Hmm it seems like the enum only has these two poss
dschuyler 2017/03/28 01:05:53 There are three states that enforcement of a setti
tommycli 2017/03/28 16:20:44 I'm surprised that closure considers '' a valid va
dschuyler 2017/03/28 19:27:05 I see what you mean. It likely should not allow it
169 if (exception.source == 'policy' || exception.source == 'extension')
170 enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
171
172 var controlledBy = kControlledByLookup[exception.source] || '';
173
163 return { 174 return {
164 category: this.category, 175 category: this.category,
165 origin: origin, 176 origin: origin,
166 displayName: exception.displayName, 177 displayName: exception.displayName,
167 embeddingOrigin: embeddingOrigin, 178 embeddingOrigin: embeddingOrigin,
168 embeddingDisplayName: embeddingDisplayName, 179 embeddingDisplayName: embeddingDisplayName,
169 incognito: exception.incognito, 180 incognito: exception.incognito,
170 setting: exception.setting, 181 setting: exception.setting,
171 source: exception.source, 182 enforcement: enforcement,
183 controlledBy: controlledBy,
172 }; 184 };
173 }, 185 },
174 186
175 }; 187 };
176 188
177 /** @polymerBehavior */ 189 /** @polymerBehavior */
178 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; 190 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698