Skip to content
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

Merged
merged 1 commit into from
Aug 23, 2019

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Jul 5, 2019

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.
Screen Shot 2019-07-05 at 15 10 14

Submitter Checklist:

Test Plan:

yarn test brave_browser_tests --filter=BookmarkTabHelperBrowserTest.AlwaysShowBookmarkBarOnNTPTest

  1. Launch browser with clean profile
  2. Check Always show bookmarks bar on New Tab page is off by default
  3. Check Show bookmarks bar is off
  4. Load NTP
  5. Check bookmark bar on NTP is hidden regardless of Always show bookmarks bar on New Tab page
  6. Add any bookmark and turn Always show bookmarks bar on New Tab page on
  7. Check bookmark bar on NTP is visible after active tab changing to trigger bookmark bar visibility
  8. Turn off Always show bookmarks bar on New Tab page and check bookmark bar on NTP is hidden
  9. Turn on Show bookmarks bar and check bookmark bar on NTP is always visible regardless of Always show bookmarks bar on New Tab page status

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@simonhong simonhong added this to the 0.69.x - Nightly milestone Jul 5, 2019
@simonhong simonhong requested a review from bridiver as a code owner July 5, 2019 06:13
@simonhong simonhong self-assigned this Jul 5, 2019
@simonhong simonhong added the CI/skip Do not run CI builds (except noplatform) label Jul 5, 2019
@simonhong simonhong requested a review from emerick July 5, 2019 06:14
@simonhong
Copy link
Member Author

simonhong commented Jul 5, 2019

Need to add test cases and not ready for review.

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch from 377f9bb to c430ec3 Compare July 5, 2019 06:20
@simonhong simonhong closed this Jul 5, 2019
@simonhong simonhong reopened this Jul 5, 2019
@@ -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
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Collaborator

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."

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch from c430ec3 to 0225e94 Compare July 5, 2019 12:28
@simonhong simonhong removed the CI/skip Do not run CI builds (except noplatform) label Jul 5, 2019
@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch from 0225e94 to 3920262 Compare July 5, 2019 12:32
@simonhong
Copy link
Member Author

@emerick This PR is ready to review. test case is also added. PTAL.

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from 744dc12 to cfc0497 Compare July 5, 2019 12:35
emerick
emerick previously approved these changes Jul 5, 2019
Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from afea0c9 to 644387d Compare July 12, 2019 00:59
Copy link
Member Author

@simonhong simonhong left a 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);
Copy link
Member Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

@bridiver bridiver Aug 7, 2019

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)

Copy link
Member Author

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
Copy link
Member Author

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.

  1. Browser is created by static method Browser::Create(). So, we also have to change it to return BraveBrowser. This also causes patching to browser.cc.
  2. To subclass, making a patch for browser.h is inevitable for overriding non-virtual method.
    So, direct inserting it here is smallest patch.

Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BookmarkPrefsService is introduced.

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from 5262b6a to afb373d Compare July 16, 2019 00:47
@bsclifton
Copy link
Member

@bridiver can you check this one out? 😄

@simonhong
Copy link
Member Author

@bridiver kindly ping :)

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from a1902f4 to 785392b Compare July 31, 2019 01:59
@simonhong simonhong added the CI/skip Do not run CI builds (except noplatform) label Aug 19, 2019
@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from 05b6db4 to 35fe8ac Compare August 19, 2019 07:59
@simonhong simonhong removed the CI/skip Do not run CI builds (except noplatform) label Aug 19, 2019
@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from fb50527 to 976078a Compare August 19, 2019 12:36
@simonhong
Copy link
Member Author

@bridiver come back from PTO.
I think I addressed all your comments. PTAL.

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 2 times, most recently from 5ff0e95 to 9db7fd9 Compare August 20, 2019 00:43
@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch 3 times, most recently from 2370122 to 0b9171b Compare August 20, 2019 03:51
friend class BrowserTest;
friend class FullscreenControllerInteractiveTest;
friend class FullscreenControllerTest;
+ friend class BookmarkPrefsService;
Copy link
Collaborator

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. 👍

@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch from 0b9171b to b1ec3f3 Compare August 21, 2019 00:20
@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch from b1ec3f3 to b351cab Compare August 21, 2019 00:42
Some user might want to show bookmark on NTP
when they choose to hide bookmark bar.
@simonhong simonhong force-pushed the add_always_show_bookmark_on_ntp_option branch from b351cab to 1033a4b Compare August 21, 2019 02:56
@simonhong simonhong merged commit f5e6114 into master Aug 23, 2019
@simonhong simonhong deleted the add_always_show_bookmark_on_ntp_option branch August 23, 2019 01:31
simonhong added a commit that referenced this pull request Aug 23, 2019
…ption

Add always show bookmark bar on NTP option
simonhong added a commit that referenced this pull request Aug 23, 2019
…ption

Add always show bookmark bar on NTP option
simonhong added a commit that referenced this pull request Aug 24, 2019
…ption

Add always show bookmark bar on NTP option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add setting to 'Always show bookmarks bar on New Tab Page'
5 participants