OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |