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 | 9 |
10 /** | 10 /** |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (pattern.startsWith('http://[*.]')) | 88 if (pattern.startsWith('http://[*.]')) |
89 return pattern.replace('http://[*.]', 'http://'); | 89 return pattern.replace('http://[*.]', 'http://'); |
90 else if (pattern.startsWith('https://[*.]')) | 90 else if (pattern.startsWith('https://[*.]')) |
91 return pattern.replace('https://[*.]', 'https://'); | 91 return pattern.replace('https://[*.]', 'https://'); |
92 else if (pattern.startsWith('[*.]')) | 92 else if (pattern.startsWith('[*.]')) |
93 return pattern.substring(4, pattern.length); | 93 return pattern.substring(4, pattern.length); |
94 return pattern; | 94 return pattern; |
95 }, | 95 }, |
96 | 96 |
97 /** | 97 /** |
98 * Looks up the human-friendly embedder string to show in the UI. | |
99 * @param {string} embeddingOrigin The embedding origin to show. | |
100 * @param {string} category The category requesting it. | |
101 * @return {string} The string to show. | |
102 */ | |
103 getEmbedderString: function(embeddingOrigin, category) { | |
104 if (embeddingOrigin == '') { | |
105 if (category != settings.ContentSettingsTypes.GEOLOCATION) | |
106 return ''; | |
107 return loadTimeData.getStringF('embeddedOnHost', '*'); | |
108 } | |
109 return loadTimeData.getStringF( | |
110 'embeddedOnHost', this.sanitizePort(embeddingOrigin)); | |
111 }, | |
112 | |
113 /** | |
114 * Returns the icon to use for a given site. | 98 * Returns the icon to use for a given site. |
115 * @param {string} site The url of the site to fetch the icon for. | 99 * @param {string} site The url of the site to fetch the icon for. |
116 * @return {string} The background-image style with the favicon. | 100 * @return {string} The background-image style with the favicon. |
117 * @private | 101 * @private |
118 */ | 102 */ |
119 computeSiteIcon: function(site) { | 103 computeSiteIcon: function(site) { |
120 var url = this.ensureUrlHasScheme(site); | 104 var url = this.ensureUrlHasScheme(site); |
121 return 'background-image: ' + cr.icon.getFavicon(url); | 105 return 'background-image: ' + cr.icon.getFavicon(url); |
122 }, | 106 }, |
123 | 107 |
(...skipping 29 matching lines...) Expand all Loading... |
153 /** | 137 /** |
154 * Convert an exception (received from the C++ handler) to a full | 138 * Convert an exception (received from the C++ handler) to a full |
155 * SiteException. | 139 * SiteException. |
156 * @param {!RawSiteException} exception The raw site exception from C++. | 140 * @param {!RawSiteException} exception The raw site exception from C++. |
157 * @return {!SiteException} The expanded (full) SiteException. | 141 * @return {!SiteException} The expanded (full) SiteException. |
158 * @private | 142 * @private |
159 */ | 143 */ |
160 expandSiteException: function(exception) { | 144 expandSiteException: function(exception) { |
161 var origin = exception.origin; | 145 var origin = exception.origin; |
162 var embeddingOrigin = exception.embeddingOrigin; | 146 var embeddingOrigin = exception.embeddingOrigin; |
163 var embeddingDisplayName = ''; | |
164 if (origin != embeddingOrigin) { | |
165 embeddingDisplayName = | |
166 this.getEmbedderString(embeddingOrigin, this.category); | |
167 } | |
168 | 147 |
169 var enforcement = ''; | 148 var enforcement = ''; |
170 if (exception.source == 'extension' || exception.source == 'HostedApp' || | 149 if (exception.source == 'extension' || exception.source == 'HostedApp' || |
171 exception.source == 'platform_app' || exception.source == 'policy') { | 150 exception.source == 'platform_app' || exception.source == 'policy') { |
172 enforcement = chrome.settingsPrivate.Enforcement.ENFORCED; | 151 enforcement = chrome.settingsPrivate.Enforcement.ENFORCED; |
173 } | 152 } |
174 | 153 |
175 var controlledBy = kControlledByLookup[exception.source] || ''; | 154 var controlledBy = kControlledByLookup[exception.source] || ''; |
176 | 155 |
177 return { | 156 return { |
178 category: this.category, | 157 category: this.category, |
179 origin: origin, | 158 origin: origin, |
180 displayName: exception.displayName, | 159 displayName: exception.displayName, |
181 embeddingOrigin: embeddingOrigin, | 160 embeddingOrigin: embeddingOrigin, |
182 embeddingDisplayName: embeddingDisplayName, | |
183 incognito: exception.incognito, | 161 incognito: exception.incognito, |
184 setting: exception.setting, | 162 setting: exception.setting, |
185 enforcement: enforcement, | 163 enforcement: enforcement, |
186 controlledBy: controlledBy, | 164 controlledBy: controlledBy, |
187 }; | 165 }; |
188 }, | 166 }, |
189 | 167 |
190 }; | 168 }; |
191 | 169 |
192 /** @polymerBehavior */ | 170 /** @polymerBehavior */ |
193 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; | 171 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; |
OLD | NEW |