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

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: Sync to head 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 *
michaelpg 2016/04/24 19:58:40 nit: remove blank line
Finnur 2016/04/25 10:23:12 Done.
10 */
11 Polymer({
12 is: 'add-site-dialog',
13
14 behaviors: [SiteSettingsBehavior],
15
16 /**
17 * Opens the dialog.
michaelpg 2016/04/24 19:58:40 nit: /** Opens... */
Finnur 2016/04/25 10:23:13 Done.
18 */
19 open: function() {
20 this.$.dialog.open();
21 },
22
23 /**
24 * Validates that the pattern entered is valid.
25 * @private
26 */
27 validate_: function() {
28 var pattern = this.ensurePatternWildcard_(this.site_);
29 this.browserProxy.isPatternValid(pattern).then(function(isValid) {
30 this.$.add.disabled = !isValid;
31 }.bind(this));
32 },
33
34 /**
35 * Adds the wildcard prefix to a pattern string.
36 * @param {string} pattern The pattern to add the wildcard to.
37 * @return {string} The resulting pattern.
38 * @private
39 */
40 ensurePatternWildcard_: function(pattern) {
michaelpg 2016/04/24 19:58:40 nit... "ensure" is misleading, makes me think this
Finnur 2016/04/25 10:23:13 Done.
41 if (pattern.startsWith('http://'))
42 return pattern.replace('http://', 'http://[*.]');
43 else if (pattern.startsWith('https://'))
44 return pattern.replace('https://', 'https://[*.]');
45 else
46 return '[*.]' + pattern;
47 },
48
49 /**
50 * The tap handler for the Add [Site] button (adds the pattern and closes
51 * the dialog).
52 * @private
53 */
54 onAddTap_: function() {
55 var pattern = this.ensurePatternWildcard_(this.site_);
michaelpg 2016/04/24 19:58:40 add "site_: String" to |properties|, please
Finnur 2016/04/25 10:23:12 Done.
56 this.setCategoryPermissionForOrigin(
57 pattern, pattern, this.category, settings.PermissionValues.ALLOW);
58
59 // Make sure the text box is empty when you open it next time.
michaelpg 2016/04/24 19:58:40 not needed if you create/remove the dialog on dema
Finnur 2016/04/25 10:23:13 Done.
60 this.site_ = '';
61 this.$.dialog.close();
62 },
63 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698