| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/media_router/media_router_webui_message_handle
r.h" | 5 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handle
r.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 void MediaRouterWebUIMessageHandler::MaybeUpdateFirstRunFlowData() { | 798 void MediaRouterWebUIMessageHandler::MaybeUpdateFirstRunFlowData() { |
| 799 base::DictionaryValue first_run_flow_data; | 799 base::DictionaryValue first_run_flow_data; |
| 800 | 800 |
| 801 Profile* profile = Profile::FromWebUI(web_ui()); | 801 Profile* profile = Profile::FromWebUI(web_ui()); |
| 802 PrefService* pref_service = profile->GetPrefs(); | 802 PrefService* pref_service = profile->GetPrefs(); |
| 803 | 803 |
| 804 bool first_run_flow_acknowledged = | 804 bool first_run_flow_acknowledged = |
| 805 pref_service->GetBoolean(prefs::kMediaRouterFirstRunFlowAcknowledged); | 805 pref_service->GetBoolean(prefs::kMediaRouterFirstRunFlowAcknowledged); |
| 806 bool show_cloud_pref = false; | 806 bool show_cloud_pref = false; |
| 807 #if defined(GOOGLE_CHROME_BUILD) | 807 #if defined(GOOGLE_CHROME_BUILD) |
| 808 // Cloud services preference is shown if user is logged in and has sync | 808 // Cloud services preference is shown if user is logged in. If the user |
| 809 // enabled. If the user enables sync after acknowledging the first run flow, | 809 // enables sync after acknowledging the first run flow, this is treated as |
| 810 // this is treated as the user opting into Google services, including cloud | 810 // the user opting into Google services, including cloud services, if the |
| 811 // services, if the browser is a Chrome branded build. | 811 // browser is a Chrome branded build. |
| 812 if (!pref_service->GetBoolean(prefs::kMediaRouterCloudServicesPrefSet) && | 812 if (!pref_service->GetBoolean(prefs::kMediaRouterCloudServicesPrefSet)) { |
| 813 profile->IsSyncAllowed()) { | |
| 814 SigninManagerBase* signin_manager = | 813 SigninManagerBase* signin_manager = |
| 815 SigninManagerFactory::GetForProfile(profile); | 814 SigninManagerFactory::GetForProfile(profile); |
| 816 if (signin_manager && signin_manager->IsAuthenticated() && | 815 if (signin_manager && signin_manager->IsAuthenticated()) { |
| 817 ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive()) { | |
| 818 // If the user had previously acknowledged the first run flow without | 816 // If the user had previously acknowledged the first run flow without |
| 819 // being shown the cloud services option, and is now logged in with sync | 817 // being shown the cloud services option, and is now logged in with sync |
| 820 // enabled, turn on cloud services. | 818 // enabled, turn on cloud services. |
| 821 if (first_run_flow_acknowledged) { | 819 if (first_run_flow_acknowledged && |
| 820 ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive()) { |
| 822 pref_service->SetBoolean(prefs::kMediaRouterEnableCloudServices, true); | 821 pref_service->SetBoolean(prefs::kMediaRouterEnableCloudServices, true); |
| 823 pref_service->SetBoolean(prefs::kMediaRouterCloudServicesPrefSet, | 822 pref_service->SetBoolean(prefs::kMediaRouterCloudServicesPrefSet, |
| 824 true); | 823 true); |
| 825 // Return early since the first run flow won't be surfaced. | 824 // Return early since the first run flow won't be surfaced. |
| 826 return; | 825 return; |
| 827 } | 826 } |
| 828 | 827 |
| 829 show_cloud_pref = true; | 828 show_cloud_pref = true; |
| 830 // "Casting to a Hangout from Chrome" Chromecast help center page. | 829 // "Casting to a Hangout from Chrome" Chromecast help center page. |
| 831 first_run_flow_data.SetString("firstRunFlowCloudPrefLearnMoreUrl", | 830 first_run_flow_data.SetString("firstRunFlowCloudPrefLearnMoreUrl", |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 887 } |
| 889 | 888 |
| 890 return value; | 889 return value; |
| 891 } | 890 } |
| 892 | 891 |
| 893 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { | 892 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { |
| 894 set_web_ui(web_ui); | 893 set_web_ui(web_ui); |
| 895 } | 894 } |
| 896 | 895 |
| 897 } // namespace media_router | 896 } // namespace media_router |
| OLD | NEW |