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
3 // found in the LICENSE file.
6 * @fileoverview 'cr-settings-startup-urls-page' is the settings page
7 * containing the urls that will be opened when chrome is started.
11 * <neon-animated-pages>
12 * <cr-settings-startup-urls-page prefs="{{prefs}}">
13 * </cr-settings-startup-urls-page>
15 * </neon-animated-pages>
17 * @group Chrome Settings Elements
18 * @element cr-settings-startup-urls-page
21 is: 'cr-settings-startup-urls-page',
36 /** @type {!Array<string>} */
43 'prefsChanged_(prefs.session.startup_urls.value.*)',
46 attached: function() {
48 cr.define('Settings', function() {
50 updateStartupPages: function() {
51 return self.updateStartupPages_.apply(self, arguments);
59 prefsChanged_: function(change) {
60 if (!this.savedUrlList) {
61 var pref = /** @type {chrome.settingsPrivate.PrefObject} */(
62 this.get('prefs.session.startup_urls'));
64 this.savedUrlList = pref.value.slice();
69 updateStartupPages_: function(data) {
71 for (var i = 0; i < data.length; ++i)
72 urlArray.push(data[i].url);
73 this.set('prefs.session.startup_urls.value', urlArray);
77 onUseCurrentPagesTap_: function() {
78 chrome.send('setStartupPagesToCurrentPages');
82 onCancelTap_: function() {
83 if (this.savedUrlList !== undefined) {
84 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice());
89 onOkTap_: function() {
90 var value = this.newUrl && this.newUrl.trim();
93 this.push('prefs.session.startup_urls.value', value);
98 * @param {!{model: !{index: number}}} e
101 onRemoveUrlTap_: function(e) {
102 this.splice('prefs.session.startup_urls.value', e.model.index, 1);