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

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

Issue 2682023002: [MD settings] allow site exceptions without pattern wildcard (Closed)
Patch Set: Created 3 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
« no previous file with comments | « chrome/browser/resources/settings/site_settings/add_site_dialog.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** @polymerBehavior */ 9 /** @polymerBehavior */
10 var SiteSettingsBehaviorImpl = { 10 var SiteSettingsBehaviorImpl = {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return url.slice(0, -4); 54 return url.slice(0, -4);
55 } 55 }
56 if (urlWithScheme.startsWith('http://') && 56 if (urlWithScheme.startsWith('http://') &&
57 urlWithScheme.endsWith(':80')) { 57 urlWithScheme.endsWith(':80')) {
58 return url.slice(0, -3); 58 return url.slice(0, -3);
59 } 59 }
60 return url; 60 return url;
61 }, 61 },
62 62
63 /** 63 /**
64 * Adds the wildcard prefix to a pattern string (if missing).
65 * @param {string} pattern The pattern to add the wildcard to.
66 * @return {string} The resulting pattern.
67 * @private
68 */
69 addPatternWildcard: function(pattern) {
70 if (pattern.indexOf('[*.]') > -1)
71 return pattern;
72 if (pattern.startsWith('http://'))
73 return pattern.replace('http://', 'http://[*.]');
74 else if (pattern.startsWith('https://'))
75 return pattern.replace('https://', 'https://[*.]');
76 else if (pattern.startsWith('chrome-extension://'))
77 return pattern; // No need for a wildcard for this.
78 else
79 return '[*.]' + pattern;
80 },
81
82 /**
83 * Removes the wildcard prefix from a pattern string. 64 * Removes the wildcard prefix from a pattern string.
84 * @param {string} pattern The pattern to remove the wildcard from. 65 * @param {string} pattern The pattern to remove the wildcard from.
85 * @return {string} The resulting pattern. 66 * @return {string} The resulting pattern.
86 * @private 67 * @private
87 */ 68 */
88 removePatternWildcard: function(pattern) { 69 removePatternWildcard: function(pattern) {
89 if (pattern.startsWith('http://[*.]')) 70 if (pattern.startsWith('http://[*.]'))
90 return pattern.replace('http://[*.]', 'http://'); 71 return pattern.replace('http://[*.]', 'http://');
91 else if (pattern.startsWith('https://[*.]')) 72 else if (pattern.startsWith('https://[*.]'))
92 return pattern.replace('https://[*.]', 'https://'); 73 return pattern.replace('https://[*.]', 'https://');
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 incognito: exception.incognito, 167 incognito: exception.incognito,
187 setting: exception.setting, 168 setting: exception.setting,
188 source: exception.source, 169 source: exception.source,
189 }; 170 };
190 }, 171 },
191 172
192 }; 173 };
193 174
194 /** @polymerBehavior */ 175 /** @polymerBehavior */
195 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; 176 var SiteSettingsBehavior = [SiteSettingsBehaviorImpl];
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings/add_site_dialog.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698