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

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

Issue 2021343003: MD Site Settings: Add five new top level categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test fix Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * 'add-site-dialog' provides a dialog to add exceptions for a given Content 7 * 'add-site-dialog' provides a dialog to add exceptions for a given Content
8 * Settings category. 8 * Settings category.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 19 matching lines...) Expand all
30 * @private 30 * @private
31 */ 31 */
32 validate_: function() { 32 validate_: function() {
33 var pattern = this.addPatternWildcard_(this.site_); 33 var pattern = this.addPatternWildcard_(this.site_);
34 this.browserProxy.isPatternValid(pattern).then(function(isValid) { 34 this.browserProxy.isPatternValid(pattern).then(function(isValid) {
35 this.$.add.disabled = !isValid; 35 this.$.add.disabled = !isValid;
36 }.bind(this)); 36 }.bind(this));
37 }, 37 },
38 38
39 /** 39 /**
40 * Adds the wildcard prefix to a pattern string.
41 * @param {string} pattern The pattern to add the wildcard to.
42 * @return {string} The resulting pattern.
43 * @private
44 */
45 addPatternWildcard_: function(pattern) {
46 if (pattern.startsWith('http://'))
47 return pattern.replace('http://', 'http://[*.]');
48 else if (pattern.startsWith('https://'))
49 return pattern.replace('https://', 'https://[*.]');
50 else
51 return '[*.]' + pattern;
52 },
53
54 /**
55 * The tap handler for the Add [Site] button (adds the pattern and closes 40 * The tap handler for the Add [Site] button (adds the pattern and closes
56 * the dialog). 41 * the dialog).
57 * @private 42 * @private
58 */ 43 */
59 onAddTap_: function() { 44 onAddTap_: function() {
60 var pattern = this.addPatternWildcard_(this.site_); 45 var pattern = this.addPatternWildcard_(this.site_);
61 this.setCategoryPermissionForOrigin( 46 this.setCategoryPermissionForOrigin(
62 pattern, pattern, this.category, settings.PermissionValues.ALLOW); 47 pattern, '', this.category, settings.PermissionValues.ALLOW);
63 this.$.dialog.close(); 48 this.$.dialog.close();
64 }, 49 },
65 }); 50 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698