Hi Christoph,
I dropped the contextual_tasks dependency, moved the code to chrome/browser/ui/autofill and started to use the IPH framework for bubble triggering.
Could you please take a look?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
raw_ptr<Profile> profile_;nit: raw_ref?
"ActiveTabChanged",
"Copy",
"ActiveTabChanged",
"Paste",Where do these string constants come from? Shouldn't this be an enum?
const std::vector<std::string>& GetTargetSequence() {
static const base::NoDestructor<std::vector<std::string>> kTargetSequence({
"ActiveTabChanged",
"Copy",
"ActiveTabChanged",
"Paste",
});
return *kTargetSequence;
}nit:
```
constexpr const char* kTargetSequence[] = ...;
```
?
if (!profile_) return;Code formatting is off. This should be caught by a presubmit script. Did you see a warning when you uploaded the CL? If not, could you file a bug or reopen an existing one (maybe b/386840832)?
const std::string& action,std::string_view?
for (const auto& target : GetTargetSequence()) {nit: spell out the type
bool relevant = false;
for (const auto& target : GetTargetSequence()) {
if (action == target) {
relevant = true;
break;
}
}nit: `bool relevant = base::Contains(...)`?
for (size_t i = 0; i < GetTargetSequence().size(); ++i) {nit: use base::zip()
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
"ActiveTabChanged",
"Copy",
"ActiveTabChanged",
"Paste",Where do these string constants come from? Shouldn't this be an enum?
I originally used strings to match the names in actions.xml, but since I'm just passing events directly from the TabHelper and not using ActionObserver, I don't actually need these strings.
I've refactored it to use enum instead.
const std::vector<std::string>& GetTargetSequence() {
static const base::NoDestructor<std::vector<std::string>> kTargetSequence({
"ActiveTabChanged",
"Copy",
"ActiveTabChanged",
"Paste",
});
return *kTargetSequence;
}nit:
```
constexpr const char* kTargetSequence[] = ...;
```
?
I replaced the strings by enums as discussed in the other thread.
if (!profile_) return;Code formatting is off. This should be caught by a presubmit script. Did you see a warning when you uploaded the CL? If not, could you file a bug or reopen an existing one (maybe b/386840832)?
I used the Gemini CLI to upload this CL, and it appears it automatically ran `git cl upload -f`, which bypassed the presubmit warnings. I've now formatted the code and manually verified that all presubmit checks pass.
Apologies for uploading unformatted files earlier.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
raw_ptr<Profile> profile_;Maryia Mankevichnit: raw_ref?
I ended up removing `profile_` entirely.
I was originally storing it to call `chrome::FindBrowserWithProfile()`, but the presubmit flagged that function as a banned anti-pattern (since it can return the wrong window if the user has multiple windows open for the same profile).
const std::string& action,Maryia Mankevichstd::string_view?
Replaced by enum.
for (const auto& target : GetTargetSequence()) {nit: spell out the type
removed since I started to use `base::Contains`.
bool relevant = false;
for (const auto& target : GetTargetSequence()) {
if (action == target) {
relevant = true;
break;
}
}nit: `bool relevant = base::Contains(...)`?
Done
for (size_t i = 0; i < GetTargetSequence().size(); ++i) {Maryia Mankevichnit: use base::zip()
It looks like using `std::ranges::equal` in `CheckSequence` is even better than loop with `base::zip()`. WDYT?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
AutofillAtMemoryPromoDetector(const AutofillAtMemoryPromoDetector&) = delete;
AutofillAtMemoryPromoDetector& operator=(
const AutofillAtMemoryPromoDetector&) = delete;Move above destructor go/cstyle#Declaration_Order
"ActiveTabChanged",
"Copy",
"ActiveTabChanged",
"Paste",Maryia MankevichWhere do these string constants come from? Shouldn't this be an enum?
I originally used strings to match the names in actions.xml, but since I'm just passing events directly from the TabHelper and not using ActionObserver, I don't actually need these strings.
I've refactored it to use enum instead.
Acknowledged
const std::vector<std::string>& GetTargetSequence() {
static const base::NoDestructor<std::vector<std::string>> kTargetSequence({
"ActiveTabChanged",
"Copy",
"ActiveTabChanged",
"Paste",
});
return *kTargetSequence;
}nit:
```
constexpr const char* kTargetSequence[] = ...;
```
?
I replaced the strings by enums as discussed in the other thread.
Acknowledged
const std::vector<AutofillAtMemoryPromoDetector::Action>& GetTargetSequence() {
static const base::NoDestructor<
std::vector<AutofillAtMemoryPromoDetector::Action>>
kTargetSequence({
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kCopy,
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kPaste,
});
return *kTargetSequence;
}Use `std::array`, e.g.,
```
static constexpr auto kTargetSequence =
std::to_array<AutofillAtMemoryPromoDetector::Action>({
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kCopy,
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kPaste});
```
if (!profile_) return;Maryia MankevichCode formatting is off. This should be caught by a presubmit script. Did you see a warning when you uploaded the CL? If not, could you file a bug or reopen an existing one (maybe b/386840832)?
I used the Gemini CLI to upload this CL, and it appears it automatically ran `git cl upload -f`, which bypassed the presubmit warnings. I've now formatted the code and manually verified that all presubmit checks pass.
Apologies for uploading unformatted files earlier.
Thanks! Could you file a bug?
for (size_t i = 0; i < GetTargetSequence().size(); ++i) {Maryia Mankevichnit: use base::zip()
It looks like using `std::ranges::equal` in `CheckSequence` is even better than loop with `base::zip()`. WDYT?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
std::equal_to<Action>(), &ActionRecord::action)) {Remove?
AutofillAtMemoryPromoDetector(const AutofillAtMemoryPromoDetector&) = delete;
AutofillAtMemoryPromoDetector& operator=(
const AutofillAtMemoryPromoDetector&) = delete;Maryia MankevichMove above destructor go/cstyle#Declaration_Order
Done
const std::vector<AutofillAtMemoryPromoDetector::Action>& GetTargetSequence() {
static const base::NoDestructor<
std::vector<AutofillAtMemoryPromoDetector::Action>>
kTargetSequence({
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kCopy,
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kPaste,
});
return *kTargetSequence;
}Use `std::array`, e.g.,
```
static constexpr auto kTargetSequence =
std::to_array<AutofillAtMemoryPromoDetector::Action>({
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kCopy,
AutofillAtMemoryPromoDetector::Action::kActiveTabChanged,
AutofillAtMemoryPromoDetector::Action::kPaste});
```
Done
if (!profile_) return;Maryia MankevichCode formatting is off. This should be caught by a presubmit script. Did you see a warning when you uploaded the CL? If not, could you file a bug or reopen an existing one (maybe b/386840832)?
Christoph SchweringI used the Gemini CLI to upload this CL, and it appears it automatically ran `git cl upload -f`, which bypassed the presubmit warnings. I've now formatted the code and manually verified that all presubmit checks pass.
Apologies for uploading unformatted files earlier.
Thanks! Could you file a bug?
Do you mean filing a bug for the Gemini CLI team? I'm not sure if it's considered a bug, since the result depends on the prompt (I can just ask Gemini explicitly not to use -f when uploading).
std::equal_to<Action>(), &ActionRecord::action)) {Remove?
I couldn't remove it completely because I need to pass the projection (&ActionRecord::action) as the 4th argument, since I am comparing a collection of structs against a collection of enums. I can replace it with {}. Did this for now. PTAL.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
std::equal_to<Action>(), &ActionRecord::action)) {Maryia MankevichRemove?
I couldn't remove it completely because I need to pass the projection (&ActionRecord::action) as the 4th argument, since I am comparing a collection of structs against a collection of enums. I can replace it with {}. Did this for now. PTAL.
Makes sense, thanks!
// WARNING: Do not use this class for desktop chrome. Use TabFeatures instead.
// See
// https://chromium.googlesource.com/chromium/src/+/main/docs/chrome_browser_design_principles.md
void TabHelpers::AttachTabHelpers(WebContents* web_contents) {Note this. (Sorry I had missed this earlier.)
But I'm wondering if we really need a KeyedService + TabFeature for this. Can we just make it a member of ChromeAutofillClient to save a lot of boilerplate code?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// WARNING: Do not use this class for desktop chrome. Use TabFeatures instead.
// See
// https://chromium.googlesource.com/chromium/src/+/main/docs/chrome_browser_design_principles.md
void TabHelpers::AttachTabHelpers(WebContents* web_contents) {Note this. (Sorry I had missed this earlier.)
But I'm wondering if we really need a KeyedService + TabFeature for this. Can we just make it a member of ChromeAutofillClient to save a lot of boilerplate code?
Great point on the boilerplate!
Since this needs to track a sequence across different tabs, I think it can't live entirely in `ChromeAutofillClient`.
To simplify things, i'll try to do it using `PersonalDataManager` instead of my custom `KeyedSevice` and `ChromeAutofillClient` instead of my custom `TabHelper`.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |