Skip to content

Add New tab page options to settings #6879

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

Merged
merged 14 commits into from
Oct 30, 2020
Merged

Add New tab page options to settings #6879

merged 14 commits into from
Oct 30, 2020

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Oct 16, 2020

With this, user can select which page should be opened in NTP.

Screen Shot 2020-10-23 at 5 41 29 PM

Screen Shot 2020-10-23 at 5 41 40 PM

dark mode blank page:
Screenshot from 2020-10-28 10-47-00

Resolves brave/brave-browser#2999

Submitter Checklist:

Test Plan:

npm run test brave_unit_tests -- --filter=*BraveNewTabTest*

  1. Choose Dashboard...
  2. Create NTP by new tab button, shortcut(ex, CMD+T or new tab from app menu)
  3. Check brave NTP is opened
  4. Choose HomePage
  5. If newtab is homepage is on, create NTP is brave NTP
  6. If newtab is homepage is off, configured page is opened
  7. Choose blankpage
  8. Check about:blank is loaded for NTP

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 self-assigned this Oct 16, 2020
@simonhong simonhong force-pushed the new_tab_shows_options branch from 9efd0e4 to dd2f61e Compare October 16, 2020 13:03
@simonhong simonhong marked this pull request as ready for review October 16, 2020 15:46
@simonhong simonhong requested a review from a team as a code owner October 16, 2020 15:46
@simonhong simonhong force-pushed the new_tab_shows_options branch from dd2f61e to c809b7b Compare October 16, 2020 15:47
@mkarolin
Copy link
Collaborator

This setting seems to also apply to Private and Tor windows. Is this expected?

@simonhong
Copy link
Member Author

@mkarolin It's not intentional. @rebron should we only apply this behavior to normal window?

@simonhong simonhong force-pushed the new_tab_shows_options branch from c809b7b to 6ecc6fe Compare October 19, 2020 03:18
@bsclifton
Copy link
Member

@simonhong I think we only need to apply this to regular window - Private and Private w/ Tor windows both have the informational page that we would like to show

@simonhong simonhong force-pushed the new_tab_shows_options branch from 6ecc6fe to 391c5de Compare October 19, 2020 07:29
@simonhong
Copy link
Member Author

This option is only effective for normal window.

@simonhong simonhong force-pushed the new_tab_shows_options branch from 391c5de to 83f36e6 Compare October 19, 2020 08:57
@simonhong
Copy link
Member Author

@rebron @bsclifton , one more question - Should New Window also follow this option?
With current PR, only new tab created by new tab command(cmd + T or click new tab button) uses this option.
and new window is launched with one NTP.

@simonhong simonhong added this to the 1.18.x - Nightly milestone Oct 21, 2020
@simonhong simonhong force-pushed the new_tab_shows_options branch from 83f36e6 to 58e0092 Compare October 21, 2020 02:08
@bsclifton bsclifton force-pushed the new_tab_shows_options branch from 58e0092 to 1755ed9 Compare October 21, 2020 19:14
@bsclifton
Copy link
Member

bsclifton commented Oct 21, 2020

Curious what you think @karenkliu @rebron
image

To me, it makes more sense to put New Tab shows at the top (above the Customize your Brave Dashboard)

Unrelated to this PR, I think that Brave Rewards, Binance, Gemini, Crypto.com, etc should all be under a Widgets parent item, similar to how Background images has sub-items
cc: @ryanml

@bsclifton
Copy link
Member

bsclifton commented Oct 21, 2020

@rebron @bsclifton , one more question - Should New Window also follow this option?
With current PR, only new tab created by new tab command(cmd + T or click new tab button) uses this option.
and new window is launched with one NTP.

Yes - this new setting should be checked/respected when opening a new window too 😄

Should we hide the Homepage option if the Show home button preference is disabled? I think we should consider hiding it. When it's disabled, it defaults to brave://newtab - so user might think preference is not being respected. User needs to enable home button in order to actually set the home page

@rebron
Copy link
Collaborator

rebron commented Oct 21, 2020

@karenkliu and I chatted about this yesterday. Placement looks good.

We should hide the homepage option until a user enables the homepage button. Otherwise, it won't really make sense.


namespace chrome {

// Whole logic is copied from upstream chrome::NewTab().
Copy link
Member

@bsclifton bsclifton Oct 21, 2020

Choose a reason for hiding this comment

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

Maybe also note as part of this comment:

// the only change is `new_tab_url` instead of `Gurl()`

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Code changes look really good! Notes left about how this should work on new window also

@karenkliu may have some comments too 😄

@karenkliu
Copy link

@simonhong Hi Simon, after going through the details again, these are some updates to the design:

  • Remove "Customize Brave Dashboard" label from the New Tab Page section because with the addition of this dropdown the controls no longer apply to just the dashboard
  • The New tab page shows... dropdown should go at the top of the New Tab Page section

image

  • The widgets go at the bottom of the New Tab Page section, after Top Sites
  • The options are Dashboard, Homepage, and Blank page
  • If the user selects Blank page, then the user will get a blank white page in light theme and #17171F in dark theme
  • If user selects Homepage or Blank page, then the Dashboard options will not be shown:

image
image

@simonhong
Copy link
Member Author

simonhong commented Oct 22, 2020

@bsclifton @rebron What should we do in this scenario?
At first, user turned homepage button on and New Tab Page is set as Homepage.
Then, user turned off homepage button. How should we change New Tab page shows option?

IMO, making Homepage available always seems fine because Homepage url prefs are persisted regardless of homepage button show option. WDYT?

@mkarolin
Copy link
Collaborator

Agree with @simonhong that it would be more beneficial to have Homepage drop-down option visible not based on the Home Button setting, but rather on whether the homepage URL has been set. However, setting the Home URL is not well-discoverable in the settings right now.

Why not always have the Homepage drop-down visible and, if selected, show to the user the entry field to set the URL (which would be tied to the same pref as the one under Home Button)?

@bsclifton
Copy link
Member

I'm OK with always showing Homepage given above argument. WDYT @rebron? I could go either way 😛 Would defer to you

@simonhong
Copy link
Member Author

@karenkliu When user select Homepage, user can choose New Tab page as a homepage button option.
Or user can set empty string as a homepage url. In these cases, dashboard options should be visible.

@simonhong simonhong added the CI/skip Do not run CI builds (except noplatform) label Oct 23, 2020
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

Can remove the different resources for light and dark. I suggest we just use chrome://newtab and serve blank.html from there, but maybe there's a reason you created chrome://blank

<title>Blank page</title>
</head>

<body style="background-color:#FFFFFF;">
Copy link
Member

Choose a reason for hiding this comment

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

We can put a <style> element here which varies the background-color based on dark / light theme. Similar to on the dashboard NTP: https://github.com/brave/brave-core/blob/master/components/brave_new_tab_ui/brave_new_tab.html

@media (prefers-color-scheme: dark) {
    body { background-color: #333639; }
  }

Then we don't need both blank_page.html and dark_blank_page.html.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed 👍

Comment on lines 13 to 21
class BraveBlankPageUI : public content::WebUIController {
public:
BraveBlankPageUI(content::WebUI* web_ui,
const std::string& host);
~BraveBlankPageUI() override;

BraveBlankPageUI(const BraveBlankPageUI&) = delete;
BraveBlankPageUI& operator=(BraveBlankPageUI&) = delete;
};
Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating a whole new WebUI route and class, I was thinking we could just use the regular chrome://newtab route and class, and simply change the .html resource that is rendered, depending on the value of kNewTabPageShowsOptions. I can't think of a reason that we would need to have separate routes or both the dashboard route and the blank route available at the same time, regardless of the preference value. Do you have a different opinion?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought new tab and blank are different webui. So, I created new route.
But, I don't have strong opinon about this. I'll follow your suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

@petemill Fixed. PTAL again!

Copy link
Member Author

Choose a reason for hiding this comment

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

I realized that your approach is better because blank page can also act like NTP. - search suggestion in location bar.

Comment on lines 16 to 18
const bool is_dark_mode =
dark_mode::GetActiveBraveDarkModeType() ==
dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK;
Copy link
Member

Choose a reason for hiding this comment

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

See comment about no need to vary on dark mode.

Comment on lines 38 to 39
} else if (option == brave::NewTabPageShowsOptions::BLANKPAGE) {
return GURL(url::kAboutBlankURL);
return GURL(kBraveBlankPageURL);
Copy link
Member

Choose a reason for hiding this comment

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

see comment about not needing a separate route as far as I can tell

@simonhong simonhong force-pushed the new_tab_shows_options branch from 343a4c2 to da0dfe9 Compare October 28, 2020 01:34
@simonhong simonhong requested a review from petemill October 28, 2020 01:35
@simonhong simonhong force-pushed the new_tab_shows_options branch 2 times, most recently from 81c3903 to 2a5be52 Compare October 28, 2020 01:51
Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

chromium_src overrides LGTM

Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

Looks great to me apart from 1 html syntax error to fix

@simonhong simonhong force-pushed the new_tab_shows_options branch from 2a5be52 to dcb29c8 Compare October 28, 2020 23:27
@simonhong simonhong requested a review from petemill October 28, 2020 23:28
@simonhong simonhong force-pushed the new_tab_shows_options branch from dcb29c8 to 903c4c0 Compare October 28, 2020 23:51
With this, user can select which page should be opened in NTP.
Also renamed dashboard with images to dashboard.
Instead of url rewriting, navigation throttle is used.
When new tab url is requested, throttle cancels it if new tab options
url should be used.
With url rewriting, new tab options url loading is fine. However, tab title
is not updated well if blank url is loaded.
This blank page will have different bg color for theme type.
And new tab shows blank page options will use this page.
Blank page will be configured by BraveNewTabUI.
also fix some var name after c87 rebasing.
@simonhong simonhong force-pushed the new_tab_shows_options branch from 903c4c0 to 0713614 Compare October 29, 2020 23:51
@simonhong simonhong dismissed petemill’s stale review October 30, 2020 03:39

Fixed requested changes.

@simonhong
Copy link
Member Author

Merged because only unrelated rewards browser test are failed.

@simonhong simonhong merged commit 93bda64 into master Oct 30, 2020
@simonhong simonhong deleted the new_tab_shows_options branch October 30, 2020 03:56
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 new tab page settings
6 participants