OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/ntp_snippets/ntp_snippets_status_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_status_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "components/ntp_snippets/features.h" | 9 #include "components/ntp_snippets/features.h" |
10 #include "components/ntp_snippets/pref_names.h" | 10 #include "components/ntp_snippets/pref_names.h" |
11 #include "components/prefs/pref_registry_simple.h" | 11 #include "components/prefs/pref_registry_simple.h" |
12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
13 #include "components/variations/variations_associated_data.h" | 13 #include "components/variations/variations_associated_data.h" |
14 | 14 |
15 namespace ntp_snippets { | 15 namespace ntp_snippets { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kFetchingRequiresSignin[] = "fetching_requires_signin"; | 19 const char kFetchingRequiresSignin[] = "fetching_requires_signin"; |
20 const char kFetchingRequiresSigninEnabled[] = "true"; | 20 const char kFetchingRequiresSigninEnabled[] = "true"; |
21 const char kFetchingRequiresSigninDisabled[] = "false"; | 21 const char kFetchingRequiresSigninDisabled[] = "false"; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 NTPSnippetsStatusService::NTPSnippetsStatusService( | 25 NTPSnippetsStatusService::NTPSnippetsStatusService( |
26 SigninManagerBase* signin_manager, | 26 SigninManagerBase* signin_manager, |
27 PrefService* pref_service) | 27 PrefService* pref_service) |
28 : disabled_reason_(DisabledReason::EXPLICITLY_DISABLED), | 28 : disabled_reason_(DisabledReason::EXPLICITLY_DISABLED), |
29 require_signin_(true), | 29 require_signin_(false), |
30 signin_manager_(signin_manager), | 30 signin_manager_(signin_manager), |
31 pref_service_(pref_service), | 31 pref_service_(pref_service), |
32 signin_observer_(this) { | 32 signin_observer_(this) { |
33 std::string param_value_str = variations::GetVariationParamValueByFeature( | 33 std::string param_value_str = variations::GetVariationParamValueByFeature( |
34 kArticleSuggestionsFeature, kFetchingRequiresSignin); | 34 kArticleSuggestionsFeature, kFetchingRequiresSignin); |
35 if (param_value_str == kFetchingRequiresSigninDisabled) { | 35 if (param_value_str == kFetchingRequiresSigninEnabled) { |
36 require_signin_ = false; | 36 require_signin_ = true; |
37 } else if (!param_value_str.empty() && | 37 } else if (!param_value_str.empty() && |
38 param_value_str != kFetchingRequiresSigninEnabled) { | 38 param_value_str != kFetchingRequiresSigninDisabled) { |
39 DLOG(WARNING) << "Unknow value for the variations parameter " | 39 DLOG(WARNING) << "Unknow value for the variations parameter " |
40 << kFetchingRequiresSignin << ": " << param_value_str; | 40 << kFetchingRequiresSignin << ": " << param_value_str; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 NTPSnippetsStatusService::~NTPSnippetsStatusService() {} | 44 NTPSnippetsStatusService::~NTPSnippetsStatusService() {} |
45 | 45 |
46 // static | 46 // static |
47 void NTPSnippetsStatusService::RegisterProfilePrefs( | 47 void NTPSnippetsStatusService::RegisterProfilePrefs( |
48 PrefRegistrySimple* registry) { | 48 PrefRegistrySimple* registry) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 (!signin_manager_ || !signin_manager_->IsAuthenticated())) { | 101 (!signin_manager_ || !signin_manager_->IsAuthenticated())) { |
102 DVLOG(1) << "[GetNewDisabledReason] Signed out"; | 102 DVLOG(1) << "[GetNewDisabledReason] Signed out"; |
103 return DisabledReason::SIGNED_OUT; | 103 return DisabledReason::SIGNED_OUT; |
104 } | 104 } |
105 | 105 |
106 DVLOG(1) << "[GetNewDisabledReason] Enabled"; | 106 DVLOG(1) << "[GetNewDisabledReason] Enabled"; |
107 return DisabledReason::NONE; | 107 return DisabledReason::NONE; |
108 } | 108 } |
109 | 109 |
110 } // namespace ntp_snippets | 110 } // namespace ntp_snippets |
OLD | NEW |