Commit c9be4526 authored by jkrcal's avatar jkrcal Committed by Commit bot

Change the default value of the fetching_requires_signin parameter

With the current default value fetching_requires_signin=true, users get
suboptimal UX after fresh install / after clearing app data. Because of
bug 632199, the server-side variation parameters are not applied in the
first run and sign-in is required. This is inconsistent with the second
run of Chrome, where the server sets fetching_requires_signin:=false
and no sign-in is required any more.

BUG=646759

Review-Url: https://codereview.chromium.org/2343583002
Cr-Commit-Position: refs/heads/master@{#419147}
parent abe073d9
...@@ -26,16 +26,16 @@ NTPSnippetsStatusService::NTPSnippetsStatusService( ...@@ -26,16 +26,16 @@ NTPSnippetsStatusService::NTPSnippetsStatusService(
SigninManagerBase* signin_manager, SigninManagerBase* signin_manager,
PrefService* pref_service) PrefService* pref_service)
: disabled_reason_(DisabledReason::EXPLICITLY_DISABLED), : disabled_reason_(DisabledReason::EXPLICITLY_DISABLED),
require_signin_(true), require_signin_(false),
signin_manager_(signin_manager), signin_manager_(signin_manager),
pref_service_(pref_service), pref_service_(pref_service),
signin_observer_(this) { signin_observer_(this) {
std::string param_value_str = variations::GetVariationParamValueByFeature( std::string param_value_str = variations::GetVariationParamValueByFeature(
kArticleSuggestionsFeature, kFetchingRequiresSignin); kArticleSuggestionsFeature, kFetchingRequiresSignin);
if (param_value_str == kFetchingRequiresSigninDisabled) { if (param_value_str == kFetchingRequiresSigninEnabled) {
require_signin_ = false; require_signin_ = true;
} else if (!param_value_str.empty() && } else if (!param_value_str.empty() &&
param_value_str != kFetchingRequiresSigninEnabled) { param_value_str != kFetchingRequiresSigninDisabled) {
DLOG(WARNING) << "Unknow value for the variations parameter " DLOG(WARNING) << "Unknow value for the variations parameter "
<< kFetchingRequiresSignin << ": " << param_value_str; << kFetchingRequiresSignin << ": " << param_value_str;
} }
......
...@@ -43,8 +43,6 @@ class NTPSnippetsStatusService : public SigninManagerBase::Observer { ...@@ -43,8 +43,6 @@ class NTPSnippetsStatusService : public SigninManagerBase::Observer {
void Init(const DisabledReasonChangeCallback& callback); void Init(const DisabledReasonChangeCallback& callback);
private: private:
FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest,
SigninStateCompatibility);
FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest, DisabledViaPref); FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest, DisabledViaPref);
// SigninManagerBase::Observer implementation // SigninManagerBase::Observer implementation
......
...@@ -37,29 +37,21 @@ class NTPSnippetsStatusServiceTest : public ::testing::Test { ...@@ -37,29 +37,21 @@ class NTPSnippetsStatusServiceTest : public ::testing::Test {
test::NTPSnippetsTestUtils utils_; test::NTPSnippetsTestUtils utils_;
}; };
TEST_F(NTPSnippetsStatusServiceTest, SigninStateCompatibility) { // TODO(jkrcal): Extend the ways to override variation parameters in unit-test
auto service = MakeService(); // (bug 645447), and recover the SigninStateCompatibility test that sign-in is
// required when the parameter is overriden.
// The default test setup is signed out.
EXPECT_EQ(DisabledReason::SIGNED_OUT, service->GetDisabledReasonFromDeps());
// Once signed in, we should be in a compatible state.
utils_.fake_signin_manager()->SignIn("foo@bar.com");
EXPECT_EQ(DisabledReason::NONE, service->GetDisabledReasonFromDeps());
}
TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) { TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) {
auto service = MakeService(); auto service = MakeService();
// The default test setup is signed out. // The default test setup is signed out. The service is enabled.
ASSERT_EQ(DisabledReason::SIGNED_OUT, service->GetDisabledReasonFromDeps()); ASSERT_EQ(DisabledReason::NONE, service->GetDisabledReasonFromDeps());
// Once the enabled pref is set to false, we should be disabled. // Once the enabled pref is set to false, we should be disabled.
utils_.pref_service()->SetBoolean(prefs::kEnableSnippets, false); utils_.pref_service()->SetBoolean(prefs::kEnableSnippets, false);
EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
service->GetDisabledReasonFromDeps()); service->GetDisabledReasonFromDeps());
// The other dependencies shouldn't matter anymore. // Signing-in shouldn't matter anymore.
utils_.fake_signin_manager()->SignIn("foo@bar.com"); utils_.fake_signin_manager()->SignIn("foo@bar.com");
EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
service->GetDisabledReasonFromDeps()); service->GetDisabledReasonFromDeps());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment