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

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

Issue 1909413002: Site Settings: Implement dialog for adding site exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * 'add-site-dialog' provides a dialog to add exceptions for a given Content
8 * Settings category.
9 */
10 Polymer({
11 is: 'add-site-dialog',
12
13 behaviors: [SiteSettingsBehavior],
14
15 properties: {
16 /**
17 * The site to add an exception for.
18 * @private
19 */
20 site_: String,
21 },
22
23 /** Opens the dialog. */
24 open: function() {
25 this.$.dialog.open();
26 },
27
28 /**
29 * Validates that the pattern entered is valid.
30 * @private
31 */
32 validate_: function() {
33 var pattern = this.addPatternWildcard_(this.site_);
34 this.browserProxy.isPatternValid(pattern).then(function(isValid) {
35 this.$.add.disabled = !isValid;
36 }.bind(this));
37 },
38
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
56 * the dialog).
57 * @private
58 */
59 onAddTap_: function() {
60 var pattern = this.addPatternWildcard_(this.site_);
61 this.setCategoryPermissionForOrigin(
62 pattern, pattern, this.category, settings.PermissionValues.ALLOW);
63 this.$.dialog.close();
64 },
65 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698