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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js
index 363d37609262bd496e72f002f868fa6ef9d92e5e..516d7304d88ef318869709bf1f5ac16c70cbf7cc 100644
--- a/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js
+++ b/chrome/browser/resources/settings/on_startup_page/startup_url_dialog.js
@@ -12,18 +12,39 @@ Polymer({
properties: {
/** @private {string} */
url_: String,
+
+ /**
+ * If specified the dialog acts as an "Edit page" dialog, otherwise as an
+ * "Add new page" dialog.
+ * @type {?StartupPageInfo}
+ */
+ model: Object,
+
+ /** @private {string} */
+ dialogTitle_: String,
+
+ /** @private {string} */
+ actionButtonText_: String,
},
/** @private {!settings.SearchEnginesBrowserProxy} */
browserProxy_: null,
/** @override */
- ready: function() {
+ attached: function() {
this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance();
- },
- /** @override */
- attached: function() {
+ if (this.model) {
+ this.dialogTitle_ = loadTimeData.getString('onStartupEditPage');
+ this.actionButtonText_ = loadTimeData.getString('onStartupEdit');
+ this.$.actionButton.disabled = false;
+ // Pre-populate the input field.
+ this.url_ = this.model.url;
+ } else {
+ this.dialogTitle_ = loadTimeData.getString('onStartupAddNewPage');
+ this.actionButtonText_ = loadTimeData.getString('add');
+ this.$.actionButton.disabled = true;
+ }
this.$.dialog.open();
},
@@ -33,8 +54,12 @@ Polymer({
},
/** @private */
- onAddTap_: function() {
- this.browserProxy_.addStartupPage(this.url_).then(function(success) {
+ onActionButtonTap_: function() {
+ var whenDone = this.model ?
+ this.browserProxy_.editStartupPage(this.model.modelIndex, this.url_) :
+ this.browserProxy_.addStartupPage(this.url_);
+
+ whenDone.then(function(success) {
if (success)
this.$.dialog.close();
// If the URL was invalid, there is nothing to do, just leave the dialog
@@ -45,7 +70,7 @@ Polymer({
/** @private */
validate_: function() {
this.browserProxy_.validateStartupPage(this.url_).then(function(isValid) {
- this.$.add.disabled = !isValid;
+ this.$.actionButton.disabled = !isValid;
}.bind(this));
},
});

Powered by Google App Engine
This is Rietveld 408576698