OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 const OptionsPage = options.OptionsPage; | 6 const OptionsPage = options.OptionsPage; |
7 const ArrayDataModel = cr.ui.ArrayDataModel; | 7 const ArrayDataModel = cr.ui.ArrayDataModel; |
8 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 8 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
9 | 9 |
10 // | 10 // |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 OptionsPage.showOverlay('instantConfirmOverlay'); | 62 OptionsPage.showOverlay('instantConfirmOverlay'); |
63 } | 63 } |
64 }; | 64 }; |
65 $('defaultSearchEngine').onchange = this.setDefaultSearchEngine; | 65 $('defaultSearchEngine').onchange = this.setDefaultSearchEngine; |
66 | 66 |
67 var homepageField = $('homepageURL'); | 67 var homepageField = $('homepageURL'); |
68 $('homepageUseNTPButton').onchange = | 68 $('homepageUseNTPButton').onchange = |
69 this.handleHomepageUseNTPButtonChange_.bind(this); | 69 this.handleHomepageUseNTPButtonChange_.bind(this); |
70 $('homepageUseURLButton').onchange = | 70 $('homepageUseURLButton').onchange = |
71 this.handleHomepageUseURLButtonChange_.bind(this); | 71 this.handleHomepageUseURLButtonChange_.bind(this); |
72 homepageField.onchange = | 72 homepageField.onchange = this.handleHomepageURLChange_.bind(this); |
73 this.handleHomepageURLChange_.bind(this); | 73 homepageField.oninput = this.handleHomepageURLChange_.bind(this); |
74 | 74 |
75 // Ensure that changes are committed when closing the page. | 75 // Ensure that changes are committed when closing the page. |
76 window.addEventListener('unload', function() { | 76 window.addEventListener('unload', function() { |
77 if (document.activeElement == homepageField) | 77 if (document.activeElement == homepageField) |
78 homepageField.blur(); | 78 homepageField.blur(); |
79 }); | 79 }); |
80 | 80 |
81 if (!cr.isChromeOS) { | 81 if (!cr.isChromeOS) { |
82 $('defaultBrowserUseAsDefaultButton').onclick = function(event) { | 82 $('defaultBrowserUseAsDefaultButton').onclick = function(event) { |
83 chrome.send('becomeDefaultBrowser'); | 83 chrome.send('becomeDefaultBrowser'); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 /** | 196 /** |
197 * Handles change events of the radio button 'homepageUseNTPButton'. | 197 * Handles change events of the radio button 'homepageUseNTPButton'. |
198 * @private | 198 * @private |
199 * @param {event} change event. | 199 * @param {event} change event. |
200 */ | 200 */ |
201 handleHomepageUseNTPButtonChange_: function(event) { | 201 handleHomepageUseNTPButtonChange_: function(event) { |
202 Preferences.setBooleanPref('homepage_is_newtabpage', true); | 202 Preferences.setBooleanPref('homepage_is_newtabpage', true); |
203 }, | 203 }, |
204 | 204 |
205 /** | 205 /** |
206 * Handles change events of the text field 'homepageURL'. | 206 * Handles input and change events of the text field 'homepageURL'. |
207 * @private | 207 * @private |
208 * @param {event} change event. | 208 * @param {event} input/change event. |
209 */ | 209 */ |
210 handleHomepageURLChange_: function(event) { | 210 handleHomepageURLChange_: function(event) { |
211 Preferences.setStringPref('homepage', $('homepageURL').value); | 211 var doFixup = event.type == 'change' ? '1' : '0'; |
| 212 chrome.send('setHomePage', [$('homepageURL').value, doFixup]); |
212 }, | 213 }, |
213 | 214 |
214 /** | 215 /** |
215 * Handle change events of the preference 'homepage'. | 216 * Handle change events of the preference 'homepage'. |
216 * @private | 217 * @private |
217 * @param {event} preference changed event. | 218 * @param {event} preference changed event. |
218 */ | 219 */ |
219 handleHomepageChange_: function(event) { | 220 handleHomepageChange_: function(event) { |
220 this.homepage_pref_.value = event.value['value']; | 221 this.homepage_pref_.value = event.value['value']; |
221 this.homepage_pref_.managed = event.value['managed']; | 222 this.homepage_pref_.managed = event.value['managed']; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 BrowserOptions.getInstance().updateStartupPages_(pages); | 379 BrowserOptions.getInstance().updateStartupPages_(pages); |
379 StartupPageManager.getInstance().updateStartupPages_(pages); | 380 StartupPageManager.getInstance().updateStartupPages_(pages); |
380 }; | 381 }; |
381 | 382 |
382 // Export | 383 // Export |
383 return { | 384 return { |
384 BrowserOptions: BrowserOptions | 385 BrowserOptions: BrowserOptions |
385 }; | 386 }; |
386 | 387 |
387 }); | 388 }); |
OLD | NEW |