Commit 632702aa authored by kevers@chromium.org's avatar kevers@chromium.org

Delay scroll to section until page initialization is complete.

BUG=153777


Review URL: https://chromiumcodereview.appspot.com/11414204

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170572 0039d316-1c4b-4281-b951-d872f2087c98
parent 4e04e997
......@@ -32,6 +32,15 @@ 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);
......@@ -418,6 +427,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 +565,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 +1316,7 @@ cr.define('options', function() {
'getCurrentProfile',
'getStartStopSyncButton',
'hideBluetoothSettings',
'notifyInitializationComplete',
'removeBluetoothDevice',
'removeCloudPrintConnectorSection',
'scrollToSection',
......
......@@ -378,6 +378,9 @@ void OptionsUI::InitializeHandlers() {
// do various things like show/hide sections and send data to the Javascript.
for (size_t i = 0; i < handlers_.size(); ++i)
handlers_[i]->InitializePage();
web_ui()->CallJavascriptFunction(
"BrowserOptions.notifyInitializationComplete");
}
void OptionsUI::RenderViewCreated(content::RenderViewHost* render_view_host) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment