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