Commit c82468fc authored by Michele Mancina's avatar Michele Mancina Committed by Commit Bot

[Autofill Assistant] Add is_signed_into_chrome flag to client context

Bug: b/159100700
Change-Id: Ie38363ba8a820c2d9663533cbf0f0a8cff19d91a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255464
Commit-Queue: Michele Mancina <micantox@google.com>
Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Cr-Commit-Position: refs/heads/master@{#784410}
parent 166cdd61
...@@ -82,6 +82,17 @@ message ClientContextProto { ...@@ -82,6 +82,17 @@ message ClientContextProto {
// Whether a11y (talkback and touch exploration) is enabled or not. // Whether a11y (talkback and touch exploration) is enabled or not.
optional bool accessibility_enabled = 13; optional bool accessibility_enabled = 13;
enum SignedIntoChromeStatus {
UNDEFINED = 0;
// There is no account signed into Chrome.
NOT_SIGNED_IN = 1;
// An account is signed into Chrome.
SIGNED_IN = 2;
}
optional SignedIntoChromeStatus signed_into_chrome_status = 14;
} }
// Get the list of scripts that can potentially be run on a url. // Get the list of scripts that can potentially be run on a url.
......
...@@ -340,6 +340,10 @@ ClientContextProto ServiceImpl::CreateClientContext( ...@@ -340,6 +340,10 @@ ClientContextProto ServiceImpl::CreateClientContext(
void ServiceImpl::UpdateMutableClientContextFields() { void ServiceImpl::UpdateMutableClientContextFields() {
client_context_.set_accessibility_enabled(client_->IsAccessibilityEnabled()); client_context_.set_accessibility_enabled(client_->IsAccessibilityEnabled());
client_context_.set_signed_into_chrome_status(
client_->GetChromeSignedInEmailAddress().empty()
? ClientContextProto::NOT_SIGNED_IN
: ClientContextProto::SIGNED_IN);
} }
} // namespace autofill_assistant } // namespace autofill_assistant
...@@ -146,6 +146,8 @@ class ServiceImpl : public Service { ...@@ -146,6 +146,8 @@ class ServiceImpl : public Service {
base::WeakPtrFactory<ServiceImpl> weak_ptr_factory_; base::WeakPtrFactory<ServiceImpl> weak_ptr_factory_;
FRIEND_TEST_ALL_PREFIXES(ServiceImplTestSignedInStatus, SetsSignedInStatus);
DISALLOW_COPY_AND_ASSIGN(ServiceImpl); DISALLOW_COPY_AND_ASSIGN(ServiceImpl);
}; };
......
...@@ -38,4 +38,25 @@ TEST_F(ServiceImplTest, CreatesValidHashFromEmail) { ...@@ -38,4 +38,25 @@ TEST_F(ServiceImplTest, CreatesValidHashFromEmail) {
"2c8fa87717fab622bb5cc4d18135fe30dae339efd274b450022d361be92b48c3"); "2c8fa87717fab622bb5cc4d18135fe30dae339efd274b450022d361be92b48c3");
} }
class ServiceImplTestSignedInStatus
: public ServiceImplTest,
public testing::WithParamInterface<
std::pair<std::string, ClientContextProto::SignedIntoChromeStatus>> {
};
INSTANTIATE_TEST_SUITE_P(
ParametrizedTests,
ServiceImplTestSignedInStatus,
testing::Values(std::make_pair("", ClientContextProto::NOT_SIGNED_IN),
std::make_pair("bob@email.com",
ClientContextProto::SIGNED_IN)));
TEST_P(ServiceImplTestSignedInStatus, SetsSignedInStatus) {
ON_CALL(mock_client_, GetChromeSignedInEmailAddress)
.WillByDefault(Return(GetParam().first));
service_impl_->UpdateMutableClientContextFields();
EXPECT_EQ(service_impl_->client_context_.signed_into_chrome_status(),
GetParam().second);
}
} // namespace autofill_assistant } // namespace autofill_assistant
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