Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: chrome/browser/ui/webui/welcome_handler_android.cc

Issue 22375004: Ensure sync footer visibility is always set correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/welcome_handler_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/webui/welcome_handler_android.h" 5 #include "chrome/browser/ui/webui/welcome_handler_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/android/tab_android.h" 9 #include "chrome/browser/android/tab_android.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 24 matching lines...) Expand all
35 base::Unretained(this))); 35 base::Unretained(this)));
36 36
37 // Register for callbacks 37 // Register for callbacks
38 sync_service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile( 38 sync_service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile(
39 Profile::FromWebUI(web_ui())); 39 Profile::FromWebUI(web_ui()));
40 if (sync_service_) 40 if (sync_service_)
41 observer_manager_.Add(sync_service_); 41 observer_manager_.Add(sync_service_);
42 } 42 }
43 43
44 void WelcomeHandler::HandleUpdateSyncFooterVisibility(const ListValue* args) { 44 void WelcomeHandler::HandleUpdateSyncFooterVisibility(const ListValue* args) {
45 OnStateChanged(); 45 UpdateSyncFooterVisibility(true);
46 } 46 }
47 47
48 void WelcomeHandler::HandleShowSyncSettings(const ListValue* args) { 48 void WelcomeHandler::HandleShowSyncSettings(const ListValue* args) {
49 TabAndroid::FromWebContents(web_ui()->GetWebContents())->ShowSyncSettings(); 49 TabAndroid::FromWebContents(web_ui()->GetWebContents())->ShowSyncSettings();
50 } 50 }
51 51
52 void WelcomeHandler::HandleShowTermsOfService(const ListValue* args) { 52 void WelcomeHandler::HandleShowTermsOfService(const ListValue* args) {
53 TabAndroid::FromWebContents(web_ui()->GetWebContents())->ShowTermsOfService(); 53 TabAndroid::FromWebContents(web_ui()->GetWebContents())->ShowTermsOfService();
54 } 54 }
55 55
56 void WelcomeHandler::OnStateChanged() { 56 void WelcomeHandler::OnStateChanged() {
57 UpdateSyncFooterVisibility(false);
58 }
59
60 void WelcomeHandler::UpdateSyncFooterVisibility(bool forced) {
57 bool is_sync_enabled = 61 bool is_sync_enabled =
58 sync_service_ && sync_service_->IsSyncEnabledAndLoggedIn(); 62 sync_service_ && sync_service_->IsSyncEnabledAndLoggedIn();
59 63
60 if (is_sync_footer_visible_ != is_sync_enabled) { 64 if (forced || is_sync_footer_visible_ != is_sync_enabled) {
61 is_sync_footer_visible_ = is_sync_enabled; 65 is_sync_footer_visible_ = is_sync_enabled;
62 web_ui()->CallJavascriptFunction("welcome.setSyncFooterVisible", 66 web_ui()->CallJavascriptFunction("welcome.setSyncFooterVisible",
63 base::FundamentalValue(is_sync_enabled)); 67 base::FundamentalValue(is_sync_enabled));
64 } 68 }
65 } 69 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/welcome_handler_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698