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

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

Issue 1344613002: [MD settings] on startup use current pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 'cr-settings-startup-urls-page' is the settings page 6 * @fileoverview 'cr-settings-startup-urls-page' is the settings page
7 * containing the urls that will be opened when chrome is started. 7 * containing the urls that will be opened when chrome is started.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
(...skipping 18 matching lines...) Expand all
29 notify: true, 29 notify: true,
30 }, 30 },
31 31
32 newUrl: { 32 newUrl: {
33 type: String, 33 type: String,
34 }, 34 },
35 35
36 /** @type {!Array<string>} */ 36 /** @type {!Array<string>} */
37 savedUrlList: { 37 savedUrlList: {
38 type: Array, 38 type: Array,
39 value: function() { return []; }
40 }, 39 },
41 }, 40 },
42 41
42 observers: [
43 'prefsChanged_(prefs.session.startup_urls.value.*)',
44 ],
45
46 attached: function() {
47 var updateFunction = this.updateStartupPages_.bind(this);
48 cr.define('Settings', function() {
49 return {
50 updateStartupPages: updateFunction,
51 };
52 });
53 },
54
55 /** @private */
56 prefsChanged_: function(change) {
57 if (this.savedUrlList == undefined &&
58 this.get('prefs.session.startup_urls')) {
59 this.savedUrlList = this.prefs.session.startup_urls.value.slice();
60 }
61 },
62
63 /** @private */
64 updateStartupPages_: function(data) {
65 var urlArray = [];
66 for (var i = 0; i < data.length; ++i)
67 urlArray.push(data[i].url);
68 this.set('prefs.session.startup_urls.value', urlArray);
69 },
70
43 /** @private */ 71 /** @private */
44 onUseCurrentPagesTap_: function() { 72 onUseCurrentPagesTap_: function() {
45 // TODO(dschuyler): I'll be making a chrome.send call here. 73 chrome.send('setStartupPagesToCurrentPages');
46 }, 74 },
47 75
48 /** @private */ 76 /** @private */
49 onCancelTap_: function() { 77 onCancelTap_: function() {
50 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice()); 78 if (this.savedUrlList !== undefined) {
79 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice());
80 }
51 }, 81 },
52 82
53 /** @private */ 83 /** @private */
54 onOkTap_: function() { 84 onOkTap_: function() {
55 var value = this.newUrl && this.newUrl.trim(); 85 var value = this.newUrl && this.newUrl.trim();
56 if (!value) 86 if (!value)
57 return; 87 return;
58 this.push('prefs.session.startup_urls.value', value); 88 this.push('prefs.session.startup_urls.value', value);
59 this.newUrl = ''; 89 this.newUrl = '';
60 }, 90 },
61 91
62 /** 92 /**
63 * @param {!{model: !{index: number}}} e 93 * @param {!{model: !{index: number}}} e
64 * @private 94 * @private
65 */ 95 */
66 onRemoveUrlTap_: function(e) { 96 onRemoveUrlTap_: function(e) {
67 this.splice('prefs.session.startup_urls.value', e.model.index, 1); 97 this.splice('prefs.session.startup_urls.value', e.model.index, 1);
68 }, 98 },
69 }); 99 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698