-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added search promotion button in omnibox #25409
Conversation
1ea573f
to
cad4c85
Compare
4586a2f
to
d06f456
Compare
@@ -36,6 +36,15 @@ | |||
add_trailing_decoration(item, /*intra_item_padding=*/0); \ | |||
} | |||
|
|||
#define BRAVE_LAYOUT_HANDLE_SEARCH_PROMOTION_BUTTON_VISIBILITY \ | |||
} \ | |||
else if (GetSearchPromotionButton() && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't avoid this presubmit error. @goodov can you advice how should I handle this?
brave/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc:41: (cpplint) If an else has a brace on one side, it should have it on both [readability/braces] [5]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would combining this line with the above help? Or does that trigger the formatter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's the formatter. Even with that style, still presubmit has same complaints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// NOLINT
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, NOLINT works! thanks.
d06f456
to
218f4a3
Compare
|
||
// Unretained here is safe as |close_button| is the child of this class. | ||
close_button->SetCallback(base::BindOnce(&PromotionButtonView::OnClosePressed, | ||
base::Unretained(this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] base::Unretained is most of the time unrequited, and a weak reference is better suited for secure coding.
Consider swapping Unretained for a weak reference.
base::Unretained usage may be acceptable when a callback owner is guaranteed
to be destroyed with the object base::Unretained is pointing to, for example:
- PrefChangeRegistrar
- base::*Timer
- mojo::Receiver
- any other class member destroyed when the class is deallocated
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/chromium-uaf.yaml
Cc @thypon @goodov @iefremov
|
||
// Unretained here is safe as this callback is used by itself. | ||
SetCallback(base::BindOnce(&PromotionButtonView::OnButtonPressed, | ||
base::Unretained(this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] base::Unretained is most of the time unrequited, and a weak reference is better suited for secure coding.
Consider swapping Unretained for a weak reference.
base::Unretained usage may be acceptable when a callback owner is guaranteed
to be destroyed with the object base::Unretained is pointing to, for example:
- PrefChangeRegistrar
- base::*Timer
- mojo::Receiver
- any other class member destroyed when the class is deallocated
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/chromium-uaf.yaml
Cc @thypon @goodov @iefremov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % nits
browser/ui/views/location_bar/brave_location_bar_view_browsertest.cc
Outdated
Show resolved
Hide resolved
base::OnceClosure dismissed_callback_; | ||
base::OnceClosure make_default_callback_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it that its fine to have these as OnceClosures
because the button hides after being interacted with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching here.
Right, OnceClosure
fits for dismissed_callback_
as this button is not shown again after dismissed.
However, make_default_callback_
should be RepeatingClosure
because we show this button again
if user set to non brave search again.
@rebron when user clicks this button, brave search is set as a default and not set dismissed bit.
So, user will see this promotion button again if user change to another search provider again.
Is this what we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't show the promotion button again if the user already set or dismissed it already.
browser/ui/views/location_bar/brave_search_conversion/promotion_button_controller.h
Show resolved
Hide resolved
browser/ui/views/location_bar/brave_search_conversion/promotion_button_controller.cc
Outdated
Show resolved
Hide resolved
browser/ui/views/location_bar/brave_search_conversion/promotion_button_controller.cc
Show resolved
Hide resolved
@@ -36,6 +36,15 @@ | |||
add_trailing_decoration(item, /*intra_item_padding=*/0); \ | |||
} | |||
|
|||
#define BRAVE_LAYOUT_HANDLE_SEARCH_PROMOTION_BUTTON_VISIBILITY \ | |||
} \ | |||
else if (GetSearchPromotionButton() && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would combining this line with the above help? Or does that trigger the formatter?
218f4a3
to
432e061
Compare
|
||
// Unretained here is safe as |close_button| is the child of this class. | ||
close_button->SetCallback(base::BindOnce(&PromotionButtonView::OnClosePressed, | ||
base::Unretained(this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] base::Unretained is most of the time unrequited, and a weak reference is better suited for secure coding.
Consider swapping Unretained for a weak reference.
base::Unretained usage may be acceptable when a callback owner is guaranteed
to be destroyed with the object base::Unretained is pointing to, for example:
- PrefChangeRegistrar
- base::*Timer
- mojo::Receiver
- any other class member destroyed when the class is deallocated
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/chromium-uaf.yaml
Cc @thypon @goodov @iefremov
} | ||
selected_keyword_view_->SetCustomImage(image); | ||
} | ||
+ BRAVE_LAYOUT_HANDLE_SEARCH_PROMOTION_BUTTON_VISIBILITY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: BRAVE_LOCATION_BAR_VIEW_LAYOUT_...
(all defines in this file can be updated).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings
++
432e061
to
901cb2b
Compare
[puLL-Merge] - brave/brave-core@25409 DescriptionThis PR adds a new search conversion promotion button to the location bar in Brave browser. The button aims to encourage users to switch to Brave Search as their default search engine. ChangesChanges
Possible Issues
Security HotspotsNone identified. The changes primarily involve UI elements and don't directly interact with sensitive data or security-critical components. |
fix brave/brave-browser#40776
Resolves
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Manual test: see the linked issue
BraveLocationBarViewBrowserTest.SearchConversionButtonTest