[ActorOTP] Add sender address to OneTimeToken class [chromium/src : main]

0 views
Skip to first unread message

Ioana Treib (Gerrit)

unread,
Jul 7, 2026, 12:06:55 PM (23 hours ago) Jul 7
to Thomas Lottermann, Bekzhan Kassenov, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Bekzhan Kassenov and Thomas Lottermann

Ioana Treib voted and added 7 comments

Votes added by Ioana Treib

Commit-Queue+1

7 comments

Patchset-level comments
File-level comment, Patchset 2:
Ioana Treib . unresolved

Hi Bekzhan,

Please take a look! I am not quite sure of the exact format of the sender, can you please double-check that the parsing of the domain makes sense?

Thank you,
Ioana

Bekzhan Kassenov

I think @lotte...@google.com would know this better.

Ioana Treib

The CL changed a bit so leaving the 2 examples I have here:

Are both of these possible? Are there more formats?

File components/one_time_tokens/core/browser/email_one_time_token_fetcher.cc
Line 28, Patchset 2:std::optional<std::string> ExtractDomainFromSenderAddress(
Bekzhan Kassenov . resolved

If we still end up keeping this function here (see my comment on one_time_token.h), please cover this function with unit tests.

Ioana Treib

I've removed the function for now. I'll re-add it with the matching logic in the matching place.

Line 30, Patchset 2: if (sender_address.empty()) {
return std::nullopt;
}
// `sender_address` can be formatted as a plain email address
// (e.g., "sup...@example.com") or as a display name with angle brackets
// (e.g., "Example Support <sup...@example.com>"). We extract the domain
// after the '@' and strip any trailing '>' to handle both formats.
size_t at_pos = sender_address.rfind('@');
if (at_pos != std::string::npos && at_pos + 1 < sender_address.length()) {
std::string domain = sender_address.substr(at_pos + 1);
if (!domain.empty() && domain.back() == '>') {
domain.pop_back();
}
if (!domain.empty()) {
return domain;
}
} else if (at_pos == std::string::npos) {
return sender_address;
}
return std::nullopt;
Bekzhan Kassenov . resolved

opt: consider using gaia::ExtractDomainName

https://source.chromium.org/chromium/chromium/src/+/main:google_apis/gaia/gaia_auth_util.cc;l=105;drc=17dbebcbc47146643c1618409adbcb704bba22d3

Ioana Treib

Oh, I didn't know about it. Thanks for the tip!

File components/one_time_tokens/core/browser/one_time_token.h
Line 44, Patchset 2: [[nodiscard]] const std::optional<std::string>& sender_domain() const {
Bekzhan Kassenov . resolved

I don't think putting only the domain here is the best approach.

1. We lose some fidelity in case if the matching logic starts to need more fields.
2. EmailOneTimeTokenFetcher was planned to be a pure backend fetcher, but now it contains some business logic.

I'd recommend simply propagating the full sender address, and deciding on what's needed down in the matching logic.

Ioana Treib

SGTM!

Line 44, Patchset 2: [[nodiscard]] const std::optional<std::string>& sender_domain() const {
Bekzhan Kassenov . resolved

On class evolution: it would be good to be able to group Gmail-specific fields together, and make them disjoint from potential SMS-based fields.

I don't know C++ enough to propose a good pattern here, but in proto I'd suggest putting this into a submessage with the purpose of turning it into a `oneof` later.

Ioana Treib

Documenting what I got from our offline discussion:

  • std::variant could work for now, but when a third type of OTP is added that has some overlapping fields it will become awkward.
  • using inheritance with a different object type per OTP type is probably the way to go, if this class becomes too complext.
Line 42, Patchset 2: // The sender domain of the OTP email. This is only relevant for Gmail OTPs
// and is `std::nullopt` otherwise.
Bekzhan Kassenov . resolved

This statement is not validated on construction.

Ioana Treib

Done

File components/one_time_tokens/core/browser/one_time_token.cc
Line 37, Patchset 2:bool OneTimeToken::operator==(const OneTimeToken& other) const {
return type_ == other.type_ && value_ == other.value_ &&
sender_domain_ == other.sender_domain_;
}
Bekzhan Kassenov . resolved

I don't think OneTimeToken is a good candidate to have `==` defined on it, since there are different use-cases with different equality requirements... We even went out of our way to design components/one_time_tokens/core/browser/util/expiring_cache.h to don't require `==` defined.

Could you please add a TODO to eliminate this operator?

Ioana Treib

Done. Added it in the header.

Open in Gerrit

Related details

Attention is currently required from:
  • Bekzhan Kassenov
  • Thomas Lottermann
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
Gerrit-Change-Number: 8040200
Gerrit-PatchSet: 5
Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
Gerrit-CC: Thomas Lottermann <lotte...@google.com>
Gerrit-Attention: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Attention: Thomas Lottermann <lotte...@google.com>
Gerrit-Comment-Date: Tue, 07 Jul 2026 16:06:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Bekzhan Kassenov <bkas...@google.com>
Comment-In-Reply-To: Ioana Treib <ioa...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Bekzhan Kassenov (Gerrit)

unread,
Jul 7, 2026, 12:17:04 PM (23 hours ago) Jul 7
to Ioana Treib, Thomas Lottermann, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Ioana Treib and Thomas Lottermann

Bekzhan Kassenov voted and added 3 comments

Votes added by Bekzhan Kassenov

Code-Review+1

3 comments

File components/one_time_tokens/core/browser/email_one_time_token_fetcher.cc
Line 188, Patchset 5 (Latest): response.sender_address()));
Bekzhan Kassenov . unresolved

I think absent proto field should be cast to `std::nullopt`.

Line 188, Patchset 5 (Latest): response.sender_address()));
Bekzhan Kassenov . unresolved

Proto accessors return `const std::string&`, is that correct? Does this get auto-wrapped into an optional?

File components/one_time_tokens/core/browser/email_one_time_token_fetcher_unittest.cc
Line 74, Patchset 5 (Latest): response.set_sender_address("no-r...@example.com");
Bekzhan Kassenov . unresolved

Please add a test for an empty response field. At least server-side implementation permits that: http://google3/java/com/google/chrome/passwords/boq/onetimetoken/service/FetchEmailOneTimeTokenAction.kt;l=161;rcl=908027161

Open in Gerrit

Related details

Attention is currently required from:
  • Ioana Treib
  • Thomas Lottermann
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
Gerrit-Change-Number: 8040200
Gerrit-PatchSet: 5
Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
Gerrit-CC: Thomas Lottermann <lotte...@google.com>
Gerrit-Attention: Ioana Treib <ioa...@chromium.org>
Gerrit-Attention: Thomas Lottermann <lotte...@google.com>
Gerrit-Comment-Date: Tue, 07 Jul 2026 16:16:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Ioana Treib (Gerrit)

unread,
8:10 AM (3 hours ago) 8:10 AM
to Bekzhan Kassenov, Thomas Lottermann, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Thomas Lottermann

Ioana Treib voted and added 3 comments

Votes added by Ioana Treib

Commit-Queue+1

3 comments

File components/one_time_tokens/core/browser/email_one_time_token_fetcher.cc
Line 188, Patchset 5: response.sender_address()));
Bekzhan Kassenov . resolved

Proto accessors return `const std::string&`, is that correct? Does this get auto-wrapped into an optional?

Ioana Treib

It's a std::optional<std::string>, so it should create a copy of the string and wrap it in optional, yes.

Line 188, Patchset 5: response.sender_address()));
Bekzhan Kassenov . resolved

I think absent proto field should be cast to `std::nullopt`.

Ioana Treib

I don't think this one can be absent. It will be an empty string. I've added an if checking that above and I'm returning invalid response now.

File components/one_time_tokens/core/browser/email_one_time_token_fetcher_unittest.cc
Line 74, Patchset 5: response.set_sender_address("no-r...@example.com");
Bekzhan Kassenov . resolved

Please add a test for an empty response field. At least server-side implementation permits that: http://google3/java/com/google/chrome/passwords/boq/onetimetoken/service/FetchEmailOneTimeTokenAction.kt;l=161;rcl=908027161

Ioana Treib

Done.

Open in Gerrit

Related details

Attention is currently required from:
  • Thomas Lottermann
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
Gerrit-Change-Number: 8040200
Gerrit-PatchSet: 7
Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
Gerrit-CC: Thomas Lottermann <lotte...@google.com>
Gerrit-Attention: Thomas Lottermann <lotte...@google.com>
Gerrit-Comment-Date: Wed, 08 Jul 2026 12:10:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Bekzhan Kassenov <bkas...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Bekzhan Kassenov (Gerrit)

unread,
8:13 AM (3 hours ago) 8:13 AM
to Ioana Treib, Thomas Lottermann, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Ioana Treib

Bekzhan Kassenov voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ioana Treib
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
Gerrit-Change-Number: 8040200
Gerrit-PatchSet: 7
Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
Gerrit-CC: Thomas Lottermann <lotte...@google.com>
Gerrit-Attention: Ioana Treib <ioa...@chromium.org>
Gerrit-Comment-Date: Wed, 08 Jul 2026 12:12:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Ioana Treib (Gerrit)

unread,
9:45 AM (1 hour ago) 9:45 AM
to Bekzhan Kassenov, Thomas Lottermann, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Bekzhan Kassenov

Ioana Treib added 2 comments

Patchset-level comments
File-level comment, Patchset 2:
Ioana Treib . resolved

Hi Bekzhan,

Please take a look! I am not quite sure of the exact format of the sender, can you please double-check that the parsing of the domain makes sense?

Thank you,
Ioana

Bekzhan Kassenov

I think @lotte...@google.com would know this better.

Ioana Treib

The CL changed a bit so leaving the 2 examples I have here:

Are both of these possible? Are there more formats?

Ioana Treib

I'll take this comment offline, so that I can submit this CL. It's anyway only relevant for the next change.

File-level comment, Patchset 8 (Latest):
Ioana Treib . resolved

Some tests still needed updating. Please take another look!

Open in Gerrit

Related details

Attention is currently required from:
  • Bekzhan Kassenov
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
Gerrit-Change-Number: 8040200
Gerrit-PatchSet: 8
Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
Gerrit-CC: Thomas Lottermann <lotte...@google.com>
Gerrit-Attention: Bekzhan Kassenov <bkas...@google.com>
Gerrit-Comment-Date: Wed, 08 Jul 2026 13:45:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Bekzhan Kassenov (Gerrit)

unread,
9:45 AM (1 hour ago) 9:45 AM
to Ioana Treib, Thomas Lottermann, Chromium LUCI CQ, chromium...@chromium.org

Bekzhan Kassenov voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
    Gerrit-Change-Number: 8040200
    Gerrit-PatchSet: 8
    Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
    Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
    Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
    Gerrit-CC: Thomas Lottermann <lotte...@google.com>
    Gerrit-Comment-Date: Wed, 08 Jul 2026 13:45:26 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Ioana Treib (Gerrit)

    unread,
    10:08 AM (1 hour ago) 10:08 AM
    to Rodney Ding, android-bu...@system.gserviceaccount.com, Bekzhan Kassenov, Thomas Lottermann, Chromium LUCI CQ, chromium...@chromium.org, browser-comp...@chromium.org, mfoltz+wa...@chromium.org
    Attention needed from Rodney Ding

    Ioana Treib added 1 comment

    Patchset-level comments
    Ioana Treib . resolved

    Thank you, Bekzhan!

    Rodney, could you please take a look at attempt_otp_filling_tool_browsertest.cc?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Rodney Ding
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic974c5a7d91249ff78562664064752447f77d527
    Gerrit-Change-Number: 8040200
    Gerrit-PatchSet: 8
    Gerrit-Owner: Ioana Treib <ioa...@chromium.org>
    Gerrit-Reviewer: Bekzhan Kassenov <bkas...@google.com>
    Gerrit-Reviewer: Ioana Treib <ioa...@chromium.org>
    Gerrit-Reviewer: Rodney Ding <rodne...@google.com>
    Gerrit-CC: Thomas Lottermann <lotte...@google.com>
    Gerrit-Attention: Rodney Ding <rodne...@google.com>
    Gerrit-Comment-Date: Wed, 08 Jul 2026 14:08:37 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages