Commit 09d80cf9 authored by sebsg's avatar sebsg Committed by Commit Bot

[Autofill] Don't offer to upstream cards for users with a Sync Error.

The code that decides whether to offer to Upsream now checks whether
Sync is in a permanent error state, like an auth error.

Bug: 819727
Change-Id: I27efaaf31794b8a6921e24cbbc0d6bb5e1154d1f
Reviewed-on: https://chromium-review.googlesource.com/959174Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542790}
parent f37db32e
...@@ -222,6 +222,17 @@ bool IsCreditCardUploadEnabled(const PrefService* pref_service, ...@@ -222,6 +222,17 @@ bool IsCreditCardUploadEnabled(const PrefService* pref_service,
return false; return false;
} }
// Check if sync is not in a permanent error state.
syncer::SyncService::SyncTokenStatus token_status =
sync_service->GetSyncTokenStatus();
if ((token_status.connection_status ==
syncer::ConnectionStatus::CONNECTION_AUTH_ERROR ||
token_status.connection_status ==
syncer::ConnectionStatus::CONNECTION_SERVER_ERROR) &&
token_status.last_get_token_error.IsPersistentError()) {
return false;
}
// Users who have enabled a passphrase have chosen to not make their sync // Users who have enabled a passphrase have chosen to not make their sync
// information accessible to Google. Since upload makes credit card data // information accessible to Google. Since upload makes credit card data
// available to other Google systems, disable it for passphrase users. // available to other Google systems, disable it for passphrase users.
......
...@@ -53,11 +53,28 @@ class TestSyncService : public syncer::FakeSyncService { ...@@ -53,11 +53,28 @@ class TestSyncService : public syncer::FakeSyncService {
is_using_secondary_passphrase_ = is_using_secondary_passphrase; is_using_secondary_passphrase_ = is_using_secondary_passphrase;
} }
syncer::SyncService::SyncTokenStatus GetSyncTokenStatus() const override {
syncer::SyncService::SyncTokenStatus token;
if (is_in_auth_error_) {
token.connection_status = syncer::ConnectionStatus::CONNECTION_AUTH_ERROR;
token.last_get_token_error =
GoogleServiceAuthError::FromServiceError("error");
}
return token;
}
void SetInAuthError(bool is_in_auth_error) {
is_in_auth_error_ = is_in_auth_error;
}
private: private:
bool can_sync_start_; bool can_sync_start_;
syncer::ModelTypeSet preferred_data_types_; syncer::ModelTypeSet preferred_data_types_;
bool is_engine_initialized_; bool is_engine_initialized_;
bool is_using_secondary_passphrase_; bool is_using_secondary_passphrase_;
bool is_in_auth_error_ = false;
}; };
} // namespace } // namespace
...@@ -100,6 +117,11 @@ TEST_F(AutofillExperimentsTest, DenyUpload_SyncServiceCannotStart) { ...@@ -100,6 +117,11 @@ TEST_F(AutofillExperimentsTest, DenyUpload_SyncServiceCannotStart) {
EXPECT_FALSE(IsCreditCardUploadEnabled()); EXPECT_FALSE(IsCreditCardUploadEnabled());
} }
TEST_F(AutofillExperimentsTest, DenyUpload_AuthError) {
sync_service_.SetInAuthError(true);
EXPECT_FALSE(IsCreditCardUploadEnabled());
}
TEST_F(AutofillExperimentsTest, TEST_F(AutofillExperimentsTest,
DenyUpload_SyncServiceDoesNotHaveAutofillProfilePreferredDataType) { DenyUpload_SyncServiceDoesNotHaveAutofillProfilePreferredDataType) {
sync_service_.SetPreferredDataTypes(syncer::ModelTypeSet()); sync_service_.SetPreferredDataTypes(syncer::ModelTypeSet());
......
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