Skip to content

Commit

Permalink
Add prototype for NTP refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
zenparsing committed Feb 4, 2025
1 parent b37a0fe commit 084692d
Show file tree
Hide file tree
Showing 142 changed files with 10,652 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const slashStoriesIndexer: Indexer = {
const config: StorybookConfig = {
stories: process.env.STORYBOOK_STORYPATH
? [`../${process.env.STORYBOOK_STORYPATH}`]
: ['../components/**/stories/*.tsx', '../components/**/*.stories.tsx'],
: [
'../components/**/stories/*.tsx',
'../components/**/*.stories.tsx',
'../browser/resources/**/stories/*.tsx'
],
typescript: {
check: false,
reactDocgen: false,
Expand Down
7 changes: 7 additions & 0 deletions browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,13 @@ const flags_ui::FeatureEntry::FeatureVariation kZCashFeatureVariations[] = {
kOsDesktop, \
FEATURE_VALUE_TYPE(features::kBraveNtpSearchWidget), \
}, \
{ \
"brave-use-updated-ntp", \
"Use the updated New Tab Page", \
"Uses an updated version of the New Tab Page", \
kOsDesktop, \
FEATURE_VALUE_TYPE(features::kUseUpdatedNTP), \
}, \
{ \
"brave-adblock-cname-uncloaking", \
"Enable CNAME uncloaking", \
Expand Down
4 changes: 4 additions & 0 deletions browser/brave_browser_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

namespace features {

BASE_FEATURE(kUseUpdatedNTP,
"BraveUseUpdatedNewTabPage",
base::FEATURE_DISABLED_BY_DEFAULT);

// Cleanup Session Cookies on browser restart if Session Restore is enabled.
BASE_FEATURE(kBraveCleanupSessionCookiesOnSessionRestore,
"BraveCleanupSessionCookiesOnSessionRestore",
Expand Down
1 change: 1 addition & 0 deletions browser/brave_browser_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace features {

BASE_DECLARE_FEATURE(kUseUpdatedNTP);
BASE_DECLARE_FEATURE(kBraveCleanupSessionCookiesOnSessionRestore);
BASE_DECLARE_FEATURE(kBraveCopyCleanLinkByDefault);
BASE_DECLARE_FEATURE(kBraveCopyCleanLinkFromJs);
Expand Down
8 changes: 8 additions & 0 deletions browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ using extensions::ChromeContentBrowserClientExtensionsPart;
#if !BUILDFLAG(IS_ANDROID)
#include "brave/browser/new_tab/new_tab_shows_navigation_throttle.h"
#include "brave/browser/ui/geolocation/brave_geolocation_permission_tab_helper.h"
#include "brave/browser/ui/webui/brave_new_tab/new_tab_page_ui.h"
#include "brave/browser/ui/webui/brave_news_internals/brave_news_internals_ui.h"
#include "brave/browser/ui/webui/brave_rewards/rewards_page_top_ui.h"
#include "brave/browser/ui/webui/brave_rewards/rewards_panel_ui.h"
Expand Down Expand Up @@ -664,14 +665,21 @@ void BraveContentBrowserClient::RegisterWebUIInterfaceBrokers(
.Add<brave_new_tab_page::mojom::PageHandlerFactory>()
.Add<brave_news::mojom::BraveNewsController>();

auto ntp_next_registration =
registry.ForWebUI<brave_new_tab::NewTabPageUI>()
.Add<brave_new_tab::mojom::NewTabPageHandler>()
.Add<brave_rewards::mojom::RewardsPageHandler>();

#if BUILDFLAG(ENABLE_BRAVE_VPN)
if (brave_vpn::IsBraveVPNFeatureEnabled()) {
ntp_registration.Add<brave_vpn::mojom::ServiceHandler>();
ntp_next_registration.Add<brave_vpn::mojom::ServiceHandler>();
}
#endif

if (base::FeatureList::IsEnabled(features::kBraveNtpSearchWidget)) {
ntp_registration.Add<searchbox::mojom::PageHandler>();
ntp_next_registration.Add<searchbox::mojom::PageHandler>();
}

if (base::FeatureList::IsEnabled(
Expand Down
29 changes: 29 additions & 0 deletions browser/resources/brave_new_tab/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2025 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

import("//brave/components/common/typescript.gni")
import("//mojo/public/tools/bindings/mojom.gni")

assert(!is_android)

transpile_web_ui("resources") {
entry_points = [ [
"new_tab",
rebase_path("new_tab_page.tsx"),
] ]
resource_name = "brave_new_tab"
output_module = true
deps = [
"//brave/browser/ui/webui/brave_new_tab:mojom_js",
"//brave/components/brave_rewards/core/mojom:webui_js",
"//brave/components/brave_vpn/common/mojom:mojom_js",
]
}

pack_web_resources("generated_resources") {
resource_name = "brave_new_tab"
output_dir = "$root_gen_dir/brave/browser/resources/brave_new_tab"
deps = [ ":resources" ]
}
42 changes: 42 additions & 0 deletions browser/resources/brave_new_tab/assets/favorites_active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions browser/resources/brave_new_tab/assets/favorites_active_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 084692d

Please sign in to comment.