-
Notifications
You must be signed in to change notification settings - Fork 872
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
Add always show bookmark bar on NTP option #2869
Conversation
Need to add test cases and not ready for review. |
377f9bb
to
c430ec3
Compare
app/brave_generated_resources.grd
Outdated
@@ -222,6 +222,9 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U | |||
<message name="IDS_SETTINGS_HIDE_BRAVE_REWARDS_BUTTON_DESC" desc="The description for settings switch controlling the visibility of Brave Rewards button"> | |||
Hides the Brave Rewards button in the location bar when Brave Rewards is not enabled | |||
</message> | |||
<message name="IDS_SETTINGS_ALWAYS_SHOW_BOOKMARK_BAR_ON_NTP" desc="The label for settings switch controlling the visibility of bookmarks bar on NTP"> | |||
Always show bookmarks bar on NTP |
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.
Is this a user-visible string? If so, I don't think the average user would understand what NTP means - probably better to spell it out instead of using an acronym.
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.
Agreed. @rebron Can you check this sentence?
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 you have it read: "Always show bookmarks bar on New Tab page."
c430ec3
to
0225e94
Compare
0225e94
to
3920262
Compare
@emerick This PR is ready to review. test case is also added. PTAL. |
744dc12
to
cfc0497
Compare
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
afea0c9
to
644387d
Compare
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.
Rebased on C76. PTAL @bridiver
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc | ||
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc | ||
@@ -67,6 +67,7 @@ bool BookmarkTabHelper::ShouldShowBookmarkBar() const { | ||
!prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)) | ||
return false; | ||
|
||
+ return false; | ||
+ ReturnFalseIfBookmarkBarShouldHide(profile); |
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.
This patch is inevitable because we have to return in the middle of existing logic.
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.
there is already a NTP check below. If we need to change the behavior of that check we can do a chromium_src override of search::NavEntryIsInstantNTP
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 guess I'm not sure if the override will work because of the ||
and I'm not sure what the real url is for a custom NTP, but let's discuss in dm
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.
another option here is to override BookmarkTabHelper
in browser.cc and replace with our own tab helper that proxies to the original instead of subclassing it (no virtual method issues and only needs to implement the subset of methods used in browser.cc)
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.
BraveBookmarkTabHelper
is introduced to proxy BookmarkTabHelper
.
base::Unretained(this), | ||
BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE)); | ||
|
||
+ RegisterAlwaysShowBookmarkBarOnNTPChange |
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.
There are some reason why I made a patch instead of subclassing Browser
class.
Browser
is created by static methodBrowser::Create()
. So, we also have to change it to returnBraveBrowser
. This also causes patching tobrowser.cc
.- To subclass, making a patch for
browser.h
is inevitable for overriding non-virtual method.
So, direct inserting it here is smallest patch.
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.
while this may be the smallest patch for this particular change, it is not very extensible. I think a better patch is a define in the header file which for now will just add a friend
class. The friend class can have its own pref registrar and call UpdateBookmarkBarState
using BrowserList (matching against the relevant profile). @iefremov already has a pref related BCKS in his network service PR that might make sense to reuse for this since a BCKS would make the most sense for this imo.
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.
BookmarkPrefsService is introduced.
5262b6a
to
afb373d
Compare
@bridiver can you check this one out? 😄 |
@bridiver kindly ping :) |
a1902f4
to
785392b
Compare
05b6db4
to
35fe8ac
Compare
fb50527
to
976078a
Compare
@bridiver come back from PTO. |
5ff0e95
to
9db7fd9
Compare
2370122
to
0b9171b
Compare
friend class BrowserTest; | ||
friend class FullscreenControllerInteractiveTest; | ||
friend class FullscreenControllerTest; | ||
+ friend class BookmarkPrefsService; |
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.
Most patches should be done as defines now to make them extensible. The convention would be BRAVE_BROWSER_H
and placed at the end of public:
. To add private
entries (like this one) just use private:
inside the define
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.
Done. 👍
0b9171b
to
b1ec3f3
Compare
b1ec3f3
to
b351cab
Compare
Some user might want to show bookmark on NTP when they choose to hide bookmark bar.
b351cab
to
1033a4b
Compare
…ption Add always show bookmark bar on NTP option
…ption Add always show bookmark bar on NTP option
…ption Add always show bookmark bar on NTP option
Fix brave/brave-browser#4782
Some user might want to show bookmark on NTP
when show bookmark bar option is false.
Like below, only NTP has bookmark bar when this option is on.
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
yarn test brave_browser_tests --filter=BookmarkTabHelperBrowserTest.AlwaysShowBookmarkBarOnNTPTest
Always show bookmarks bar on New Tab page
is off by defaultShow bookmarks bar
is offAlways show bookmarks bar on New Tab page
Always show bookmarks bar on New Tab page
onAlways show bookmarks bar on New Tab page
and check bookmark bar on NTP is hiddenShow bookmarks bar
and check bookmark bar on NTP is always visible regardless ofAlways show bookmarks bar on New Tab page
statusReviewer Checklist:
After-merge Checklist:
changes has landed on.