Commit 72ad9e71 authored by Alex Chau's avatar Alex Chau Committed by Commit Bot

Fix DCHECK in GetExperimentalAuthenticationKey with local sync enabled

- Return nullptr key when local sync is enabled and avoid DCHECK

Bug: 1023827
Change-Id: I73fac96233ff0b17611b8d0ffb150d9977417d50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911218
Commit-Queue: Alex Chau <alexchau@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714630}
parent 5a3c957e
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "components/browser_sync/browser_sync_switches.h" #include "components/browser_sync/browser_sync_switches.h"
#include "components/sync/driver/profile_sync_service.h" #include "components/sync/driver/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h" #include "components/sync/driver/sync_driver_switches.h"
#include "crypto/ec_private_key.h"
namespace { namespace {
...@@ -75,6 +76,7 @@ IN_PROC_BROWSER_TEST_F(LocalSyncTest, ShouldStart) { ...@@ -75,6 +76,7 @@ IN_PROC_BROWSER_TEST_F(LocalSyncTest, ShouldStart) {
ASSERT_TRUE(SyncTransportActiveChecker(service).Wait()); ASSERT_TRUE(SyncTransportActiveChecker(service).Wait());
EXPECT_TRUE(service->IsLocalSyncEnabled()); EXPECT_TRUE(service->IsLocalSyncEnabled());
EXPECT_FALSE(service->GetExperimentalAuthenticationKey());
// Verify certain features are disabled. // Verify certain features are disabled.
EXPECT_FALSE(send_tab_to_self::IsUserSyncTypeActive(browser()->profile())); EXPECT_FALSE(send_tab_to_self::IsUserSyncTypeActive(browser()->profile()));
......
...@@ -1954,7 +1954,8 @@ std::string ProfileSyncService::GetExperimentalAuthenticationSecret() const { ...@@ -1954,7 +1954,8 @@ std::string ProfileSyncService::GetExperimentalAuthenticationSecret() const {
// when usually all except keystore keys are guaranteed to be available. // when usually all except keystore keys are guaranteed to be available.
// Keystore keys are usually available initially too, but in rare cases they // Keystore keys are usually available initially too, but in rare cases they
// should arrive in later sync cycles. // should arrive in later sync cycles.
if (last_keystore_key_.empty()) { // GAIA ID is not available with local sync enabled.
if (last_keystore_key_.empty() || IsLocalSyncEnabled()) {
return std::string(); return std::string();
} }
......
...@@ -1503,5 +1503,15 @@ TEST_F(ProfileSyncServiceTest, GetExperimentalAuthenticationKey) { ...@@ -1503,5 +1503,15 @@ TEST_F(ProfileSyncServiceTest, GetExperimentalAuthenticationKey) {
EXPECT_EQ(kExpectedPrivateKeyInfo, actual_private_key); EXPECT_EQ(kExpectedPrivateKeyInfo, actual_private_key);
} }
TEST_F(ProfileSyncServiceTest, GetExperimentalAuthenticationKeyLocalSync) {
CreateServiceWithLocalSyncBackend();
InitializeForNthSync();
EXPECT_EQ(SyncService::TransportState::ACTIVE,
service()->GetTransportState());
EXPECT_TRUE(service()->GetExperimentalAuthenticationSecretForTest().empty());
EXPECT_FALSE(service()->GetExperimentalAuthenticationKey());
}
} // namespace } // namespace
} // namespace syncer } // namespace syncer
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