Index: chrome/browser/resources/options/browser_options.js |
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js |
index 29b678496f9e59e5c60e248928e5e3daa1e81009..55454b9caf1d4d518e9785ca375c42b137cda07f 100644 |
--- a/chrome/browser/resources/options/browser_options.js |
+++ b/chrome/browser/resources/options/browser_options.js |
@@ -32,11 +32,22 @@ cr.define('options', function() { |
*/ |
onShowHomeButtonChangedCalled_: false, |
+ /** |
+ * Track if page initialization is complete. All C++ UI handlers have the |
+ * chance to manipulate page content within their InitializePage mathods. |
+ * This flag is set to true after all initializers have been called. |
+ * @type (boolean} |
+ * @private |
+ */ |
+ initializationComplete_: false, |
+ |
/** @override */ |
initializePage: function() { |
OptionsPage.prototype.initializePage.call(this); |
var self = this; |
+ this.initializationComplete_ = false; |
James Hawkins
2012/11/29 23:20:21
Why do we need to set this here? Does reinitializ
kevers
2012/11/30 19:46:25
Flag reset is redundant. Removed.
|
+ |
// Ensure that navigation events are unblocked on uber page. A reload of |
// the settings page while an overlay is open would otherwise leave uber |
// page in a blocked state, where tab switching is not possible. |
@@ -418,6 +429,16 @@ cr.define('options', function() { |
$('search-field').focus(); |
}, |
+ /** |
+ * Called after all C++ UI handlers have called InitializePage to notify |
+ * that initialization is complete. |
+ * @private |
+ */ |
+ notifyInitializationComplete_: function() { |
+ this.initializationComplete_ = true; |
+ cr.dispatchSimpleEvent(document, 'initializationComplete'); |
+ }, |
+ |
/** |
* Event listener for the 'session.restore_on_startup' pref. |
* @param {Event} event The preference change event. |
@@ -546,6 +567,17 @@ cr.define('options', function() { |
/* animate */ false); |
this.updateAdvancedSettingsExpander_(); |
} |
+ |
+ if (!this.initializationComplete_) { |
+ var self = this; |
+ var callback = function() { |
+ document.removeEventListener('initializationComplete', callback); |
+ self.scrollToSection_(section); |
+ }; |
+ document.addEventListener('initializationComplete', callback); |
+ return; |
+ } |
+ |
var pageContainer = $('page-container'); |
var pageTop = parseFloat(pageContainer.style.top); |
var topSection = document.querySelector('#page-container section'); |
@@ -1286,6 +1318,7 @@ cr.define('options', function() { |
'getCurrentProfile', |
'getStartStopSyncButton', |
'hideBluetoothSettings', |
+ 'notifyInitializationComplete', |
'removeBluetoothDevice', |
'removeCloudPrintConnectorSection', |
'scrollToSection', |