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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
13 #include "base/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/media/router/issue.h" | 17 #include "chrome/browser/media/router/issue.h" |
18 #include "chrome/browser/media/router/media_router_metrics.h" | 18 #include "chrome/browser/media/router/media_router_metrics.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/webui/media_router/media_router_ui.h" | 20 #include "chrome/browser/ui/webui/media_router/media_router_ui.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
23 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
24 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
25 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 | 27 |
28 #if defined(GOOGLE_CHROME_BUILD) | 28 #if defined(GOOGLE_CHROME_BUILD) |
29 #include "chrome/browser/signin/signin_manager_factory.h" | 29 #include "chrome/browser/signin/signin_manager_factory.h" |
30 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
31 #include "components/browser_sync/browser/profile_sync_service.h" | |
32 #include "components/signin/core/browser/signin_manager.h" | 30 #include "components/signin/core/browser/signin_manager.h" |
33 #endif // defined(GOOGLE_CHROME_BUILD) | 31 #endif // defined(GOOGLE_CHROME_BUILD) |
34 | 32 |
35 namespace media_router { | 33 namespace media_router { |
36 | 34 |
37 namespace { | 35 namespace { |
38 | 36 |
39 const char kCastLearnMorePageUrl[] = | 37 const char kCastLearnMorePageUrl[] = |
40 "https://www.google.com/chrome/devices/chromecast/learn.html"; | 38 "https://www.google.com/chrome/devices/chromecast/learn.html"; |
41 const char kHelpPageUrlPrefix[] = | 39 const char kHelpPageUrlPrefix[] = |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 void MediaRouterWebUIMessageHandler::MaybeUpdateFirstRunFlowData() { | 797 void MediaRouterWebUIMessageHandler::MaybeUpdateFirstRunFlowData() { |
800 base::DictionaryValue first_run_flow_data; | 798 base::DictionaryValue first_run_flow_data; |
801 | 799 |
802 Profile* profile = Profile::FromWebUI(web_ui()); | 800 Profile* profile = Profile::FromWebUI(web_ui()); |
803 PrefService* pref_service = profile->GetPrefs(); | 801 PrefService* pref_service = profile->GetPrefs(); |
804 | 802 |
805 bool first_run_flow_acknowledged = | 803 bool first_run_flow_acknowledged = |
806 pref_service->GetBoolean(prefs::kMediaRouterFirstRunFlowAcknowledged); | 804 pref_service->GetBoolean(prefs::kMediaRouterFirstRunFlowAcknowledged); |
807 bool show_cloud_pref = false; | 805 bool show_cloud_pref = false; |
808 #if defined(GOOGLE_CHROME_BUILD) | 806 #if defined(GOOGLE_CHROME_BUILD) |
809 // Cloud services preference is shown if user is logged in and has sync | 807 // Cloud services preference is shown if user is logged in. If the user |
810 // enabled. If the user enables sync after acknowledging the first run flow, | 808 // enables sync after acknowledging the first run flow, this is treated as |
811 // this is treated as the user opting into Google services, including cloud | 809 // the user opting into Google services, including cloud services, if the |
812 // services, if the browser is a Chrome branded build. | 810 // browser is a Chrome branded build. |
813 if (!pref_service->GetBoolean(prefs::kMediaRouterCloudServicesPrefSet) && | 811 if (!pref_service->GetBoolean(prefs::kMediaRouterCloudServicesPrefSet)) { |
814 profile->IsSyncAllowed()) { | |
815 SigninManagerBase* signin_manager = | 812 SigninManagerBase* signin_manager = |
816 SigninManagerFactory::GetForProfile(profile); | 813 SigninManagerFactory::GetForProfile(profile); |
817 if (signin_manager && signin_manager->IsAuthenticated() && | 814 if (signin_manager && signin_manager->IsAuthenticated()) { |
818 ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive()) { | |
819 // If the user had previously acknowledged the first run flow without | 815 // If the user had previously acknowledged the first run flow without |
820 // being shown the cloud services option, and is now logged in with sync | 816 // being shown the cloud services option, and is now logged in with sync |
821 // enabled, turn on cloud services. | 817 // enabled, turn on cloud services. |
822 if (first_run_flow_acknowledged) { | 818 if (first_run_flow_acknowledged && |
| 819 ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive()) { |
823 pref_service->SetBoolean(prefs::kMediaRouterEnableCloudServices, true); | 820 pref_service->SetBoolean(prefs::kMediaRouterEnableCloudServices, true); |
824 pref_service->SetBoolean(prefs::kMediaRouterCloudServicesPrefSet, | 821 pref_service->SetBoolean(prefs::kMediaRouterCloudServicesPrefSet, |
825 true); | 822 true); |
826 // Return early since the first run flow won't be surfaced. | 823 // Return early since the first run flow won't be surfaced. |
827 return; | 824 return; |
828 } | 825 } |
829 | 826 |
830 show_cloud_pref = true; | 827 show_cloud_pref = true; |
831 // "Casting to a Hangout from Chrome" Chromecast help center page. | 828 // "Casting to a Hangout from Chrome" Chromecast help center page. |
832 first_run_flow_data.SetString("firstRunFlowCloudPrefLearnMoreUrl", | 829 first_run_flow_data.SetString("firstRunFlowCloudPrefLearnMoreUrl", |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } | 887 } |
891 | 888 |
892 return value; | 889 return value; |
893 } | 890 } |
894 | 891 |
895 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { | 892 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { |
896 set_web_ui(web_ui); | 893 set_web_ui(web_ui); |
897 } | 894 } |
898 | 895 |
899 } // namespace media_router | 896 } // namespace media_router |
OLD | NEW |