Commit 2afa7717 authored by nyquist@chromium.org's avatar nyquist@chromium.org

Ensure sync footer visibility is always set correctly.

There is currently a race condition on updating the sync footer
visibility on the welcome page. If the web page is created after the
initial sync footer visibility state is sent, it is never sent again.

This CL ensures that on startup, the state will always be correct.

BUG=267352

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217090 0039d316-1c4b-4281-b951-d872f2087c98
parent a2198523
...@@ -42,7 +42,7 @@ void WelcomeHandler::RegisterMessages() { ...@@ -42,7 +42,7 @@ void WelcomeHandler::RegisterMessages() {
} }
void WelcomeHandler::HandleUpdateSyncFooterVisibility(const ListValue* args) { void WelcomeHandler::HandleUpdateSyncFooterVisibility(const ListValue* args) {
OnStateChanged(); UpdateSyncFooterVisibility(true);
} }
void WelcomeHandler::HandleShowSyncSettings(const ListValue* args) { void WelcomeHandler::HandleShowSyncSettings(const ListValue* args) {
...@@ -54,10 +54,14 @@ void WelcomeHandler::HandleShowTermsOfService(const ListValue* args) { ...@@ -54,10 +54,14 @@ void WelcomeHandler::HandleShowTermsOfService(const ListValue* args) {
} }
void WelcomeHandler::OnStateChanged() { void WelcomeHandler::OnStateChanged() {
UpdateSyncFooterVisibility(false);
}
void WelcomeHandler::UpdateSyncFooterVisibility(bool forced) {
bool is_sync_enabled = bool is_sync_enabled =
sync_service_ && sync_service_->IsSyncEnabledAndLoggedIn(); sync_service_ && sync_service_->IsSyncEnabledAndLoggedIn();
if (is_sync_footer_visible_ != is_sync_enabled) { if (forced || is_sync_footer_visible_ != is_sync_enabled) {
is_sync_footer_visible_ = is_sync_enabled; is_sync_footer_visible_ = is_sync_enabled;
web_ui()->CallJavascriptFunction("welcome.setSyncFooterVisible", web_ui()->CallJavascriptFunction("welcome.setSyncFooterVisible",
base::FundamentalValue(is_sync_enabled)); base::FundamentalValue(is_sync_enabled));
......
...@@ -40,6 +40,11 @@ class WelcomeHandler : public content::WebUIMessageHandler, ...@@ -40,6 +40,11 @@ class WelcomeHandler : public content::WebUIMessageHandler,
virtual void OnStateChanged() OVERRIDE; virtual void OnStateChanged() OVERRIDE;
private: private:
// Update the sync footer visibility. Set |forced| if you want to force to
// send an update to the renderer regardless of whether we assume the state
// is up to date or not.
void UpdateSyncFooterVisibility(bool forced);
// Cached pointer to the sync service for this profile. // Cached pointer to the sync service for this profile.
ProfileSyncService* sync_service_; ProfileSyncService* sync_service_;
......
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