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

Side by Side Diff: chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js

Issue 1882483002: MD Settings: OnStartup, implementing "Edit" functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@edit_on_startup_move_delete
Patch Set: Nit. 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
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 'settings-startup-url-dialog' is a component for adding 6 * @fileoverview 'settings-startup-url-dialog' is a component for adding
7 * or editing a startup URL entry. 7 * or editing a startup URL entry.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-startup-url-dialog', 10 is: 'settings-startup-url-dialog',
11 11
12 properties: { 12 properties: {
13 /** @private {string} */ 13 /** @private {string} */
14 url_: String, 14 url_: String,
15
16 /**
17 * If specified the dialog acts as an "Edit page" dialog, otherwise as an
18 * "Add new page" dialog.
19 * @type {?StartupPageInfo}
20 */
21 model: Object,
22
23 /** @private {string} */
24 dialogTitle_: String,
25
26 /** @private {string} */
27 actionButtonText_: String,
15 }, 28 },
16 29
17 /** @private {!settings.SearchEnginesBrowserProxy} */ 30 /** @private {!settings.SearchEnginesBrowserProxy} */
18 browserProxy_: null, 31 browserProxy_: null,
19 32
20 /** @override */ 33 /** @override */
21 ready: function() { 34 attached: function() {
22 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); 35 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance();
23 },
24 36
25 /** @override */ 37 if (this.model) {
26 attached: function() { 38 this.dialogTitle_ = loadTimeData.getString('onStartupEditPage');
39 this.actionButtonText_ = loadTimeData.getString('onStartupEdit');
40 this.$.actionButton.disabled = false;
41 // Pre-populate the input field.
42 this.url_ = this.model.url;
43 } else {
44 this.dialogTitle_ = loadTimeData.getString('onStartupAddNewPage');
45 this.actionButtonText_ = loadTimeData.getString('add');
46 this.$.actionButton.disabled = true;
47 }
27 this.$.dialog.open(); 48 this.$.dialog.open();
28 }, 49 },
29 50
30 /** @private */ 51 /** @private */
31 onCancelTap_: function() { 52 onCancelTap_: function() {
32 this.$.dialog.close(); 53 this.$.dialog.close();
33 }, 54 },
34 55
35 /** @private */ 56 /** @private */
36 onAddTap_: function() { 57 onActionButtonTap_: function() {
37 this.browserProxy_.addStartupPage(this.url_).then(function(success) { 58 var whenDone = this.model ?
59 this.browserProxy_.editStartupPage(this.model.modelIndex, this.url_) :
60 this.browserProxy_.addStartupPage(this.url_);
61
62 whenDone.then(function(success) {
38 if (success) 63 if (success)
39 this.$.dialog.close(); 64 this.$.dialog.close();
40 // If the URL was invalid, there is nothing to do, just leave the dialog 65 // If the URL was invalid, there is nothing to do, just leave the dialog
41 // open and let the user fix the URL or cancel. 66 // open and let the user fix the URL or cancel.
42 }.bind(this)); 67 }.bind(this));
43 }, 68 },
44 69
45 /** @private */ 70 /** @private */
46 validate_: function() { 71 validate_: function() {
47 this.browserProxy_.validateStartupPage(this.url_).then(function(isValid) { 72 this.browserProxy_.validateStartupPage(this.url_).then(function(isValid) {
48 this.$.add.disabled = !isValid; 73 this.$.actionButton.disabled = !isValid;
49 }.bind(this)); 74 }.bind(this));
50 }, 75 },
51 }); 76 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698