diff --git a/DEPS b/DEPS index ddf0ca298bb0..0f3c1115461e 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ deps = { "vendor/bip39wally-core-native": "https://github.com/brave-intl/bat-native-bip39wally-core.git@0d3a8713a2b388d2156fe49a70ef3f7cdb44b190", "vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@e3742ba3e8942eea9e4755d91532491871bd3116", "vendor/bat-native-tweetnacl": "https://github.com/brave-intl/bat-native-tweetnacl.git@800f9d40b7409239ff192e0be634764e747c7a75", - "vendor/challenge_bypass_ristretto_ffi": "https://github.com/brave-intl/challenge-bypass-ristretto-ffi.git@c5d6d74fdbee467732bcb6b9084514839e656286", + "vendor/challenge_bypass_ristretto_ffi": "https://github.com/brave-intl/challenge-bypass-ristretto-ffi.git@419995e4a873c294f1eaefca276f8ad25328e89f", "vendor/gn-project-generators": "https://github.com/brave/gn-project-generators.git@b76e14b162aa0ce40f11920ec94bfc12da29e5d0", "vendor/web-discovery-project": "https://github.com/brave/web-discovery-project@c4775a115f0800e0961e077d6a89b35cf92d3928", "third_party/ethash/src": "https://github.com/chfast/ethash.git@e4a15c3d76dc09392c7efd3e30d84ee3b871e9ce", diff --git a/android/brave_java_sources.gni b/android/brave_java_sources.gni index 6f8ed2623935..73394b933e8f 100644 --- a/android/brave_java_sources.gni +++ b/android/brave_java_sources.gni @@ -6,6 +6,7 @@ import("//brave/android/features/tab_ui/brave_tab_management_java_sources.gni") import("//brave/android/feed/brave_feed_java_sources.gni") import("//brave/browser/brave_ads/android/java_sources.gni") +import("//brave/browser/flags/brave_flags_java_sources.gni") import("//brave/browser/share/android/java_sources.gni") import("//brave/components/brave_referrals/buildflags/buildflags.gni") import("//brave/components/permissions/android/java_sources.gni") diff --git a/android/java/apk_for_test.flags b/android/java/apk_for_test.flags index f489969de27d..cb0537bb6309 100644 --- a/android/java/apk_for_test.flags +++ b/android/java/apk_for_test.flags @@ -141,6 +141,7 @@ *** mTabContentManager; *** mTabCreatorManager; *** mSnackbarManager; + *** mTabObscuringHandler; *** onOrientationChange(...); *** updateBookmarkButtonStatus(...); *** updateReloadState(...); @@ -585,3 +586,31 @@ -keep class org.chromium.chrome.browser.tasks.ReturnToChromeUtil { *** shouldShowTabSwitcher(...); } + +-keep class org.chromium.chrome.browser.IntentHandler { + public (...); + *** getUrlForCustomTab(...); + *** getUrlForWebapp(...); + *** isJavascriptSchemeOrInvalidUrl(...); + *** extractUrlFromIntent(...); +} + +-keep class org.chromium.chrome.browser.BraveIntentHandler { + public (...); +} + +-keep class org.chromium.chrome.browser.AppHooksImpl { + public (...); +} + +-keep class org.chromium.chrome.browser.BraveAppHooks { + public (...); +} + +-keep class org.chromium.chrome.browser.flags.CachedFlag { + (...); +} + +-keep class org.chromium.chrome.browser.flags.BraveCachedFlag { + (...); +} diff --git a/android/java/org/chromium/chrome/browser/crash/BravePureJavaExceptionReporter.java b/android/java/org/chromium/chrome/browser/crash/BravePureJavaExceptionReporter.java index e6b5cbcc481f..dc43ed8df866 100644 --- a/android/java/org/chromium/chrome/browser/crash/BravePureJavaExceptionReporter.java +++ b/android/java/org/chromium/chrome/browser/crash/BravePureJavaExceptionReporter.java @@ -5,8 +5,8 @@ package org.chromium.chrome.browser.crash; -import org.chromium.base.annotations.MainDex; -import org.chromium.base.annotations.UsedByReflection; +import org.chromium.build.annotations.MainDex; +import org.chromium.build.annotations.UsedByReflection; import java.io.File; diff --git a/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java b/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java index e632da9c0014..dce4882383c4 100644 --- a/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java +++ b/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java @@ -720,7 +720,8 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { // This function used when we have scanned the QR code to connect to the chain private void seedHexReceived(String seedHex) { assert seedHex != null && !seedHex.isEmpty(); - assert isSeedHexValid(seedHex); + boolean seedHexValid = isSeedHexValid(seedHex); + assert seedHexValid; if (null == getActivity()) { return; diff --git a/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java b/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java index 3faaa9f3c862..26d2a172e4b8 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java +++ b/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java @@ -49,6 +49,7 @@ import org.chromium.chrome.browser.share.ShareDelegate; import org.chromium.chrome.browser.tab.SadTab; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.chrome.browser.tab.TabObscuringHandler; import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider; import org.chromium.chrome.browser.tabmodel.TabCreatorManager; import org.chromium.chrome.browser.tabmodel.TabModelSelector; @@ -70,7 +71,6 @@ import org.chromium.chrome.browser.toolbar.top.ToolbarActionModeCallback; import org.chromium.chrome.browser.toolbar.top.ToolbarControlContainer; import org.chromium.chrome.browser.toolbar.top.TopToolbarCoordinator; -import org.chromium.chrome.browser.ui.TabObscuringHandler; import org.chromium.chrome.browser.ui.appmenu.AppMenuCoordinator; import org.chromium.chrome.browser.ui.appmenu.AppMenuDelegate; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; @@ -113,6 +113,7 @@ public class BraveToolbarManager extends ToolbarManager { private TabContentManager mTabContentManager; private TabCreatorManager mTabCreatorManager; private SnackbarManager mSnackbarManager; + private TabObscuringHandler mTabObscuringHandler; // Own members. private boolean mIsBottomToolbarVisible; @@ -235,7 +236,7 @@ public void enableBottomControls() { /* Below are parameters for BottomControlsCoordinator */ mActivity, mWindowAndroid, mLayoutManager, mCompositorViewHolder.getResourceManager(), mBrowserControlsSizer, - mFullscreenManager, mBottomControls, mTabGroupUi, + mFullscreenManager, mBottomControls, mTabGroupUi, mTabObscuringHandler, mOverlayPanelVisibilitySupplier, getConstraintsProxy())); mBottomControls.setBottomControlsCoordinatorSupplier( mBottomControlsCoordinatorSupplier); diff --git a/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java index 3f1b0effdfd9..905f36371913 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java @@ -27,6 +27,7 @@ import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.layouts.LayoutManager; import org.chromium.chrome.browser.layouts.LayoutStateProvider; +import org.chromium.chrome.browser.tab.TabObscuringHandler; import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider; import org.chromium.chrome.browser.theme.ThemeColorProvider; import org.chromium.chrome.browser.toolbar.HomeButton; @@ -61,12 +62,12 @@ public BraveBottomControlsCoordinator( Activity activity, WindowAndroid windowAndroid, LayoutManager layoutManager, ResourceManager resourceManager, BrowserControlsSizer controlsSizer, FullscreenManager fullscreenManager, ScrollingBottomViewResourceFrameLayout root, - BottomControlsContentDelegate contentDelegate, + BottomControlsContentDelegate contentDelegate, TabObscuringHandler tabObscuringHandler, ObservableSupplier overlayPanelVisibilitySupplier, ObservableSupplier constraintsSupplier) { super(activity, windowAndroid, layoutManager, resourceManager, controlsSizer, - fullscreenManager, root, contentDelegate, overlayPanelVisibilitySupplier, - constraintsSupplier); + fullscreenManager, root, contentDelegate, tabObscuringHandler, + overlayPanelVisibilitySupplier, constraintsSupplier); mTabSwitcherLongclickListener = tabSwitcherLongclickListener; mTabProvider = tabProvider; diff --git a/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java b/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java index 02b55df70f1f..13c2b4544279 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java +++ b/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java @@ -422,7 +422,8 @@ public void onPageLoadFinished(final Tab tab, GURL url) { } @Override - public void onDidFinishNavigation(Tab tab, NavigationHandle navigation) { + public void onDidFinishNavigationInPrimaryMainFrame( + Tab tab, NavigationHandle navigation) { if (getToolbarDataProvider().getTab() == tab && mBraveRewardsNativeWorker != null && !tab.isIncognito()) { mBraveRewardsNativeWorker.OnNotifyFrontTabUrlChanged( diff --git a/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java index 2c64753467ea..013671e9e32f 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java @@ -56,8 +56,8 @@ public BraveTopToolbarCoordinator(ToolbarControlContainer controlContainer, ObservableSupplier appMenuButtonHelperSupplier, ObservableSupplier tabModelSelectorSupplier, ObservableSupplier homepageEnabledSupplier, - ObservableSupplier identityDiscStateSupplier, - Callback invalidatorCallback, Supplier identityDiscButtonSupplier, + ButtonDataProvider identityDiscController, Callback invalidatorCallback, + Supplier identityDiscButtonSupplier, Supplier resourceManagerSupplier, ObservableSupplier isProgressBarVisibleSupplier, BooleanSupplier isIncognitoModeEnabledSupplier, boolean isGridTabSwitcherEnabled, @@ -65,7 +65,6 @@ public BraveTopToolbarCoordinator(ToolbarControlContainer controlContainer, boolean isStartSurfaceEnabled, boolean isTabGroupsAndroidContinuationEnabled, HistoryDelegate historyDelegate, BooleanSupplier partnerHomepageEnabledSupplier, OfflineDownloader offlineDownloader, boolean initializeWithIncognitoColors, - ObservableSupplier profileSupplier, Callback startSurfaceLogoClickedCallback, boolean isStartSurfaceRefactorEnabled, ObservableSupplier constraintsSupplier) { @@ -74,13 +73,13 @@ public BraveTopToolbarCoordinator(ToolbarControlContainer controlContainer, layoutStateProviderSupplier, normalThemeColorProvider, overviewThemeColorProvider, browsingModeMenuButtonCoordinator, overviewModeMenuButtonCoordinator, appMenuButtonHelperSupplier, tabModelSelectorSupplier, homepageEnabledSupplier, - identityDiscStateSupplier, invalidatorCallback, identityDiscButtonSupplier, + identityDiscController, invalidatorCallback, identityDiscButtonSupplier, resourceManagerSupplier, isProgressBarVisibleSupplier, isIncognitoModeEnabledSupplier, isGridTabSwitcherEnabled, isTabletGtsPolishEnabled, isTabToGtsAnimationEnabled, isStartSurfaceEnabled, isTabGroupsAndroidContinuationEnabled, historyDelegate, partnerHomepageEnabledSupplier, offlineDownloader, initializeWithIncognitoColors, - profileSupplier, startSurfaceLogoClickedCallback, isStartSurfaceRefactorEnabled, + startSurfaceLogoClickedCallback, isStartSurfaceRefactorEnabled, constraintsSupplier); mBraveToolbarLayout = toolbarLayout; diff --git a/android/java/org/chromium/chrome/browser/upgrade/BraveUpgradeJobIntentService.java b/android/java/org/chromium/chrome/browser/upgrade/BraveUpgradeJobIntentService.java index 09657d6efb50..01080bdff69b 100644 --- a/android/java/org/chromium/chrome/browser/upgrade/BraveUpgradeJobIntentService.java +++ b/android/java/org/chromium/chrome/browser/upgrade/BraveUpgradeJobIntentService.java @@ -5,7 +5,7 @@ package org.chromium.chrome.browser.upgrade; -import org.chromium.base.annotations.IdentifierNameString; +import org.chromium.build.annotations.IdentifierNameString; import org.chromium.chrome.browser.base.SplitCompatJobIntentService; public class BraveUpgradeJobIntentService extends SplitCompatJobIntentService { diff --git a/android/java/org/chromium/chrome/browser/vpn/wireguard/WireguardService.java b/android/java/org/chromium/chrome/browser/vpn/wireguard/WireguardService.java index 67a42c84b2b4..03b01b6afd3b 100644 --- a/android/java/org/chromium/chrome/browser/vpn/wireguard/WireguardService.java +++ b/android/java/org/chromium/chrome/browser/vpn/wireguard/WireguardService.java @@ -5,7 +5,7 @@ package org.chromium.chrome.browser.vpn.wireguard; -import org.chromium.base.annotations.IdentifierNameString; +import org.chromium.build.annotations.IdentifierNameString; import org.chromium.chrome.browser.base.SplitCompatService; /** See {@link WireguardServiceImpl}. */ diff --git a/android/javatests/org/chromium/chrome/browser/BytecodeTest.java b/android/javatests/org/chromium/chrome/browser/BytecodeTest.java index 8ab8df41cd7e..6ba5ac310cec 100644 --- a/android/javatests/org/chromium/chrome/browser/BytecodeTest.java +++ b/android/javatests/org/chromium/chrome/browser/BytecodeTest.java @@ -7,6 +7,7 @@ import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.res.Resources; import android.os.Handler; import android.util.AttributeSet; @@ -71,6 +72,7 @@ import org.chromium.chrome.browser.share.crow.CrowButtonDelegate; import org.chromium.chrome.browser.suggestions.tile.TileRenderer; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.chrome.browser.tab.TabObscuringHandler; import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; import org.chromium.chrome.browser.tabmodel.ChromeTabCreator; import org.chromium.chrome.browser.tabmodel.ChromeTabCreator.OverviewNTPCreator; @@ -79,6 +81,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.theme.ThemeColorProvider; import org.chromium.chrome.browser.theme.TopUiThemeColorProvider; +import org.chromium.chrome.browser.toolbar.ButtonDataProvider; import org.chromium.chrome.browser.toolbar.ToolbarDataProvider; import org.chromium.chrome.browser.toolbar.ToolbarManager; import org.chromium.chrome.browser.toolbar.ToolbarTabController; @@ -88,7 +91,6 @@ import org.chromium.chrome.browser.toolbar.top.ToolbarControlContainer; import org.chromium.chrome.browser.toolbar.top.ToolbarLayout; import org.chromium.chrome.browser.toolbar.top.ToolbarTablet.OfflineDownloader; -import org.chromium.chrome.browser.ui.TabObscuringHandler; import org.chromium.chrome.browser.ui.appmenu.AppMenuDelegate; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; import org.chromium.chrome.browser.ui.native_page.NativePageHost; @@ -285,6 +287,10 @@ public void testClassesExist() throws Exception { Assert.assertTrue( classExists("org/chromium/chrome/browser/omnibox/BraveLocationBarMediator")); Assert.assertTrue(classExists("org/chromium/chrome/browser/tasks/ReturnToChromeUtil")); + Assert.assertTrue(classExists("org/chromium/chrome/browser/IntentHandler")); + Assert.assertTrue(classExists("org/chromium/chrome/browser/BraveIntentHandler")); + Assert.assertTrue(classExists("org/chromium/chrome/browser/flags/CachedFlag")); + Assert.assertTrue(classExists("org/chromium/chrome/browser/flags/BraveCachedFlag")); } @Test @@ -423,6 +429,14 @@ public void testMethodsExist() throws Exception { "shouldShowDeleteButton", false, null)); Assert.assertTrue(methodExists("org/chromium/chrome/browser/tasks/ReturnToChromeUtil", "shouldShowTabSwitcher", true, boolean.class, long.class)); + Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler", + "getUrlForCustomTab", true, String.class, Intent.class)); + Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler", + "getUrlForWebapp", true, String.class, Intent.class)); + Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler", + "isJavascriptSchemeOrInvalidUrl", true, boolean.class, String.class)); + Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler", + "extractUrlFromIntent", true, String.class, Intent.class)); } @Test @@ -434,7 +448,7 @@ public void testMethodsForInvocationExist() throws Exception { Assert.assertTrue(methodExists( "org/chromium/chrome/browser/omnibox/suggestions/AutocompleteCoordinator", "createViewProvider", true, ViewProvider.class, Context.class, - MVCListAdapter.ModelList.class)); + MVCListAdapter.ModelList.class, LocationBarDataProvider.class)); // Check for method type declaration changes here Assert.assertTrue(methodExists( @@ -517,7 +531,8 @@ public void testConstructorsExistAndMatch() throws Exception { "org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator", "org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsMediator", WindowAndroid.class, PropertyModel.class, BrowserControlsSizer.class, - FullscreenManager.class, int.class, ObservableSupplier.class)); + FullscreenManager.class, TabObscuringHandler.class, int.class, + ObservableSupplier.class)); Assert.assertTrue(constructorsMatch( "org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl", "org/chromium/chrome/browser/app/appmenu/BraveAppMenuPropertiesDelegateImpl", @@ -571,11 +586,11 @@ public void testConstructorsExistAndMatch() throws Exception { List.class, OneshotSupplier.class, ThemeColorProvider.class, ThemeColorProvider.class, MenuButtonCoordinator.class, MenuButtonCoordinator.class, ObservableSupplier.class, ObservableSupplier.class, ObservableSupplier.class, - ObservableSupplier.class, Callback.class, Supplier.class, Supplier.class, + ButtonDataProvider.class, Callback.class, Supplier.class, Supplier.class, ObservableSupplier.class, BooleanSupplier.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, HistoryDelegate.class, - BooleanSupplier.class, OfflineDownloader.class, boolean.class, - ObservableSupplier.class, Callback.class, boolean.class, ObservableSupplier.class)); + BooleanSupplier.class, OfflineDownloader.class, boolean.class, Callback.class, + boolean.class, ObservableSupplier.class)); Assert.assertTrue(constructorsMatch( "org/chromium/chrome/browser/toolbar/menu_button/MenuButtonCoordinator", "org/chromium/chrome/browser/toolbar/menu_button/BraveMenuButtonCoordinator", @@ -661,6 +676,13 @@ public void testConstructorsExistAndMatch() throws Exception { BraveLocationBarMediator.getLensControllerClass(), Runnable.class, BraveLocationBarMediator.getSaveOfflineButtonStateClass(), BraveLocationBarMediator.getOmniboxUmaClass(), BooleanSupplier.class)); + Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/IntentHandler", + "org/chromium/chrome/browser/BraveIntentHandler", Activity.class, + IntentHandler.IntentHandlerDelegate.class)); + Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/AppHooksImpl", + "org/chromium/chrome/browser/BraveAppHooks")); + Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/flags/CachedFlag", + "org/chromium/chrome/browser/flags/BraveCachedFlag", String.class, boolean.class)); } @Test @@ -761,6 +783,8 @@ public void testFieldsExist() throws Exception { "org/chromium/chrome/browser/toolbar/ToolbarManager", "mTabCreatorManager")); Assert.assertTrue(fieldExists( "org/chromium/chrome/browser/toolbar/ToolbarManager", "mSnackbarManager")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mTabObscuringHandler")); Assert.assertTrue( fieldExists("org/chromium/chrome/browser/toolbar/top/TopToolbarCoordinator", "mTabSwitcherModeCoordinator")); diff --git a/app/brave_main_delegate_browsertest.cc b/app/brave_main_delegate_browsertest.cc index 8979b5251f95..a25303421af3 100644 --- a/app/brave_main_delegate_browsertest.cc +++ b/app/brave_main_delegate_browsertest.cc @@ -104,6 +104,7 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) { &blink::features::kSharedStorageAPI, &blink::features::kSpeculationRulesPrefetchProxy, &blink::features::kTextFragmentAnchor, + &commerce::kCommerceAllowOnDemandBookmarkUpdates, &commerce::kCommerceDeveloper, &commerce::kCommerceMerchantViewer, &commerce::kCommercePriceTracking, @@ -123,13 +124,14 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) { &features::kFirstPartySets, &features::kIdleDetection, &features::kIsolatePrerenders, + &features::kKAnonymityService, &features::kNavigationRequestPreconnect, &features::kNotificationTriggers, &features::kOmniboxTriggerForNoStatePrefetch, &features::kPrivacyGuide2, &features::kPrivacySandboxAdsAPIsOverride, &features::kSCTAuditing, - &features::kSignedExchangeSubresourcePrefetch, + &features::kSignedExchangeReportingForDistributors, &features::kSignedHTTPExchange, &features::kSubresourceWebBundles, #if !BUILDFLAG(IS_ANDROID) @@ -152,7 +154,6 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) { &optimization_guide::features::kRemoteOptimizationGuideFetching, &optimization_guide::features:: kRemoteOptimizationGuideFetchingAnonymousDataConsent, - &password_manager::features::kUnifiedPasswordManagerDesktop, #if !BUILDFLAG(IS_ANDROID) &permissions::features::kPermissionsPostPromptSurvey, &permissions::features::kRecordPermissionExpirationTimestamps, diff --git a/app/brave_strings.grd b/app/brave_strings.grd index 47059a884565..bcbbb02100bf 100644 --- a/app/brave_strings.grd +++ b/app/brave_strings.grd @@ -643,6 +643,11 @@ Permissions you've already given to websites and apps may apply to this account. Brave recommends scanning this file because it may be dangerous + + + Brave blocked this archive file because it may hide malware + + Adding to Brave... @@ -710,6 +715,9 @@ Permissions you've already given to websites and apps may apply to this account. + + Allow extension to show access requests in the Brave toolbar + Warning: Brave cannot prevent extensions from recording your browsing history. To disable this extension in Private mode, unselect this option. @@ -1546,6 +1554,12 @@ Permissions you've already given to websites and apps may apply to this account. Installation complete. + + + + As needed, Brave reclaims memory from tabs you aren't actively using. You can change this anytime in settings. + + diff --git a/app/brave_strings_override.grd b/app/brave_strings_override.grd index 05b28a5fb9ae..9915c203a17f 100644 --- a/app/brave_strings_override.grd +++ b/app/brave_strings_override.grd @@ -326,6 +326,8 @@ Permissions you've already given to websites and apps may apply to this account. + + diff --git a/app/generated_resources.grd b/app/generated_resources.grd index 66a0f4128fc3..7424986cc824 100644 --- a/app/generated_resources.grd +++ b/app/generated_resources.grd @@ -1468,6 +1468,9 @@ are declared in tools/grit/grit_rule.gni. &Extensions + + Performance + &Settings @@ -1506,6 +1509,9 @@ are declared in tools/grit/grit_rule.gni. &Extensions + + Performance + &Settings @@ -2526,6 +2532,11 @@ are declared in tools/grit/grit_rule.gni. + + + This file contains malware that can compromise your personal or social network accounts + + @@ -4028,19 +4039,19 @@ are declared in tools/grit/grit_rule.gni. - + Reload page to use this extension - + Reload - + Reload the page to use "$1Gmail Checker" - + Reload the page to use these extensions - + Reload the page to apply your changes @@ -4239,9 +4250,6 @@ are declared in tools/grit/grit_rule.gni. Read and change all your data on all websites - - Read and change all your data on the current website when invoked - Read all your data on all websites @@ -4736,10 +4744,10 @@ are declared in tools/grit/grit_rule.gni. Allow $13? - $1Extension A is requesting to read and change $2google.com + Click to allow "$1Extension A"" on $2google.com: - Requesting to read and change $1google.com: + Click to allow on $1google.com: Always allow "$1Gmail Checker" to run on $2google.com? @@ -4753,6 +4761,27 @@ are declared in tools/grit/grit_rule.gni. No thanks + + Allowed to read & change + + + Not allowed to read & change + + + Requested to read & change + + + All extensions can read & change $1google.com + + + You blocked all extensions from $1google.com + + + This extension can read & change $1google.com + + + Click this extension's icon to read & change $1google.com + @@ -5407,6 +5436,12 @@ Keep your key file in a safe place. You will need it to create new versions of y + + + From the app + + + Customize and control $1GMail @@ -5562,8 +5597,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Password saved - - Use suggested password + + + Weak password entered @@ -5589,6 +5625,18 @@ Keep your key file in a safe place. You will need it to create new versions of y Update password? + + Sign in to save passwords + + + Sign in to use passwords + + + Sign back in to Brave Password Manager + + + Sign in + Save password for $1example.com? @@ -5732,9 +5780,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Hide this plugin - - Update plugin - Control-click to run $1Flash @@ -5748,32 +5793,14 @@ Keep your key file in a safe place. You will need it to create new versions of y $1Flash is blocked by enterprise policy - - $1Flash is blocked - This plugin is not supported on this device - - $1Flash is out of date - $1Java needs your permission to run - - Downloading $1Realplayer... - - - There was an error ($1net::ERR_TOO_MANY_GOATS) while downloading the plugin - - - $1Realplayer download failed - - - When $1Realplayer finishes updating, reload the page to activate it - $1Flash disabled. @@ -6802,6 +6829,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Can't add current tab + + Mark current tab as read + Remove current tab @@ -6861,6 +6891,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Theme + + Letter spacing + @@ -7234,6 +7267,15 @@ Keep your key file in a safe place. You will need it to create new versions of y To create a highlight like this one, select any text and right-click. + + Battery Saver is on + + + You can control when Battery Saver turns on in settings + + + Settings + @@ -7290,15 +7332,9 @@ Keep your key file in a safe place. You will need it to create new versions of y =1 {You can wait for it to become responsive or exit the page.} other {You can wait for them to become responsive or exit the pages.}} - - The page has become unresponsive. You can wait for it to become responsive or close it. - $1google.com, in $2YouTube. - - Close - Wait @@ -7413,11 +7449,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Password updated - - {COUNT, plural, - =1 {Successfully changed the compromised password. You have # more compromised password. Brave recommends checking this password now.} - other {Successfully changed the compromised password. You have # more compromised passwords. Brave recommends checking these passwords now.}} - {COUNT, plural, =1 {Successfully changed the compromised password. @@ -7427,17 +7458,11 @@ You have # more compromised password. Brave Password Manager recommends checking You have # more compromised passwords. Brave Password Manager recommends checking these passwords now.}} - - Successfully changed the compromised password. Check your passwords anytime in $1Settings. - Successfully changed the compromised password. Check your passwords anytime in $1Brave Password Manager. - - Settings - @@ -7514,21 +7539,12 @@ Check your passwords anytime in $1Brave P Move your password to your Brave sync chain to access it securely wherever you're signed in - - Passwords not saved - Save passwords? - - Brave couldn't save these passwords in your Brave sync chain. You can still save them on this device. - Brave Password Manager couldn't save these passwords in your Brave sync chain. You can save them to this device. - - Save - @@ -8928,6 +8944,42 @@ Check your passwords anytime in $1Brave P Copy to Clipboard + + Screenshot Image Editor + + + Clear Canvas + + + Align left + + + Align center + + + Align right + + + No shadow + + + Small shadow + + + Large shadow + + + Default font + + + Monospace font + + + Italic font + + + Outline font + @@ -9500,9 +9552,6 @@ Check your passwords anytime in $1Brave P Turn on sync to get your bookmarks, passwords, history, and more on this device and anywhere else you're syncing. - - Manage sync - Turn on sync @@ -9640,12 +9689,6 @@ Check your passwords anytime in $1Brave P No, this device only - - $1Flash was blocked because it is out of date - - - Run this time - $1Flash has crashed @@ -10013,14 +10056,20 @@ Please help our engineers fix this problem. Tell us what happened right before y + + Waiting for translation + Translate this page? Translated + + This selection couldn't be translated + - This page could not be translated + This page couldn't be translated Choose the page language to translate from @@ -10044,6 +10093,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Page is not in $1French + + Selection is not in $1French + Translate @@ -10086,6 +10138,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Page language to translate + + Language to translate from + Translate full page @@ -10097,12 +10152,15 @@ Please help our engineers fix this problem. Tell us what happened right before y Change Languages... - + Choose Another Language... - + Page Is Not in $1French + + Selection Is Not in $1French + Translate @@ -10145,7 +10203,10 @@ Please help our engineers fix this problem. Tell us what happened right before y Page Language to Translate - + + Language to Translate from + + Translate Full Page @@ -11145,7 +11206,10 @@ Please help our engineers fix this problem. Tell us what happened right before y $1Compose with $2GMail App - + + $1Harry Potter - $2Brave Search + + $1Harry Potter, $2Brave Search @@ -11234,6 +11298,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Share tab audio + + Also share system audio. This device will be muted to prevent feedback. + Entire Screen @@ -11452,8 +11519,11 @@ Please help our engineers fix this problem. Tell us what happened right before y Entered window overview mode. Swipe to navigate, or press tab if using a keyboard. - - Viewing templates. Press tab to navigate. + + Viewing saved desks and templates. Press tab to navigate. + + + Viewing saved desks. Press tab to navigate. Entered full screen @@ -12980,7 +13050,7 @@ Please help our engineers fix this problem. Tell us what happened right before y - + Sign in to $1rp.example with $2idp.example @@ -12998,6 +13068,12 @@ Please help our engineers fix this problem. Tell us what happened right before y To continue, $1idp.com will share your name, email address, and profile picture with this site. See this site's $2privacy policy$3 and $4terms of service$5. + + Failed signing in to $1rp.example with $2idp.example + + + Sign in to $1rp.example + Verifying… @@ -13193,7 +13269,52 @@ Please help our engineers fix this problem. Tell us what happened right before y Check the site and try changing your password. + + Try again + + + Your password didn't change. To change it, try again and leave this tab and side panel open. $1Try again + + + Brave Assistant stopped + + + + + + Battery Saver is on + + + Battery Saver is on + + + Battery Saver is on + + + Background activity and some visual effects, like smooth scrolling, may be limited. + + + Turn off now + + + + + Memory Saver is on + + + Memory Saver is on + + + Memory Saver is on + + + + Location + + + Webview + diff --git a/app/generated_resources_override.grd b/app/generated_resources_override.grd index 4712611d8c1b..0d9b3ca47449 100644 --- a/app/generated_resources_override.grd +++ b/app/generated_resources_override.grd @@ -528,6 +528,9 @@ are declared in tools/grit/grit_rule.gni. + + + @@ -899,7 +902,7 @@ are declared in tools/grit/grit_rule.gni. - + @@ -1099,6 +1102,10 @@ are declared in tools/grit/grit_rule.gni. - + + + + + diff --git a/app/gmc_strings.grdp b/app/gmc_strings.grdp index 858265b26b2f..0bb9db1338b6 100644 --- a/app/gmc_strings.grdp +++ b/app/gmc_strings.grdp @@ -26,9 +26,12 @@ Downloading... $117% - + Can't download speech files. Try again later. + + Restart needed to install speech files. + Global Media Controls diff --git a/app/media_router_strings.grdp b/app/media_router_strings.grdp index 62ac9dc3e00a..1b373eb122a2 100644 --- a/app/media_router_strings.grdp +++ b/app/media_router_strings.grdp @@ -20,15 +20,9 @@ Cast tab - - Cast file - - - Cast $1my_media.mp3 - - + Sources @@ -50,24 +44,21 @@ - + Unable to cast $1youtube.com. + + + Unable to cast. - + Unable to cast screen. Check to see if you confirmed the prompt to start sharing your screen. - + Unable to cast tab. Unable to cast screen. - - Unable to cast file. - - - Unable to cast $1my_media.mp3. - Casting tab audio is not supported on this device. @@ -76,6 +67,19 @@ Unable to cast your screen. Check the Screen Recording permission in System Preferences. + + Accept Cast request on your $1. + + + Make sure to accept the Cast request on your $1. + + + Make sure notifications are turned on on your $1. + + + Failed to cast. Please try again. + + @@ -118,11 +122,6 @@ Presenting ($1example.com) - - - Audio/Video - - Optimize fullscreen casting? @@ -170,7 +169,7 @@ help center</a>. - Tell us what's happening with Brave Cast. + Tell us what's happening with Brave Cast. Your answer diff --git a/app/os_settings_search_tag_strings.grdp b/app/os_settings_search_tag_strings.grdp index f1593000661d..0ac29522b6e6 100644 --- a/app/os_settings_search_tag_strings.grdp +++ b/app/os_settings_search_tag_strings.grdp @@ -1189,10 +1189,10 @@ Low vision display tools - + High contrast mode - + Invert colors diff --git a/app/os_settings_strings.grdp b/app/os_settings_strings.grdp index 26f798acab2b..70f647e32fa4 100644 --- a/app/os_settings_strings.grdp +++ b/app/os_settings_strings.grdp @@ -571,6 +571,18 @@ Suggestions + + Input Assistance + + + User Dictionaries + + + Privacy + + + Section + Double-space to type period @@ -595,6 +607,9 @@ Show accent marks and special characters + + Press & hold keyboard keys to see accent marks and special characters + Keyboard layout @@ -616,6 +631,90 @@ Input a syllable at a time + + Input mode + + + Romaji + + + Kana + + + Punctuation Style + + + 、。 + + + ,. + + + 、. + + + ,。 + + + Symbol Style + + + 「」・ + + + []/ + + + 「」/ + + + []・ + + + Space Input Style + + + Follow input mode + + + Fullwidth + + + Halfwidth + + + Selection Shortcut + + + No shortcut + + + 1 -- 9 + + + A -- L + + + Keymap Style + + + Custom keymap + + + ATOK + + + MS-IME + + + Kotoeri + + + Mobile + + + ChromeOS + Initial punctuation width is Full @@ -899,6 +998,24 @@ Turn light screens dark, and dark screens light. Press Search + Ctrl + H to turn color inversion on and off. + + Greyscale + + + Sepia + + + Saturation + + + Hue rotation + + + Less + + + More + Sticky keys @@ -942,7 +1059,7 @@ Zoomed in screen follows keyboard focus - Fullscreen zoom level + Zoom level Use Ctrl + Alt + Brightness up to zoom in. @@ -1042,7 +1159,7 @@ Use Ctrl + Alt + Brightness down to zoom out. Send your voice to Brave to allow dictation into any text field. - Enable dictation (speak to type) + Dictation Type with your voice. Use Search + D, then start speaking. @@ -1668,6 +1785,15 @@ Press an assigned switch or key to remove assignment. "$1Nexus 5" is in use. Reassigning the device while it's in use could cause errors. Are you sure you want to continue? + + USB devices + + + Add USB device + + + No USB devices are attached. + @@ -1845,14 +1971,14 @@ Press an assigned switch or key to remove assignment. Image Alias - - Add playbook + + Create from an Ansible Playbook or a Crostini backup file - - Select playbook + + Select file - - Select an Ansible Playbook to add + + Select an Ansible Playbook or Crostini backup file Change @@ -2238,6 +2364,12 @@ Press an assigned switch or key to remove assignment. No devices saved to $1example@google.com + + Can’t load devices saved to $1example@google.com. Check your internet connection and try again. + + + Looking for Fast Pair devices saved to $1example@google.com + Device $11 of $215, $3Beats @@ -3216,16 +3348,13 @@ Press an assigned switch or key to remove assignment. Connecting to your phone - Set a PIN or password + Use a password or PIN to unlock your $1Chromebook - This PIN or password protects your data on this $1Chromebook, including any information you access from your phone - - - Choose either one each time you sign in + This password or PIN protects your data on this $1Chromebook and any information you access from your phone. You'll need to unlock each time your $1Chromebook wakes from sleep. - If Smart Lock is turned on, you won't need to enter a PIN or password + If Smart Lock is turned on and your phone is unlocked, you don't need to enter a password or PIN Make sure your phone is nearby, unlocked, and has Bluetooth and Wi-Fi turned on @@ -3358,8 +3487,8 @@ Press an assigned switch or key to remove assignment. Hide sensitive content - - Lock in sleep mode or when cover is closed + + Lock when sleeping or lid is closed Screen lock @@ -3668,14 +3797,14 @@ Press an assigned switch or key to remove assignment. Sign out - - Sleep when cover is closed + + Sleep when lid is closed - - Sign out when cover is closed + + Sign out when lid is closed - - Shut down when cover is closed + + Shut down when lid is closed $156% - $22 hours and 20 minutes left @@ -4333,7 +4462,7 @@ Press an assigned switch or key to remove assignment. If you move away from your device, your screen will lock automatically. When you're in front of your device, your screen will stay awake longer. If you aren't using a lock screen, your device will sleep instead of lock. - Viewing protection + Viewing protection (Beta) When someone else looks at your screen, show the Privacy eye icon on the bottom right of your screen @@ -4356,6 +4485,12 @@ Press an assigned switch or key to remove assignment. All microphones disabled by devices hardware switch + + No microphone connected + + + Geolocation + $1ChromeOS Flex hardware support and stability diff --git a/app/password_manager_ui_strings.grdp b/app/password_manager_ui_strings.grdp index e642c99f0081..065a00b76b33 100644 --- a/app/password_manager_ui_strings.grdp +++ b/app/password_manager_ui_strings.grdp @@ -4,4 +4,49 @@ Password Manager + + Search passwords + + + Checkup + + + Passwords + + + Settings + + + Offer to save passwords + + + Sign in automatically + + + Easily sign in to sites and apps with your saved passwords. When turned off, you’ll be asked before signing in. + + + Create, save, and manage your passwords so you can easily sign in to sites and apps. ‎<a target='_blank' href='$1'>Learn more</a> + + + Add + + + Set up on-device encryption + + + For added safety, you can encrypt passwords on your device before they're saved to your Brave sync chain + + + Import passwords + + + Add saved passwords to Brave Password Manager + + + Export passwords + + + Download a copy to use elsewhere + diff --git a/app/profiles_strings.grdp b/app/profiles_strings.grdp index b11b815c14bd..ecbfbbed868c 100644 --- a/app/profiles_strings.grdp +++ b/app/profiles_strings.grdp @@ -502,27 +502,51 @@ Rename your profile + + Add a name or label, like Work or Personal + + + Enter a profile name + Skip + + Delete profile + Welcome! + + Back from avatar selection page + - + Welcome to your new profile This account is managed by $1example.com - + + This profile is managed by $1example.com and requires you to create a separate profile for the account $2john.doe@example.com + + + This profile is managed by $1example.com. A new profile is required for account $2john.doe@example.com by $3example2.com + + + This device is managed. A new profile is required for account $1john.doe@example.com by your device administrator + + + This device is managed by $1example.com. A new profile is required for account $2john.doe@example.com by $1example.com + + This account ($1john.doe@example.com) is managed by $2example.com - + Your device is managed by $1example.com - + Your device is managed by your organization @@ -531,10 +555,10 @@ You’re adding a managed profile to this browser. Your administrator has control over the profile and can access its data. - + Your organization requires a profile - + Your organization will manage this profile diff --git a/app/settings_brave_strings.grdp b/app/settings_brave_strings.grdp index 758a9b60f48a..37edcd20aafb 100644 --- a/app/settings_brave_strings.grdp +++ b/app/settings_brave_strings.grdp @@ -277,6 +277,11 @@ Brave Assistant in Brave can complete actions across websites for you + + + When on, Brave reclaims memory from tabs you aren't actively using. This frees up your computer's resources for other tasks and keeps Brave speedy. Inactive tabs appear empty and automatically reload when you click them. <a id="highEfficiencyLearnMore" target="_blank" href="$1">Learn more</a> or <a id="highEfficiencySendFeedback" href="#">send feedback</a> + + diff --git a/app/settings_strings.grdp b/app/settings_strings.grdp index 0f231a937f2d..11a938aaee6e 100644 --- a/app/settings_strings.grdp +++ b/app/settings_strings.grdp @@ -90,9 +90,12 @@ Speech files downloaded - + Can't download speech files. Try again later. + + Restart needed to install speech files. + Navigate pages with a text cursor @@ -136,11 +139,17 @@ - - GTK+ + + GTK + + + Use GTK + + + QT - - Use GTK+ + + Use QT Classic @@ -419,9 +428,6 @@ Never - - Passwords - Password Manager @@ -656,6 +662,17 @@ Notes can save up to $11000 characters. + + Brave Password Manager timed out + + + {NUM_MINS, plural, + =1 {To keep your passwords safe, Brave Password Manager locks after 1 minute of inactivity} + other {To keep your passwords safe, Brave Password Manager locks after {NUM_MINS} minutes of inactivity}} + + + Got it + Saved addresses will appear here @@ -665,6 +682,9 @@ Saved passwords will appear here + + Saved passwords will appear here. <a href="#" > Import passwords</a> + Sites which never save passwords will appear here @@ -757,9 +777,6 @@ See and manage passwords saved on this device - - View and manage saved passwords in your <a is="action-link" href="$1" target="_blank">Brave sync chain</a> - View and manage saved passwords in your Brave sync chain @@ -782,7 +799,7 @@ Import passwords - Choose file + Select file To import passwords, select a CSV file @@ -807,13 +824,16 @@ Select where to import your passwords - Consider deleting file_name.csv$1, so others who use this device can't see your passwords. + Consider deleting <b></b><b>filename.csv</b>, so others who use this device can't see your passwords Something went wrong and your passwords weren't imported - Can't import passwords. Check file_name.csv$1 and make sure it's formatted correctly. + Can't import passwords. Check <b></b><b>filename.csv</b> and make sure it's formatted correctly. <a href="$1" target="_blank">Learn more</a> + + + Can't import passwords. The file size should be less than 150 KB. Can't import passwords. You can only import up to 3000$1 passwords at a time. @@ -827,6 +847,17 @@ URL format should be https://www.example.com + + URL can only contain ASCII characters + + + {NUM_PASSWORDS, plural, + =1 {1 other password wasn't imported because it's formatted incorrectly} + other {{NUM_PASSWORDS} other passwords weren't imported because they're formatted incorrectly}} + + + URL is more than 2048 characters + Username is more than 1000 characters @@ -846,7 +877,7 @@ You're already importing passwords in another tab - Export passwords... + Export passwords Export passwords @@ -855,7 +886,7 @@ Your passwords will be visible to anyone who can see the exported file. - Export passwords... + Export passwords Try again @@ -894,7 +925,7 @@ Your passwords are encrypted on your device before they‘re saved to Brave Password Manager - + Manage passkeys @@ -925,6 +956,18 @@ Hide password for $1example@gmail.com on $2www.google.com + + + Use TouchID when filling passwords + + + + + + Use Windows Hello when filling passwords + + + @@ -1347,6 +1390,14 @@ Please enter a shorter URL + + + Performance + + + Memory Saver + + Languages @@ -1949,6 +2000,26 @@ Review extensions + + Review websites that sent a lot of notifications + + + These sites sent a lot of notifications in the last 2 months. You can stop them from sending future notifications. + + + {NUM_NOTIFICATION, plural, + =1 {About 1 notification a day} + other {About {NUM_NOTIFICATION} notifications a day}} + + + Don't allow + + + Always allow notifications from this site + + + Don’t allow but ask later + Device software @@ -2960,6 +3031,12 @@ Features on many sites may not work + + Allow related sites to remember you across sites + + + Related sites use cookies to help with things like keeping you signed in + Clear cookies and site data when you close all windows @@ -3286,6 +3363,16 @@ Clear displayed data + + {MEMBERS, plural, + =1 {Allowed for 1 $1google.com site} + other {Allowed for {MEMBERS} {FPS_OWNER}google.com sites}} + + + Show related sites + + + Clear data and permissions This will clear $18 GB of data stored by sites diff --git a/app/settings_strings_override.grdp b/app/settings_strings_override.grdp index a83bb37d4712..dc53ee27ebfe 100644 --- a/app/settings_strings_override.grdp +++ b/app/settings_strings_override.grdp @@ -50,9 +50,15 @@ - + + + + + + + diff --git a/app/supervised_user_error_page_strings.grdp b/app/supervised_user_error_page_strings.grdp index 48ed6446572b..6eb68edad5c2 100644 --- a/app/supervised_user_error_page_strings.grdp +++ b/app/supervised_user_error_page_strings.grdp @@ -35,6 +35,9 @@ Ask in profile + + Ask in profile instead + Send a message @@ -77,6 +80,9 @@ Hide details + + This site is blocked + This site is blocked because it may have mature content diff --git a/app/supervised_user_error_page_strings_override.grdp b/app/supervised_user_error_page_strings_override.grdp index 64be6b4c53a7..ef668480114b 100644 --- a/app/supervised_user_error_page_strings_override.grdp +++ b/app/supervised_user_error_page_strings_override.grdp @@ -6,4 +6,7 @@ Ask in profile + + Ask in profile instead + diff --git a/app/welcome_strings.grdp b/app/welcome_strings.grdp index 865381be6d69..613a453dbd39 100644 --- a/app/welcome_strings.grdp +++ b/app/welcome_strings.grdp @@ -108,6 +108,12 @@ Already a Brave user? Sign in + + Pause animations + + + Play animations + diff --git a/brave_paks.gni b/brave_paks.gni index 566ec2a8378a..ab484772db40 100644 --- a/brave_paks.gni +++ b/brave_paks.gni @@ -55,7 +55,6 @@ template("brave_extra_paks") { sources = [ "$root_gen_dir/brave/components/brave_ads/resources/brave_ads_resources.pak", "$root_gen_dir/brave/components/brave_rewards/resources/brave_rewards_resources.pak", - "$root_gen_dir/brave/ui/webui/resources/brave_webui_resources.pak", "$root_gen_dir/components/brave_components_resources.pak", ] @@ -63,9 +62,7 @@ template("brave_extra_paks") { sources += [ "$root_gen_dir/brave/brave_generated_resources.pak", "$root_gen_dir/brave/brave_unscaled_resources.pak", - "$root_gen_dir/brave/browser/resources/bookmarks/brave_bookmarks_resources.pak", "$root_gen_dir/brave/browser/resources/federated_internals/federated_internals_resources.pak", - "$root_gen_dir/brave/browser/resources/history/brave_history_resources.pak", "$root_gen_dir/brave/browser/resources/settings/brave_settings_resources.pak", ] } @@ -74,16 +71,13 @@ template("brave_extra_paks") { "//brave/components/brave_ads/resources", "//brave/components/brave_rewards/resources", "//brave/components/resources", - "//brave/ui/webui/resources", ] if (!is_android) { deps += [ "//brave/app:brave_generated_resources_grit", "//brave/app/theme:brave_unscaled_resources", - "//brave/browser/resources/bookmarks:resources", "//brave/browser/resources/federated_internals:resources", - "//brave/browser/resources/history:resources", "//brave/browser/resources/settings:resources", "//brave/components/resources:strings", ] @@ -103,13 +97,9 @@ template("brave_extra_paks") { } if (enable_extensions) { - sources += [ - "$root_gen_dir/brave/browser/resources/extensions/brave_extensions_resources.pak", - "$root_gen_dir/brave/components/brave_extension/brave_extension_resources.pak", - ] + sources += [ "$root_gen_dir/brave/components/brave_extension/brave_extension_resources.pak" ] deps += [ - "//brave/browser/resources/extensions:resources", "//brave/common/extensions/api", "//brave/components/brave_extension:resources", ] diff --git a/browser/DEPS b/browser/DEPS index d83c2099d055..234d36a0ed87 100644 --- a/browser/DEPS +++ b/browser/DEPS @@ -59,6 +59,7 @@ include_rules = [ "+services/proxy_resolver/public/mojom", "+services/resource_coordinator/public/cpp", "+services/resource_coordinator/public/mojom", + "+services/service_manager/public/cpp", "+services/strings", "+third_party/boringssl/src/include", "+third_party/crashpad", diff --git a/browser/brave_content_browser_client.cc b/browser/brave_content_browser_client.cc index 73c5b5953e9f..6a8c3f04ef0c 100644 --- a/browser/brave_content_browser_client.cc +++ b/browser/brave_content_browser_client.cc @@ -109,6 +109,7 @@ #include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/cookies/site_for_cookies.h" +#include "services/service_manager/public/cpp/binder_registry.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/loader/url_loader_throttle.h" #include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h" diff --git a/browser/brave_prefs_browsertest.cc b/browser/brave_prefs_browsertest.cc index 4e93fdc1da30..23c6de053b54 100644 --- a/browser/brave_prefs_browsertest.cc +++ b/browser/brave_prefs_browsertest.cc @@ -145,8 +145,6 @@ IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest, MiscBravePrefs) { #endif #if BUILDFLAG(ENABLE_CUSTOM_BACKGROUND) - EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetDictionary( - NTPBackgroundPrefs::kPrefName)); EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->HasPrefPath( NTPBackgroundPrefs::kDeprecatedPrefName)); #endif diff --git a/browser/brave_shields/brave_shields_web_contents_observer.cc b/browser/brave_shields/brave_shields_web_contents_observer.cc index 742e4a351066..a44cc9bf841c 100644 --- a/browser/brave_shields/brave_shields_web_contents_observer.cc +++ b/browser/brave_shields/brave_shields_web_contents_observer.cc @@ -214,22 +214,16 @@ void BraveShieldsWebContentsObserver::ReadyToCommitNavigation( } navigation_handle->GetWebContents()->ForEachRenderFrameHost( - base::BindRepeating( - [](BraveShieldsWebContentsObserver* observer, - content::RenderFrameHost* rfh) { - observer->GetBraveShieldsRemote(rfh) - ->SetAllowScriptsFromOriginsOnce( - observer->allowed_script_origins_); - if (content::BrowserContext* context = rfh->GetBrowserContext()) { - if (PrefService* pref_service = - user_prefs::UserPrefs::Get(context)) { - observer->GetBraveShieldsRemote(rfh)->SetReduceLanguageEnabled( - brave_shields::IsReduceLanguageEnabledForProfile( - pref_service)); - } - } - }, - base::Unretained(this))); + [this](content::RenderFrameHost* rfh) { + GetBraveShieldsRemote(rfh)->SetAllowScriptsFromOriginsOnce( + allowed_script_origins_); + if (content::BrowserContext* context = rfh->GetBrowserContext()) { + if (PrefService* pref_service = user_prefs::UserPrefs::Get(context)) { + GetBraveShieldsRemote(rfh)->SetReduceLanguageEnabled( + brave_shields::IsReduceLanguageEnabledForProfile(pref_service)); + } + } + }); } void BraveShieldsWebContentsObserver::AllowScriptsOnce( diff --git a/browser/brave_wallet/brave_wallet_prefs_unittest.cc b/browser/brave_wallet/brave_wallet_prefs_unittest.cc index 49ca9801165f..48f92d1e6b7c 100644 --- a/browser/brave_wallet/brave_wallet_prefs_unittest.cc +++ b/browser/brave_wallet/brave_wallet_prefs_unittest.cc @@ -183,18 +183,18 @@ TEST_F(BraveWalletPrefsUnitTest, } MigrateObsoleteProfilePrefs(GetPrefs()); - const base::Value* dict = GetPrefs()->GetDictionary(kBraveWalletTransactions); - const base::Value* tx1_value = dict->FindDictPath("ethereum.mainnet.meta1"); - const base::Value* tx2_value = dict->FindDictPath("ethereum.mainnet.meta2"); - const base::Value* tx3_value = dict->FindDictPath("ethereum.ropsten.meta3"); + const auto& dict = GetPrefs()->GetDict(kBraveWalletTransactions); + const auto* tx1_value = dict.FindDictByDottedPath("ethereum.mainnet.meta1"); + const auto* tx2_value = dict.FindDictByDottedPath("ethereum.mainnet.meta2"); + const auto* tx3_value = dict.FindDictByDottedPath("ethereum.ropsten.meta3"); ASSERT_TRUE(tx1_value && tx2_value && tx3_value); EXPECT_EQ(*tx1_value, tx1); EXPECT_EQ(*tx2_value, tx2); EXPECT_EQ(*tx3_value, tx1); - EXPECT_EQ(dict->DictSize(), 1u); - EXPECT_EQ(dict->FindDictKey("ethereum")->DictSize(), 2u); - EXPECT_EQ(dict->FindDictPath("ethereum.mainnet")->DictSize(), 2u); - EXPECT_EQ(dict->FindDictPath("ethereum.ropsten")->DictSize(), 1u); + EXPECT_EQ(dict.size(), 1u); + EXPECT_EQ(dict.FindDict("ethereum")->size(), 2u); + EXPECT_EQ(dict.FindDictByDottedPath("ethereum.mainnet")->size(), 2u); + EXPECT_EQ(dict.FindDictByDottedPath("ethereum.ropsten")->size(), 1u); EXPECT_TRUE( GetPrefs()->GetBoolean(kBraveWalletEthereumTransactionsCoinTypeMigrated)); @@ -208,7 +208,7 @@ TEST_F(BraveWalletPrefsUnitTest, update_dict->RemovePath("mainnet"); } EXPECT_TRUE(pref && !pref->IsDefaultValue()); - EXPECT_TRUE(GetPrefs()->GetDictionary(kBraveWalletTransactions)->DictEmpty()); + EXPECT_TRUE(GetPrefs()->GetDict(kBraveWalletTransactions).empty()); MigrateObsoleteProfilePrefs(GetPrefs()); EXPECT_TRUE(pref && pref->IsDefaultValue()); diff --git a/browser/brave_wallet/brave_wallet_service_unittest.cc b/browser/brave_wallet/brave_wallet_service_unittest.cc index 7208321575c4..95f7ea9afeb3 100644 --- a/browser/brave_wallet/brave_wallet_service_unittest.cc +++ b/browser/brave_wallet/brave_wallet_service_unittest.cc @@ -144,13 +144,13 @@ void GetErrorCodeMessage(base::Value formed_response, error_message->clear(); return; } - const base::Value* code = formed_response.FindKey("code"); + auto code = formed_response.GetDict().FindInt("code"); if (code) { - *error = static_cast(code->GetInt()); + *error = static_cast(*code); } - const base::Value* message = formed_response.FindKey("message"); + const std::string* message = formed_response.GetDict().FindString("message"); if (message) { - *error_message = message->GetString(); + *error_message = *message; } } @@ -1243,8 +1243,9 @@ TEST_F(BraveWalletServiceUnitTest, NetworkListChangedEvent) { observer_->Reset(); { DictionaryPrefUpdate update(GetPrefs(), kBraveWalletCustomNetworks); - base::Value* list = update.Get()->FindKey(kEthereumPrefKey); - list->EraseListValueIf([&](const base::Value& v) { + base::Value::List* list = + update.Get()->GetDict().FindList(kEthereumPrefKey); + list->EraseIf([&](const base::Value& v) { auto* chain_id_value = v.FindStringKey("chainId"); if (!chain_id_value) return false; @@ -1453,10 +1454,8 @@ TEST_F(BraveWalletServiceUnitTest, MigrateUserAssetEthContractAddress) { user_assets_pref->Set("goerli", std::move(user_assets_list)); } - const base::Value* pref = - GetPrefs()->GetDictionary(kBraveWalletUserAssetsDeprecated); - ASSERT_TRUE(pref); - const auto* user_assets_list = pref->GetDict().FindList("goerli"); + const auto& pref = GetPrefs()->GetDict(kBraveWalletUserAssetsDeprecated); + const auto* user_assets_list = pref.FindList("goerli"); ASSERT_TRUE(user_assets_list); ASSERT_EQ(user_assets_list->size(), 1u); EXPECT_EQ(*(*user_assets_list)[0].GetDict().FindString("contract_address"), @@ -1518,11 +1517,9 @@ TEST_F(BraveWalletServiceUnitTest, MigrateMultichainUserAssets) { ASSERT_TRUE(GetPrefs()->HasPrefPath(kBraveWalletUserAssetsDeprecated)); BraveWalletService::MigrateMultichainUserAssets(GetPrefs()); - const auto* assets = - GetPrefs()->GetDictionary(kBraveWalletUserAssets)->GetIfDict(); - ASSERT_TRUE(assets); + const auto& assets = GetPrefs()->GetDict(kBraveWalletUserAssets); const auto* ethereum_mainnet_list = - assets->FindListByDottedPath("ethereum.mainnet"); + assets.FindListByDottedPath("ethereum.mainnet"); ASSERT_TRUE(ethereum_mainnet_list); ASSERT_EQ(ethereum_mainnet_list->size(), 2u); EXPECT_FALSE( @@ -1533,18 +1530,18 @@ TEST_F(BraveWalletServiceUnitTest, MigrateMultichainUserAssets) { EXPECT_EQ(*(*ethereum_mainnet_list)[1].GetDict().FindString("address"), "0x0D8775F648430679A709E98d2b0Cb6250d2887EF"); const auto* ethereum_rinkbey_list = - assets->FindListByDottedPath("ethereum.rinkbey"); + assets.FindListByDottedPath("ethereum.rinkbey"); ASSERT_TRUE(ethereum_rinkbey_list); ASSERT_EQ(ethereum_rinkbey_list->size(), 1u); EXPECT_FALSE( (*ethereum_rinkbey_list)[0].GetDict().FindString("contract_address")); EXPECT_EQ(*(*ethereum_rinkbey_list)[0].GetDict().FindString("address"), ""); - const auto* solana_dict = assets->FindDict("solana"); + const auto* solana_dict = assets.FindDict("solana"); ASSERT_TRUE(solana_dict); EXPECT_EQ(*solana_dict, BraveWalletService::GetDefaultSolanaAssets()); - const auto* filecoin_dict = assets->FindDict("filecoin"); + const auto* filecoin_dict = assets.FindDict("filecoin"); ASSERT_TRUE(filecoin_dict); EXPECT_EQ(*filecoin_dict, BraveWalletService::GetDefaultFilecoinAssets()); diff --git a/browser/brave_wallet/ethereum_provider_impl_unittest.cc b/browser/brave_wallet/ethereum_provider_impl_unittest.cc index 73b500637039..b1365a85646c 100644 --- a/browser/brave_wallet/ethereum_provider_impl_unittest.cc +++ b/browser/brave_wallet/ethereum_provider_impl_unittest.cc @@ -80,13 +80,13 @@ void GetErrorCodeMessage(base::Value formed_response, error_message->clear(); return; } - const base::Value* code = formed_response.FindKey("code"); + auto code = formed_response.GetDict().FindInt("code"); if (code) { - *error = static_cast(code->GetInt()); + *error = static_cast(*code); } - const base::Value* message = formed_response.FindKey("message"); + const std::string* message = formed_response.GetDict().FindString("message"); if (message) { - *error_message = message->GetString(); + *error_message = *message; } } diff --git a/browser/brave_wallet/keyring_service_unittest.cc b/browser/brave_wallet/keyring_service_unittest.cc index 5c5dfca4ff87..7fa52c2110cf 100644 --- a/browser/brave_wallet/keyring_service_unittest.cc +++ b/browser/brave_wallet/keyring_service_unittest.cc @@ -64,20 +64,18 @@ const char kMnemonic2[] = "misery jeans response tiny nominee civil zoo strong correct taxi chimney " "goat"; -base::Value GetHardwareKeyringValueForTesting() { - base::DictionaryValue dict; - dict.SetPath("hardware.A1.account_metas.0x111.account_name", - base::Value("test1")); - dict.SetPath("hardware.A1.account_metas.0x111.derivation_path", - base::Value("path1")); - dict.SetPath("hardware.A1.account_metas.0x111.hardware_vendor", - base::Value("vendor1")); - dict.SetPath("hardware.B2.account_metas.0x222.account_name", - base::Value("test2")); - dict.SetPath("hardware.B2.account_metas.0x222.derivation_path", - base::Value("path2")); - dict.SetPath("hardware.B2.account_metas.0x222.hardware_vendor", - base::Value("vendor2")); +base::Value::Dict GetHardwareKeyringValueForTesting() { + base::Value::Dict dict; + dict.SetByDottedPath("hardware.A1.account_metas.0x111.account_name", "test1"); + dict.SetByDottedPath("hardware.A1.account_metas.0x111.derivation_path", + "path1"); + dict.SetByDottedPath("hardware.A1.account_metas.0x111.hardware_vendor", + "vendor1"); + dict.SetByDottedPath("hardware.B2.account_metas.0x222.account_name", "test2"); + dict.SetByDottedPath("hardware.B2.account_metas.0x222.derivation_path", + "path2"); + dict.SetByDottedPath("hardware.B2.account_metas.0x222.hardware_vendor", + "vendor2"); return dict; } @@ -195,13 +193,13 @@ class KeyringServiceUnitTest : public testing::Test { } bool HasPrefForKeyring(const std::string& key, const std::string& id) { - return KeyringService::HasPrefForKeyring(GetPrefs(), key, id); + return KeyringService::HasPrefForKeyring(*GetPrefs(), key, id); } std::string GetStringPrefForKeyring(const std::string& key, const std::string& id) { const base::Value* value = - KeyringService::GetPrefForKeyring(GetPrefs(), key, id); + KeyringService::GetPrefForKeyring(*GetPrefs(), key, id); if (!value) return std::string(); @@ -658,24 +656,24 @@ class KeyringServiceUnitTest : public testing::Test { }; // namespace brave_wallet TEST_F(KeyringServiceUnitTest, HasAndGetPrefForKeyring) { - base::DictionaryValue dict; - dict.SetPath("default.pref1", base::Value("123")); - GetPrefs()->Set(kBraveWalletKeyrings, dict); - EXPECT_TRUE(KeyringService::HasPrefForKeyring(GetPrefs(), "pref1", + base::Value::Dict dict; + dict.SetByDottedPath("default.pref1", base::Value("123")); + GetPrefs()->SetDict(kBraveWalletKeyrings, std::move(dict)); + EXPECT_TRUE(KeyringService::HasPrefForKeyring(*GetPrefs(), "pref1", mojom::kDefaultKeyringId)); const base::Value* value = KeyringService::GetPrefForKeyring( - GetPrefs(), "pref1", mojom::kDefaultKeyringId); + *GetPrefs(), "pref1", mojom::kDefaultKeyringId); ASSERT_NE(value, nullptr); EXPECT_EQ(value->GetString(), "123"); EXPECT_FALSE( - KeyringService::HasPrefForKeyring(GetPrefs(), "pref1", "keyring2")); - EXPECT_EQ(KeyringService::GetPrefForKeyring(GetPrefs(), "pref1", "keyring2"), + KeyringService::HasPrefForKeyring(*GetPrefs(), "pref1", "keyring2")); + EXPECT_EQ(KeyringService::GetPrefForKeyring(*GetPrefs(), "pref1", "keyring2"), nullptr); - EXPECT_FALSE(KeyringService::HasPrefForKeyring(GetPrefs(), "pref2", + EXPECT_FALSE(KeyringService::HasPrefForKeyring(*GetPrefs(), "pref2", mojom::kDefaultKeyringId)); - EXPECT_EQ(KeyringService::GetPrefForKeyring(GetPrefs(), "pref2", + EXPECT_EQ(KeyringService::GetPrefForKeyring(*GetPrefs(), "pref2", mojom::kDefaultKeyringId), nullptr); } @@ -683,15 +681,14 @@ TEST_F(KeyringServiceUnitTest, HasAndGetPrefForKeyring) { TEST_F(KeyringServiceUnitTest, SetPrefForKeyring) { KeyringService::SetPrefForKeyring(GetPrefs(), "pref1", base::Value("123"), mojom::kDefaultKeyringId); - const base::Value* keyrings_pref = - GetPrefs()->GetDictionary(kBraveWalletKeyrings); - ASSERT_NE(keyrings_pref, nullptr); - const base::Value* value = keyrings_pref->FindPath("default.pref1"); + const auto& keyrings_pref = GetPrefs()->GetDict(kBraveWalletKeyrings); + const std::string* value = + keyrings_pref.FindStringByDottedPath("default.pref1"); ASSERT_NE(value, nullptr); - EXPECT_EQ(value->GetString(), "123"); + EXPECT_EQ(*value, "123"); - EXPECT_EQ(keyrings_pref->FindPath("default.pref2"), nullptr); - EXPECT_EQ(keyrings_pref->FindPath("keyring2.pref1"), nullptr); + EXPECT_EQ(keyrings_pref.FindByDottedPath("default.pref2"), nullptr); + EXPECT_EQ(keyrings_pref.FindByDottedPath("keyring2.pref1"), nullptr); } TEST_F(KeyringServiceUnitTest, GetAvailableKeyringsFromPrefs) { @@ -729,7 +726,7 @@ TEST_F(KeyringServiceUnitTest, GetPrefInBytesForKeyring) { }; auto mnemonic = KeyringService::GetPrefInBytesForKeyring( - GetPrefs(), kEncryptedMnemonic, mojom::kDefaultKeyringId); + *GetPrefs(), kEncryptedMnemonic, mojom::kDefaultKeyringId); ASSERT_TRUE(mnemonic); verify_bytes(*mnemonic); @@ -738,22 +735,22 @@ TEST_F(KeyringServiceUnitTest, GetPrefInBytesForKeyring) { base::Value("3q2+7w^^"), mojom::kDefaultKeyringId); EXPECT_FALSE(KeyringService::GetPrefInBytesForKeyring( - GetPrefs(), kEncryptedMnemonic, mojom::kDefaultKeyringId)); + *GetPrefs(), kEncryptedMnemonic, mojom::kDefaultKeyringId)); // default pref value (empty) GetPrefs()->ClearPref(kBraveWalletKeyrings); EXPECT_FALSE(KeyringService::GetPrefInBytesForKeyring( - GetPrefs(), kEncryptedMnemonic, mojom::kDefaultKeyringId)); + *GetPrefs(), kEncryptedMnemonic, mojom::kDefaultKeyringId)); // non-existing pref EXPECT_FALSE(KeyringService::GetPrefInBytesForKeyring( - GetPrefs(), "brave.nothinghere", mojom::kDefaultKeyringId)); + *GetPrefs(), "brave.nothinghere", mojom::kDefaultKeyringId)); // non-string pref KeyringService::SetPrefForKeyring(GetPrefs(), "test_num", base::Value(123), mojom::kDefaultKeyringId); EXPECT_FALSE(KeyringService::GetPrefInBytesForKeyring( - GetPrefs(), "test_num", mojom::kDefaultKeyringId)); + *GetPrefs(), "test_num", mojom::kDefaultKeyringId)); } TEST_F(KeyringServiceUnitTest, SetPrefInBytesForKeyring) { @@ -1436,7 +1433,7 @@ TEST_F(KeyringServiceUnitTest, AccountMetasForKeyring) { address2, mojom::kDefaultKeyringId); const base::Value* account_metas = KeyringService::GetPrefForKeyring( - GetPrefs(), kAccountMetas, mojom::kDefaultKeyringId); + *GetPrefs(), kAccountMetas, mojom::kDefaultKeyringId); ASSERT_NE(account_metas, nullptr); EXPECT_EQ( @@ -1445,17 +1442,17 @@ TEST_F(KeyringServiceUnitTest, AccountMetasForKeyring) { EXPECT_EQ( account_metas->FindPath(account_path2 + ".account_name")->GetString(), name2); - EXPECT_EQ(KeyringService::GetAccountNameForKeyring(GetPrefs(), account_path1, + EXPECT_EQ(KeyringService::GetAccountNameForKeyring(*GetPrefs(), account_path1, mojom::kDefaultKeyringId), name1); EXPECT_EQ(KeyringService::GetAccountAddressForKeyring( - GetPrefs(), account_path1, mojom::kDefaultKeyringId), + *GetPrefs(), account_path1, mojom::kDefaultKeyringId), address1); - EXPECT_EQ(KeyringService::GetAccountNameForKeyring(GetPrefs(), account_path2, + EXPECT_EQ(KeyringService::GetAccountNameForKeyring(*GetPrefs(), account_path2, mojom::kDefaultKeyringId), name2); EXPECT_EQ(KeyringService::GetAccountAddressForKeyring( - GetPrefs(), account_path2, mojom::kDefaultKeyringId), + *GetPrefs(), account_path2, mojom::kDefaultKeyringId), address2); EXPECT_EQ(service.GetAccountMetasNumberForKeyring(mojom::kDefaultKeyringId), 2u); @@ -1626,41 +1623,44 @@ TEST_F(KeyringServiceUnitTest, GetAccountPathByIndex) { } TEST_F(KeyringServiceUnitTest, MigrationPrefs) { - GetPrefs()->Set(kBraveWalletKeyrings, GetHardwareKeyringValueForTesting()); - EXPECT_EQ( - *GetPrefs() - ->Get(kBraveWalletKeyrings) - ->FindStringPath("hardware.A1.account_metas.0x111.account_name"), - "test1"); + GetPrefs()->SetDict(kBraveWalletKeyrings, + GetHardwareKeyringValueForTesting()); + EXPECT_EQ(*GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindStringByDottedPath( + "hardware.A1.account_metas.0x111.account_name"), + "test1"); KeyringService::MigrateObsoleteProfilePrefs(GetPrefs()); - const base::Value* hardware_accounts = KeyringService::GetPrefForKeyring( - GetPrefs(), kHardwareAccounts, mojom::kDefaultKeyringId); - EXPECT_EQ(hardware_accounts->DictSize(), 2u); - EXPECT_EQ( - *hardware_accounts->FindStringPath("A1.account_metas.0x111.account_name"), - "test1"); - EXPECT_EQ(*hardware_accounts->FindStringPath( + const base::Value::Dict& hardware_accounts = + KeyringService::GetPrefForKeyring(*GetPrefs(), kHardwareAccounts, + mojom::kDefaultKeyringId) + ->GetDict(); + EXPECT_EQ(hardware_accounts.size(), 2u); + EXPECT_EQ(*hardware_accounts.FindStringByDottedPath( + "A1.account_metas.0x111.account_name"), + "test1"); + EXPECT_EQ(*hardware_accounts.FindStringByDottedPath( "A1.account_metas.0x111.derivation_path"), "path1"); - EXPECT_EQ(*hardware_accounts->FindStringPath( + EXPECT_EQ(*hardware_accounts.FindStringByDottedPath( "A1.account_metas.0x111.hardware_vendor"), "vendor1"); - EXPECT_EQ( - *hardware_accounts->FindStringPath("B2.account_metas.0x222.account_name"), - "test2"); - EXPECT_EQ(*hardware_accounts->FindStringPath( + EXPECT_EQ(*hardware_accounts.FindStringByDottedPath( + "B2.account_metas.0x222.account_name"), + "test2"); + EXPECT_EQ(*hardware_accounts.FindStringByDottedPath( "B2.account_metas.0x222.derivation_path"), "path2"); - EXPECT_EQ(*hardware_accounts->FindStringPath( + EXPECT_EQ(*hardware_accounts.FindStringByDottedPath( "B2.account_metas.0x222.hardware_vendor"), "vendor2"); - ASSERT_FALSE( - GetPrefs() - ->Get(kBraveWalletKeyrings) - ->FindStringPath("hardware.A1.account_metas.0x111.account_name")); + ASSERT_FALSE(GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindStringByDottedPath( + "hardware.A1.account_metas.0x111.account_name")); } TEST_F(KeyringServiceUnitTest, ImportedAccounts) { @@ -1812,7 +1812,7 @@ TEST_F(KeyringServiceUnitTest, ImportedAccounts) { EXPECT_EQ(default_keyring->GetImportedAccountsNumber(), 2u); const base::Value* imported_accounts_value = - KeyringService::GetPrefForKeyring(GetPrefs(), kImportedAccounts, + KeyringService::GetPrefForKeyring(*GetPrefs(), kImportedAccounts, mojom::kDefaultKeyringId); ASSERT_TRUE(imported_accounts_value); EXPECT_EQ(imported_accounts_value->GetList()[0] @@ -1887,7 +1887,7 @@ TEST_F(KeyringServiceUnitTest, ImportedAccountFromJson) { // private key is encrypted const base::Value* imported_accounts_value = - KeyringService::GetPrefForKeyring(GetPrefs(), kImportedAccounts, + KeyringService::GetPrefForKeyring(*GetPrefs(), kImportedAccounts, mojom::kDefaultKeyringId); ASSERT_TRUE(imported_accounts_value); const std::string encrypted_private_key = @@ -2006,17 +2006,17 @@ TEST_F(KeyringServiceUnitTest, SetDefaultKeyringDerivedAccountMeta) { address1, mojom::kDefaultKeyringId); KeyringService::SetAccountMetaForKeyring(GetPrefs(), account_path2, name2, address2, mojom::kDefaultKeyringId); - EXPECT_EQ(KeyringService::GetAccountNameForKeyring(GetPrefs(), account_path1, + EXPECT_EQ(KeyringService::GetAccountNameForKeyring(*GetPrefs(), account_path1, mojom::kDefaultKeyringId), name1); EXPECT_EQ(KeyringService::GetAccountAddressForKeyring( - GetPrefs(), account_path1, mojom::kDefaultKeyringId), + *GetPrefs(), account_path1, mojom::kDefaultKeyringId), address1); - EXPECT_EQ(KeyringService::GetAccountNameForKeyring(GetPrefs(), account_path2, + EXPECT_EQ(KeyringService::GetAccountNameForKeyring(*GetPrefs(), account_path2, mojom::kDefaultKeyringId), name2); EXPECT_EQ(KeyringService::GetAccountAddressForKeyring( - GetPrefs(), account_path2, mojom::kDefaultKeyringId), + *GetPrefs(), account_path2, mojom::kDefaultKeyringId), address2); ASSERT_FALSE(observer.AccountsChangedFired()); @@ -2044,10 +2044,10 @@ TEST_F(KeyringServiceUnitTest, SetDefaultKeyringDerivedAccountMeta) { EXPECT_TRUE(observer.AccountsChangedFired()); observer.Reset(); - EXPECT_EQ(KeyringService::GetAccountNameForKeyring(GetPrefs(), account_path1, + EXPECT_EQ(KeyringService::GetAccountNameForKeyring(*GetPrefs(), account_path1, mojom::kDefaultKeyringId), name1); - EXPECT_EQ(KeyringService::GetAccountNameForKeyring(GetPrefs(), account_path2, + EXPECT_EQ(KeyringService::GetAccountNameForKeyring(*GetPrefs(), account_path2, mojom::kDefaultKeyringId), kUpdatedName); } @@ -2245,7 +2245,7 @@ TEST_F(KeyringServiceUnitTest, HardwareAccounts) { auto path = keyring_id + ".hardware." + account->device_id + ".account_metas." + account->address; ASSERT_TRUE( - GetPrefs()->GetDictionary(kBraveWalletKeyrings)->FindPath(path)); + GetPrefs()->GetDict(kBraveWalletKeyrings).FindByDottedPath(path)); } { // Checking Default keyring accounts @@ -2348,26 +2348,30 @@ TEST_F(KeyringServiceUnitTest, HardwareAccounts) { EXPECT_TRUE(observer.AccountsChangedFired()); observer.Reset(); - ASSERT_FALSE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("default.hardware.device1.account_metas.0x111")); + ASSERT_FALSE( + GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("default.hardware.device1.account_metas.0x111")); - ASSERT_FALSE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("default.hardware.device1.account_metas.0x264")); + ASSERT_FALSE( + GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("default.hardware.device1.account_metas.0x264")); - ASSERT_TRUE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("default.hardware.device2.account_metas.0xEA0")); + ASSERT_TRUE( + GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("default.hardware.device2.account_metas.0xEA0")); - ASSERT_TRUE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("filecoin.hardware.device2.account_metas.0xFIL")); + ASSERT_TRUE( + GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("filecoin.hardware.device2.account_metas.0xFIL")); ASSERT_TRUE( GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath( + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath( "filecoin_testnet.hardware.device2.account_metas.0xFILTEST")); ASSERT_FALSE(observer.AccountsChangedFired()); @@ -2404,22 +2408,24 @@ TEST_F(KeyringServiceUnitTest, HardwareAccounts) { EXPECT_TRUE(observer.AccountsChangedFired()); observer.Reset(); - ASSERT_FALSE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("default.hardware.device2.account_metas.0xEA0")); + ASSERT_FALSE( + GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("default.hardware.device2.account_metas.0xEA0")); ASSERT_FALSE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("default.hardware.device2")); + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("default.hardware.device2")); EXPECT_TRUE(RemoveHardwareAccount(&service, "0xFIL", kPasswordBrave, mojom::CoinType::FIL)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(observer.AccountsChangedFired()); observer.Reset(); - ASSERT_FALSE(GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath("filecoin.hardware.device2.account_metas.0xFIL")); + ASSERT_FALSE( + GetPrefs() + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath("filecoin.hardware.device2.account_metas.0xFIL")); EXPECT_TRUE(RemoveHardwareAccount(&service, "0xFILTEST", kPasswordBrave, mojom::CoinType::FIL)); @@ -2428,8 +2434,8 @@ TEST_F(KeyringServiceUnitTest, HardwareAccounts) { observer.Reset(); ASSERT_FALSE( GetPrefs() - ->GetDictionary(kBraveWalletKeyrings) - ->FindPath( + ->GetDict(kBraveWalletKeyrings) + .FindByDottedPath( "filecoin_testnet.hardware.device2.account_metas.0xFILTEST")); } @@ -2769,35 +2775,38 @@ TEST_F(KeyringServiceUnitTest, SetSelectedAccount) { EXPECT_TRUE(Unlock(&service, "brave")); // Can set Filecoin account { - absl::optional imported_account = ImportFilecoinAccount( + absl::optional fil_imported_account = ImportFilecoinAccount( &service, "Imported Filecoin account 1", // t1h4n7rphclbmwyjcp6jrdiwlfcuwbroxy3jvg33q "7b2254797065223a22736563703235366b31222c22507269766174654b6579223a2257" "6b4545645a45794235364b5168512b453338786a7663464c2b545a4842464e732b696a" "58533535794b383d227d", mojom::kFilecoinTestnet); - ASSERT_TRUE(imported_account.has_value()); - EXPECT_EQ(*imported_account, "t1h4n7rphclbmwyjcp6jrdiwlfcuwbroxy3jvg33q"); - EXPECT_TRUE(SetSelectedAccount( - &service, &observer, imported_account.value(), mojom::CoinType::FIL)); - EXPECT_EQ(imported_account.value(), + ASSERT_TRUE(fil_imported_account.has_value()); + EXPECT_EQ(*fil_imported_account, + "t1h4n7rphclbmwyjcp6jrdiwlfcuwbroxy3jvg33q"); + EXPECT_TRUE(SetSelectedAccount(&service, &observer, + fil_imported_account.value(), + mojom::CoinType::FIL)); + EXPECT_EQ(fil_imported_account.value(), GetFilecoinSelectedAccount(&service, mojom::kFilecoinTestnet)); } // Can set Solana account { // lazily create keyring when importing SOL account - absl::optional imported_account = ImportAccount( + absl::optional sol_imported_account = ImportAccount( &service, "Imported Account 1", // C5ukMV73nk32h52MjxtnZXTrrr7rupD9CTDDRnYYDRYQ "sCzwsBKmKtk5Hgb4YUJAduQ5nmJq4GTyzCXhrKonAGaexa83MgSZuTSMS6TSZTndnC" "YbQtaJQKLXET9jVjepWXe", mojom::CoinType::SOL); - ASSERT_TRUE(imported_account.has_value()); - EXPECT_EQ(*imported_account, + ASSERT_TRUE(sol_imported_account.has_value()); + EXPECT_EQ(*sol_imported_account, "C5ukMV73nk32h52MjxtnZXTrrr7rupD9CTDDRnYYDRYQ"); - EXPECT_TRUE(SetSelectedAccount( - &service, &observer, imported_account.value(), mojom::CoinType::SOL)); - EXPECT_EQ(imported_account.value(), + EXPECT_TRUE(SetSelectedAccount(&service, &observer, + sol_imported_account.value(), + mojom::CoinType::SOL)); + EXPECT_EQ(sol_imported_account.value(), GetSelectedAccount(&service, mojom::CoinType::SOL)); } EXPECT_EQ(hardware_account, @@ -3512,8 +3521,8 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) { } { // Create wallet with enabled filecoin & solana - base::test::ScopedFeatureList feature_list; - feature_list.InitWithFeatures( + base::test::ScopedFeatureList local_feature_list; + local_feature_list.InitWithFeatures( {brave_wallet::features::kBraveWalletFilecoinFeature, brave_wallet::features::kBraveWalletSolanaFeature}, {}); @@ -3536,8 +3545,8 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) { EXPECT_NE(service.encryptors_.at(mojom::kFilecoinKeyringId), nullptr); #endif service.Lock(); - base::test::ScopedFeatureList feature_list; - feature_list.InitWithFeatures( + base::test::ScopedFeatureList local_feature_list; + local_feature_list.InitWithFeatures( {brave_wallet::features::kBraveWalletFilecoinFeature, brave_wallet::features::kBraveWalletSolanaFeature}, {}); @@ -3567,19 +3576,20 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) { EXPECT_NE(service.encryptors_.at(mojom::kFilecoinKeyringId), nullptr); #endif - base::test::ScopedFeatureList feature_list; - base::FieldTrialParams parameters; - parameters[features::kCreateDefaultSolanaAccount.name] = "false"; + base::test::ScopedFeatureList local_feature_list; + base::FieldTrialParams local_parameters; + local_parameters[features::kCreateDefaultSolanaAccount.name] = "false"; std::vector - enabled_features; - enabled_features.emplace_back( - brave_wallet::features::kBraveWalletSolanaFeature, parameters); - enabled_features.emplace_back( + local_enabled_features; + local_enabled_features.emplace_back( + brave_wallet::features::kBraveWalletSolanaFeature, local_parameters); + local_enabled_features.emplace_back( brave_wallet::features::kBraveWalletFilecoinFeature, base::FieldTrialParams()); - feature_list.InitWithFeaturesAndParameters(enabled_features, {}); + local_feature_list.InitWithFeaturesAndParameters(local_enabled_features, + {}); service.Reset(); ASSERT_TRUE( diff --git a/browser/browsing_data/brave_browsing_data_remover_delegate.cc b/browser/browsing_data/brave_browsing_data_remover_delegate.cc index ff04bb96c716..766f5457a935 100644 --- a/browser/browsing_data/brave_browsing_data_remover_delegate.cc +++ b/browser/browsing_data/brave_browsing_data_remover_delegate.cc @@ -93,8 +93,7 @@ void BraveBrowsingDataRemoverDelegate::ClearShieldsSettings( ContentSettingsForOneType settings; map->GetSettingsForOneType(content_type, &settings); for (const ContentSettingPatternSource& setting : settings) { - base::Time last_modified = provider->GetWebsiteSettingLastModified( - setting.primary_pattern, setting.secondary_pattern, content_type); + base::Time last_modified = setting.metadata.last_modified; if (last_modified >= begin_time && (last_modified < end_time || end_time.is_null())) { provider->SetWebsiteSetting(setting.primary_pattern, diff --git a/browser/extensions/api/brave_rewards_api.cc b/browser/extensions/api/brave_rewards_api.cc index d78a746a9474..b307a374573c 100644 --- a/browser/extensions/api/brave_rewards_api.cc +++ b/browser/extensions/api/brave_rewards_api.cc @@ -1354,21 +1354,21 @@ ExtensionFunction::ResponseAction BraveRewardsUpdatePrefsFunction::Run() { auto* ads_service = AdsServiceFactory::GetForProfile(profile); if (rewards_service) { - bool* ac_enabled = params->prefs.auto_contribute_enabled.get(); + auto& ac_enabled = params->prefs.auto_contribute_enabled; if (ac_enabled) rewards_service->SetAutoContributeEnabled(*ac_enabled); - double* ac_amount = params->prefs.auto_contribute_amount.get(); + auto& ac_amount = params->prefs.auto_contribute_amount; if (ac_amount) rewards_service->SetAutoContributionAmount(*ac_amount); } if (ads_service) { - bool* ads_enabled = params->prefs.ads_enabled.get(); + auto& ads_enabled = params->prefs.ads_enabled; if (ads_enabled) ads_service->SetEnabled(*ads_enabled); - int* ads_per_hour = params->prefs.ads_per_hour.get(); + auto& ads_per_hour = params->prefs.ads_per_hour; if (ads_per_hour) ads_service->SetMaximumNotificationAdsPerHour(*ads_per_hour); } diff --git a/browser/farbling/brave_font_whitelist_browsertest.cc b/browser/farbling/brave_font_whitelist_browsertest.cc index 9071a0ec9790..c7986a805dd6 100644 --- a/browser/farbling/brave_font_whitelist_browsertest.cc +++ b/browser/farbling/brave_font_whitelist_browsertest.cc @@ -95,7 +95,7 @@ TEST_F(BraveFontWhitelistRenderViewTest, MAYBE_FontLocalSource) { // If the width of both spans is the same, that means they were both blocked // from using the specified font (Helvetica), which is what we want. - EXPECT_EQ(p1.BoundsInViewport().width(), p2.BoundsInViewport().width()); + EXPECT_EQ(p1.BoundsInWidget().width(), p2.BoundsInWidget().width()); } } // namespace content_settings diff --git a/browser/flags/android/java/src/org/chromium/chrome/browser/flags/BraveCachedFlag.java b/browser/flags/android/java/src/org/chromium/chrome/browser/flags/BraveCachedFlag.java new file mode 100644 index 000000000000..d912f757609c --- /dev/null +++ b/browser/flags/android/java/src/org/chromium/chrome/browser/flags/BraveCachedFlag.java @@ -0,0 +1,38 @@ +/* Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. */ + +package org.chromium.chrome.browser.flags; + +import java.util.HashMap; + +/** + * Class to override default cached values. + */ +public class BraveCachedFlag extends CachedFlag { + // Set of flags to override. + private static final HashMap sFlags; + static { + sFlags = new HashMap(); + sFlags.put(ChromeFeatureList.START_SURFACE_ANDROID, false); + } + + private final boolean mDefaultValue; + + public BraveCachedFlag(String featureName, boolean defaultValue) { + super(featureName, defaultValue); + + // Override value if necessary. + if (sFlags.containsKey(featureName)) { + mDefaultValue = sFlags.get(featureName); + } else { + mDefaultValue = defaultValue; + } + } + + @Override + public boolean isEnabled() { + return CachedFeatureFlags.isEnabled(mFeatureName, mDefaultValue); + } +} diff --git a/browser/flags/brave_flags_java_sources.gni b/browser/flags/brave_flags_java_sources.gni new file mode 100644 index 000000000000..23eb495fe6a8 --- /dev/null +++ b/browser/flags/brave_flags_java_sources.gni @@ -0,0 +1,8 @@ +# Copyright 2022 The Brave Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Since CachedFlag that we extend and ChromeFeatureList that we patch are parts of the same +# component, we have to embed our class to this component. Otherwise we will have cycled +# dependency. +brave_flags_java_sources = [ "//brave/browser/flags/android/java/src/org/chromium/chrome/browser/flags/BraveCachedFlag.java" ] diff --git a/browser/importer/brave_external_process_importer_host_unittest.cc b/browser/importer/brave_external_process_importer_host_unittest.cc index 32cef1aa678d..7b53caee80fd 100644 --- a/browser/importer/brave_external_process_importer_host_unittest.cc +++ b/browser/importer/brave_external_process_importer_host_unittest.cc @@ -37,19 +37,19 @@ class ImportEndedObserver : public importer::ImporterProgressObserver { ~ImportEndedObserver() override = default; // Invoked when the import begins. - void ImportStarted() override{}; + void ImportStarted() override {} // Invoked when data for the specified item is about to be collected. - void ImportItemStarted(importer::ImportItem item) override{}; + void ImportItemStarted(importer::ImportItem item) override {} // Invoked when data for the specified item has been collected from the // source profile and is now ready for further processing. void ImportItemEnded(importer::ImportItem item) override { std::move(callback_).Run(); - }; + } // Invoked when the source profile has been imported. - void ImportEnded() override{}; + void ImportEnded() override {} protected: base::OnceClosure callback_; diff --git a/browser/ipfs/content_browser_client_helper.h b/browser/ipfs/content_browser_client_helper.h index a34699cbeb0f..91fdaec5b675 100644 --- a/browser/ipfs/content_browser_client_helper.h +++ b/browser/ipfs/content_browser_client_helper.h @@ -15,10 +15,6 @@ namespace content { class BrowserContext; } // namespace content -namespace ui { -enum PageTransition; -} // namespace ui - namespace url { class Origin; } // namespace url diff --git a/browser/ipfs/ipfs_dns_resolver_impl.h b/browser/ipfs/ipfs_dns_resolver_impl.h index fe99fc4012cb..b42f8d97e49c 100644 --- a/browser/ipfs/ipfs_dns_resolver_impl.h +++ b/browser/ipfs/ipfs_dns_resolver_impl.h @@ -11,6 +11,7 @@ #include #include "base/sequence_checker.h" +#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/network/public/mojom/host_resolver.mojom.h" #include "services/network/public/mojom/network_service.mojom.h" diff --git a/browser/ipfs/ipfs_host_resolver.cc b/browser/ipfs/ipfs_host_resolver.cc index 548a450b1c3b..b64e54e58c17 100644 --- a/browser/ipfs/ipfs_host_resolver.cc +++ b/browser/ipfs/ipfs_host_resolver.cc @@ -49,10 +49,11 @@ IPFSHostResolver::IPFSHostResolver( } IPFSHostResolver::~IPFSHostResolver() = default; -void IPFSHostResolver::Resolve(const net::HostPortPair& host, - const net::NetworkIsolationKey& isolation_key, - net::DnsQueryType dns_query_type, - HostTextResultsCallback callback) { +void IPFSHostResolver::Resolve( + const net::HostPortPair& host, + const net::NetworkAnonymizationKey& anonymization_key, + net::DnsQueryType dns_query_type, + HostTextResultsCallback callback) { if (!callback) return; @@ -73,15 +74,18 @@ void IPFSHostResolver::Resolve(const net::HostPortPair& host, resolving_host_ = host.host(); net::HostPortPair local_host_port(prefix_ + resolving_host_, host.port()); - network_context_->ResolveHost(local_host_port, isolation_key, - std::move(parameters), - receiver_.BindNewPipeAndPassRemote()); + network_context_->ResolveHost( + network::mojom::HostResolverHost::NewHostPortPair(local_host_port), + anonymization_key, std::move(parameters), + receiver_.BindNewPipeAndPassRemote()); } void IPFSHostResolver::OnComplete( int result, const net::ResolveErrorInfo& error_info, - const absl::optional& list) { + const absl::optional& list, + const absl::optional& + endpoint_results_with_metadata) { if (result != net::OK) { VLOG(1) << "DNS resolving error:" << net::ErrorToString(result) << " for host: " << prefix_ + resolving_host_; diff --git a/browser/ipfs/ipfs_host_resolver.h b/browser/ipfs/ipfs_host_resolver.h index 37aeb368d531..f5a143c603ba 100644 --- a/browser/ipfs/ipfs_host_resolver.h +++ b/browser/ipfs/ipfs_host_resolver.h @@ -13,7 +13,7 @@ #include "base/callback_forward.h" #include "mojo/public/cpp/bindings/receiver.h" #include "net/base/host_port_pair.h" -#include "net/base/network_isolation_key.h" +#include "net/base/network_anonymization_key.h" #include "net/dns/public/dns_query_type.h" #include "services/network/public/cpp/resolve_host_client_base.h" #include "services/network/public/mojom/host_resolver.mojom.h" @@ -34,7 +34,7 @@ class IPFSHostResolver : public network::ResolveHostClientBase { const std::string& dnslink)>; virtual void Resolve(const net::HostPortPair& host, - const net::NetworkIsolationKey& isolation_key, + const net::NetworkAnonymizationKey& anonymization_key, net::DnsQueryType dns_query_type, HostTextResultsCallback callback); @@ -47,10 +47,11 @@ class IPFSHostResolver : public network::ResolveHostClientBase { private: // network::mojom::ResolveHostClient implementation: - void OnComplete( - int result, - const net::ResolveErrorInfo& resolve_error_info, - const absl::optional& resolved_addresses) override; + void OnComplete(int result, + const net::ResolveErrorInfo& resolve_error_info, + const absl::optional& resolved_addresses, + const absl::optional& + endpoint_results_with_metadata) override; void OnTextResults(const std::vector& text_results) override; std::string resolving_host_; diff --git a/browser/ipfs/ipfs_host_resolver_unittest.cc b/browser/ipfs/ipfs_host_resolver_unittest.cc index 067860b1c32d..df21cf9bff17 100644 --- a/browser/ipfs/ipfs_host_resolver_unittest.cc +++ b/browser/ipfs/ipfs_host_resolver_unittest.cc @@ -41,12 +41,15 @@ class FakeHostResolver : public network::mojom::HostResolver { ~FakeHostResolver() override = default; // network::mojom::HostResolver - void ResolveHost(const net::HostPortPair& host, - const net::NetworkIsolationKey& network_isolation_key, - network::mojom::ResolveHostParametersPtr parameters, - mojo::PendingRemote - pending_response_client) override { - EXPECT_EQ(expected_host_, host.host()); + void ResolveHost( + network::mojom::HostResolverHostPtr host, + const net::NetworkAnonymizationKey& network_anonymization_key, + network::mojom::ResolveHostParametersPtr parameters, + mojo::PendingRemote + pending_response_client) override { + EXPECT_EQ(expected_host_, host->is_host_port_pair() + ? host->get_host_port_pair().host() + : host->get_scheme_host_port().host()); EXPECT_EQ(parameters->dns_query_type, net::DnsQueryType::TXT); mojo::Remote response_client; response_client.Bind(std::move(pending_response_client)); @@ -85,14 +88,16 @@ class FakeHostResolverFail : public FakeHostResolver { ~FakeHostResolverFail() override = default; // network::mojom::HostResolver - void ResolveHost(const net::HostPortPair& host, - const net::NetworkIsolationKey& network_isolation_key, - network::mojom::ResolveHostParametersPtr parameters, - mojo::PendingRemote - pending_response_client) override { + void ResolveHost( + network::mojom::HostResolverHostPtr host, + const net::NetworkAnonymizationKey& network_anonymization_key, + network::mojom::ResolveHostParametersPtr parameters, + mojo::PendingRemote + pending_response_client) override { mojo::Remote response_client; response_client.Bind(std::move(pending_response_client)); - response_client->OnComplete(-2, net::ResolveErrorInfo(), absl::nullopt); + response_client->OnComplete(-2, net::ResolveErrorInfo(), absl::nullopt, + absl::nullopt); resolve_host_called_++; } }; @@ -103,13 +108,14 @@ class FakeNetworkContext : public network::TestNetworkContext { ~FakeNetworkContext() override = default; // network::mojom::HostResolver - void ResolveHost(const net::HostPortPair& host, - const net::NetworkIsolationKey& network_isolation_key, - network::mojom::ResolveHostParametersPtr parameters, - mojo::PendingRemote - pending_response_client) override { + void ResolveHost( + network::mojom::HostResolverHostPtr host, + const net::NetworkAnonymizationKey& network_anonymization_key, + network::mojom::ResolveHostParametersPtr parameters, + mojo::PendingRemote + pending_response_client) override { DCHECK(host_resolver_); - host_resolver_->ResolveHost(host, network_isolation_key, + host_resolver_->ResolveHost(std::move(host), network_anonymization_key, std::move(parameters), std::move(pending_response_client)); } @@ -172,7 +178,7 @@ TEST_F(IPFSHostResolverTest, PrefixRunSuccess) { SetResolvedCallbackCalled(0); ipfs_resolver.Resolve( - net::HostPortPair(host, 11), net::NetworkIsolationKey(), + net::HostPortPair(host, 11), net::NetworkAnonymizationKey(), net::DnsQueryType::TXT, base::BindOnce(&IPFSHostResolverTest::HostResolvedCallback, weak_ptr_factory_.GetWeakPtr(), run_loop.QuitClosure(), @@ -201,7 +207,7 @@ TEST_F(IPFSHostResolverTest, SuccessOnReuse) { SetResolvedCallbackCalled(0); ipfs_resolver.Resolve( - net::HostPortPair(host, 11), net::NetworkIsolationKey(), + net::HostPortPair(host, 11), net::NetworkAnonymizationKey(), net::DnsQueryType::TXT, base::BindOnce(&IPFSHostResolverTest::HostResolvedCallback, weak_ptr_factory_.GetWeakPtr(), run_loop.QuitClosure(), @@ -214,7 +220,7 @@ TEST_F(IPFSHostResolverTest, SuccessOnReuse) { EXPECT_EQ(resolved_callback_called(), 1); ipfs_resolver.Resolve( - net::HostPortPair(host, 11), net::NetworkIsolationKey(), + net::HostPortPair(host, 11), net::NetworkAnonymizationKey(), net::DnsQueryType::TXT, base::BindOnce( [](const std::string& expected_host, const std::string& host, @@ -237,7 +243,7 @@ TEST_F(IPFSHostResolverTest, ResolutionFailed) { ipfs_resolver.SetCompleteCallbackForTesting(run_loop.QuitClosure()); SetResolvedCallbackCalled(0); ipfs_resolver.Resolve( - net::HostPortPair(host, 11), net::NetworkIsolationKey(), + net::HostPortPair(host, 11), net::NetworkAnonymizationKey(), net::DnsQueryType::TXT, base::BindOnce([](const std::string& host, const std::string& dnslink) { NOTREACHED(); diff --git a/browser/ipfs/ipfs_tab_helper.cc b/browser/ipfs/ipfs_tab_helper.cc index cf47db1bd0d7..755742e5326a 100644 --- a/browser/ipfs/ipfs_tab_helper.cc +++ b/browser/ipfs/ipfs_tab_helper.cc @@ -152,12 +152,15 @@ void IPFSTabHelper::ResolveIPFSLink() { auto resolved_callback = base::BindOnce(&IPFSTabHelper::HostResolvedCallback, weak_ptr_factory_.GetWeakPtr()); - const auto& key = + const auto& network_anonymization_key = web_contents()->GetPrimaryMainFrame() - ? web_contents()->GetPrimaryMainFrame()->GetNetworkIsolationKey() - : net::NetworkIsolationKey(); - resolver_->Resolve(host_port_pair, key, net::DnsQueryType::TXT, - std::move(resolved_callback)); + ? web_contents() + ->GetPrimaryMainFrame() + ->GetIsolationInfoForSubresources() + .network_anonymization_key() + : net::NetworkAnonymizationKey(); + resolver_->Resolve(host_port_pair, network_anonymization_key, + net::DnsQueryType::TXT, std::move(resolved_callback)); } bool IPFSTabHelper::IsDNSLinkCheckEnabled() const { diff --git a/browser/ipfs/ipfs_tab_helper_browsertest.cc b/browser/ipfs/ipfs_tab_helper_browsertest.cc index 54564a60b65e..5be3f1b79a25 100644 --- a/browser/ipfs/ipfs_tab_helper_browsertest.cc +++ b/browser/ipfs/ipfs_tab_helper_browsertest.cc @@ -84,7 +84,7 @@ class FakeIPFSHostResolver : public ipfs::IPFSHostResolver { : ipfs::IPFSHostResolver(context) {} ~FakeIPFSHostResolver() override = default; void Resolve(const net::HostPortPair& host, - const net::NetworkIsolationKey& isolation_key, + const net::NetworkAnonymizationKey& anonymization_key, net::DnsQueryType dns_query_type, HostTextResultsCallback callback) override { resolve_called_++; diff --git a/browser/net/brave_ad_block_tp_network_delegate_helper.cc b/browser/net/brave_ad_block_tp_network_delegate_helper.cc index 77ac550c8242..a7decc99fb7b 100644 --- a/browser/net/brave_ad_block_tp_network_delegate_helper.cc +++ b/browser/net/brave_ad_block_tp_network_delegate_helper.cc @@ -96,7 +96,7 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { cb_ = base::BindOnce(&UseCnameResult, task_runner, std::move(next_callback), ctx, previous_result); - const auto network_isolation_key = ctx->network_isolation_key; + const auto network_anonymization_key = ctx->network_anonymization_key; network::mojom::ResolveHostParametersPtr optional_parameters = network::mojom::ResolveHostParameters::New(); @@ -116,15 +116,17 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { if (g_testing_host_resolver) { g_testing_host_resolver->ResolveHost( - net::HostPortPair::FromURL(ctx->request_url), network_isolation_key, - std::move(optional_parameters), receiver_.BindNewPipeAndPassRemote()); + network::mojom::HostResolverHost::NewHostPortPair( + net::HostPortPair::FromURL(ctx->request_url)), + network_anonymization_key, std::move(optional_parameters), + receiver_.BindNewPipeAndPassRemote()); } else { auto* web_contents = content::WebContents::FromFrameTreeNodeId(ctx->frame_tree_node_id); if (!web_contents) { start_time_ = base::TimeTicks::Now(); this->OnComplete(net::ERR_FAILED, net::ResolveErrorInfo(), - absl::nullopt); + absl::nullopt, absl::nullopt); return; } @@ -134,20 +136,23 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { ->GetNetworkContext(); network_context->ResolveHost( - net::HostPortPair::FromURL(ctx->request_url), network_isolation_key, - std::move(optional_parameters), receiver_.BindNewPipeAndPassRemote()); + network::mojom::HostResolverHost::NewHostPortPair( + net::HostPortPair::FromURL(ctx->request_url)), + network_anonymization_key, std::move(optional_parameters), + receiver_.BindNewPipeAndPassRemote()); } - receiver_.set_disconnect_handler( - base::BindOnce(&AdblockCnameResolveHostClient::OnComplete, - base::Unretained(this), net::ERR_NAME_NOT_RESOLVED, - net::ResolveErrorInfo(net::ERR_FAILED), absl::nullopt)); + receiver_.set_disconnect_handler(base::BindOnce( + &AdblockCnameResolveHostClient::OnComplete, base::Unretained(this), + net::ERR_NAME_NOT_RESOLVED, net::ResolveErrorInfo(net::ERR_FAILED), + absl::nullopt, absl::nullopt)); } - void OnComplete( - int32_t result, - const net::ResolveErrorInfo& resolve_error_info, - const absl::optional& resolved_addresses) override { + void OnComplete(int32_t result, + const net::ResolveErrorInfo& resolve_error_info, + const absl::optional& resolved_addresses, + const absl::optional& + endpoint_results_with_metadata) override { UMA_HISTOGRAM_TIMES("Brave.ShieldsCNAMEBlocking.TotalResolutionTime", base::TimeTicks::Now() - start_time_); if (result == net::OK && resolved_addresses) { diff --git a/browser/net/brave_proxying_url_loader_factory.cc b/browser/net/brave_proxying_url_loader_factory.cc index 4ab2943a62d3..497ff71465b4 100644 --- a/browser/net/brave_proxying_url_loader_factory.cc +++ b/browser/net/brave_proxying_url_loader_factory.cc @@ -221,9 +221,11 @@ void BraveProxyingURLLoaderFactory::InProgressRequest::OnReceiveEarlyHints( void BraveProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse( network::mojom::URLResponseHeadPtr head, - mojo::ScopedDataPipeConsumerHandle body) { + mojo::ScopedDataPipeConsumerHandle body, + absl::optional cached_metadata) { current_response_head_ = std::move(head); current_response_body_ = std::move(body); + cached_metadata_ = std::move(cached_metadata); ctx_->internal_redirect = false; HandleResponseOrRedirectHeaders( base::BindRepeating(&InProgressRequest::ContinueToResponseStarted, @@ -249,11 +251,6 @@ void BraveProxyingURLLoaderFactory::InProgressRequest::OnUploadProgress( std::move(callback)); } -void BraveProxyingURLLoaderFactory::InProgressRequest::OnReceiveCachedMetadata( - mojo_base::BigBuffer data) { - target_client_->OnReceiveCachedMetadata(std::move(data)); -} - void BraveProxyingURLLoaderFactory::InProgressRequest::OnTransferSizeUpdated( int32_t transfer_size_diff) { target_client_->OnTransferSizeUpdated(transfer_size_diff); @@ -367,7 +364,8 @@ void BraveProxyingURLLoaderFactory::InProgressRequest:: } // Craft the response. - target_client_->OnReceiveResponse(std::move(response), std::move(consumer)); + target_client_->OnReceiveResponse(std::move(response), std::move(consumer), + std::move(cached_metadata_)); auto write_data = std::make_unique(); write_data->client = weak_factory_.GetWeakPtr(); @@ -527,7 +525,8 @@ void BraveProxyingURLLoaderFactory::InProgressRequest:: proxied_client_receiver_.Resume(); target_client_->OnReceiveResponse(std::move(current_response_head_), - std::move(current_response_body_)); + std::move(current_response_body_), + std::move(cached_metadata_)); } void BraveProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect( diff --git a/browser/net/brave_proxying_url_loader_factory.h b/browser/net/brave_proxying_url_loader_factory.h index 35e8b9d6da29..ecae516560c2 100644 --- a/browser/net/brave_proxying_url_loader_factory.h +++ b/browser/net/brave_proxying_url_loader_factory.h @@ -85,15 +85,16 @@ class BraveProxyingURLLoaderFactory // network::mojom::URLLoaderClient: void OnReceiveEarlyHints( network::mojom::EarlyHintsPtr early_hints) override; - void OnReceiveResponse(network::mojom::URLResponseHeadPtr response_head, - mojo::ScopedDataPipeConsumerHandle body) override; + void OnReceiveResponse( + network::mojom::URLResponseHeadPtr response_head, + mojo::ScopedDataPipeConsumerHandle body, + absl::optional cached_metadata) override; void OnReceiveRedirect( const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr response_head) override; void OnUploadProgress(int64_t current_position, int64_t total_size, OnUploadProgressCallback callback) override; - void OnReceiveCachedMetadata(mojo_base::BigBuffer data) override; void OnTransferSizeUpdated(int32_t transfer_size_diff) override; void OnComplete(const network::URLLoaderCompletionStatus& status) override; @@ -147,6 +148,7 @@ class BraveProxyingURLLoaderFactory // ExtensionWebRequestEventRouter) through much of the request's lifetime. // That code supports both Network Service and non-Network Service behavior, // which is why this weirdness exists here. + absl::optional cached_metadata_; network::mojom::URLResponseHeadPtr current_response_head_; mojo::ScopedDataPipeConsumerHandle current_response_body_; scoped_refptr override_headers_; diff --git a/browser/net/brave_reduce_language_network_delegate_helper.cc b/browser/net/brave_reduce_language_network_delegate_helper.cc index 468a831703d8..7f8a443e149b 100644 --- a/browser/net/brave_reduce_language_network_delegate_helper.cc +++ b/browser/net/brave_reduce_language_network_delegate_helper.cc @@ -36,8 +36,9 @@ std::string FarbleAcceptLanguageHeader( const GURL& tab_origin, Profile* profile, HostContentSettingsMap* content_settings) { - std::string languages = - profile->GetPrefs()->Get(language::prefs::kAcceptLanguages)->GetString(); + std::string languages = profile->GetPrefs() + ->GetValue(language::prefs::kAcceptLanguages) + .GetString(); std::string accept_language_string = language::GetFirstLanguage(languages); // If the first language is a multi-part code like "en-US" or "zh-HK", // extract and append the base language code to |accept_language_string|. diff --git a/browser/net/url_context.cc b/browser/net/url_context.cc index f20f4a26168e..012aef4d4ff5 100644 --- a/browser/net/url_context.cc +++ b/browser/net/url_context.cc @@ -98,8 +98,8 @@ std::shared_ptr BraveRequestInfo::MakeCTX( // cross-site top-level navigations. Fortunately for now it is not a problem // for shields functionality. We should reconsider this machinery, also // given that this is always empty for subresources. - ctx->network_isolation_key = - request.trusted_params->isolation_info.network_isolation_key(); + ctx->network_anonymization_key = + request.trusted_params->isolation_info.network_anonymization_key(); ctx->tab_origin = request.trusted_params->isolation_info.top_frame_origin() .value_or(url::Origin()) .GetURL(); diff --git a/browser/net/url_context.h b/browser/net/url_context.h index 5eba785cb0f9..a4e05520784f 100644 --- a/browser/net/url_context.h +++ b/browser/net/url_context.h @@ -10,7 +10,7 @@ #include #include -#include "net/base/network_isolation_key.h" +#include "net/base/network_anonymization_key.h" #include "net/http/http_request_headers.h" #include "net/http/http_response_headers.h" #include "net/url_request/referrer_policy.h" @@ -108,7 +108,8 @@ struct BraveRequestInfo { return blocked_by == kAdBlocked && !mock_data_url.empty(); } - net::NetworkIsolationKey network_isolation_key = net::NetworkIsolationKey(); + net::NetworkAnonymizationKey network_anonymization_key = + net::NetworkAnonymizationKey(); // Default to invalid type for resource_type, so delegate helpers // can properly detect that the info couldn't be obtained. diff --git a/browser/ntp_background/ntp_background_prefs.cc b/browser/ntp_background/ntp_background_prefs.cc index ed4b914d5291..d3c20e651440 100644 --- a/browser/ntp_background/ntp_background_prefs.cc +++ b/browser/ntp_background/ntp_background_prefs.cc @@ -127,7 +127,5 @@ absl::variant NTPBackgroundPrefs::GetSelectedValue() const { } const base::Value::Dict* NTPBackgroundPrefs::GetPrefValue() const { - const auto* value = service_->GetDictionary(kPrefName); - DCHECK(value && value->is_dict()); - return value->GetIfDict(); + return &service_->GetDict(kPrefName); } diff --git a/browser/ntp_background/ntp_background_prefs_unittest.cc b/browser/ntp_background/ntp_background_prefs_unittest.cc index 860c2c9e9bbe..a0a2f969e738 100644 --- a/browser/ntp_background/ntp_background_prefs_unittest.cc +++ b/browser/ntp_background/ntp_background_prefs_unittest.cc @@ -20,13 +20,10 @@ class NTPBackgroundPrefsTest : public testing::Test { }; TEST_F(NTPBackgroundPrefsTest, RegisterDefaultPref) { - const auto* value = service_.GetDictionary(NTPBackgroundPrefs::kPrefName); - EXPECT_TRUE(value); - - const auto* dict = value->GetIfDict(); - EXPECT_TRUE(dict->FindString("type")); - EXPECT_TRUE(dict->FindBool("random").has_value()); - EXPECT_TRUE(dict->FindString("selected_value")); + const auto& dict = service_.GetDict(NTPBackgroundPrefs::kPrefName); + EXPECT_TRUE(dict.FindString("type")); + EXPECT_TRUE(dict.FindBool("random").has_value()); + EXPECT_TRUE(dict.FindString("selected_value")); } TEST_F(NTPBackgroundPrefsTest, TypeAccessor) { @@ -43,7 +40,6 @@ TEST_F(NTPBackgroundPrefsTest, MigrationTest) { auto* registry = service_.registry(); registry->RegisterBooleanPref(NTPBackgroundPrefs::kDeprecatedPrefName, false); EXPECT_FALSE(service_.GetBoolean(NTPBackgroundPrefs::kDeprecatedPrefName)); - EXPECT_TRUE(service_.GetDictionary(NTPBackgroundPrefs::kPrefName)); // Check default value EXPECT_TRUE(background_prefs_.IsBraveType()); diff --git a/browser/permissions/permission_lifetime_manager_browsertest.cc b/browser/permissions/permission_lifetime_manager_browsertest.cc index cedce3c80870..43c0b34ac234 100644 --- a/browser/permissions/permission_lifetime_manager_browsertest.cc +++ b/browser/permissions/permission_lifetime_manager_browsertest.cc @@ -141,8 +141,8 @@ class PermissionLifetimeManagerBrowserTest : public InProcessBrowserTest { ASSERT_TRUE(serializer.Serialize(pre_test_data_)); } - const base::Value* GetExpirationsPrefValue() { - return browser()->profile()->GetPrefs()->Get( + const base::Value::Dict& GetExpirationsPrefValue() { + return browser()->profile()->GetPrefs()->GetDict( prefs::kPermissionLifetimeExpirations); } @@ -176,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerBrowserTest, ExpirationSmoke) { EXPECT_EQ(1, prompt_factory_->show_count()); EXPECT_TRUE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), @@ -190,7 +190,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerBrowserTest, ExpirationSmoke) { url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ASK); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); } IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerBrowserTest, @@ -227,12 +227,12 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerBrowserTest, url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ALLOW); EXPECT_TRUE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); base::ScopedMockTimeMessageLoopTaskRunner scoped_mock_time_task_runner; permission_lifetime_manager()->RestartExpirationTimerForTesting(); EXPECT_TRUE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); scoped_mock_time_task_runner.task_runner()->FastForwardBy(base::Seconds(10)); EXPECT_TRUE(permission_lifetime_timer().IsRunning()); @@ -242,7 +242,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerBrowserTest, scoped_mock_time_task_runner.task_runner()->FastForwardBy(base::Seconds(60)); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ASK); @@ -270,13 +270,13 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerBrowserTest, url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ALLOW); EXPECT_TRUE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); host_content_settings_map()->SetContentSettingDefaultScope( url, url, ContentSettingsType::GEOLOCATION, ContentSetting::CONTENT_SETTING_DEFAULT); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); } class PermissionLifetimeManagerWithOriginMonitorBrowserTest @@ -306,7 +306,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(1, prompt_factory_->show_count()); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), @@ -329,7 +329,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ASK); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); } IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, @@ -350,7 +350,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(1, prompt_factory_->show_count()); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), @@ -363,7 +363,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ALLOW); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); // Navigate to another domain. It should keep the permission. const GURL& other_url = @@ -372,7 +372,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ALLOW); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); // Permission Should be reset after the timeout base::RunLoop run_loop; @@ -383,7 +383,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ASK); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); } IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, @@ -404,7 +404,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(1, prompt_factory_->show_count()); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), @@ -417,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ALLOW); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); // Navigate to another domain in PSL. It should keep the permission. const GURL& other_url = @@ -426,7 +426,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ALLOW); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); // Permission Should be reset after the timeout base::RunLoop run_loop; @@ -437,7 +437,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ASK); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); } IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, @@ -458,7 +458,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(1, prompt_factory_->show_count()); EXPECT_FALSE(permission_lifetime_timer().IsRunning()); - EXPECT_FALSE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_FALSE(GetExpirationsPrefValue().empty()); EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), @@ -476,7 +476,7 @@ IN_PROC_BROWSER_TEST_F(PermissionLifetimeManagerWithOriginMonitorBrowserTest, EXPECT_EQ(host_content_settings_map()->GetContentSetting( url, url, ContentSettingsType::GEOLOCATION), ContentSetting::CONTENT_SETTING_ASK); - EXPECT_TRUE(GetExpirationsPrefValue()->DictEmpty()); + EXPECT_TRUE(GetExpirationsPrefValue().empty()); } } // namespace permissions diff --git a/browser/permissions/permission_lifetime_manager_unittest.cc b/browser/permissions/permission_lifetime_manager_unittest.cc index e175ba2ffa58..d4607133f262 100644 --- a/browser/permissions/permission_lifetime_manager_unittest.cc +++ b/browser/permissions/permission_lifetime_manager_unittest.cc @@ -218,11 +218,10 @@ class PermissionLifetimeManagerTest : public testing::Test { base::StringPiece pref_value_template, const std::vector& subst = {}) { SCOPED_TRACE(testing::Message() << location.ToString()); - const base::Value* expirations = - prefs()->GetDictionary(prefs::kPermissionLifetimeExpirations); - ASSERT_TRUE(expirations); - EXPECT_EQ(*expirations, - base::test::ParseJson(base::ReplaceStringPlaceholders( + const auto& expirations = + prefs()->GetDict(prefs::kPermissionLifetimeExpirations); + EXPECT_EQ(expirations, + base::test::ParseJsonDict(base::ReplaceStringPlaceholders( pref_value_template, subst, nullptr))); } diff --git a/browser/playlist/test/playlist_browsertest.cc b/browser/playlist/test/playlist_browsertest.cc index f760823630d7..ae5a624917ab 100644 --- a/browser/playlist/test/playlist_browsertest.cc +++ b/browser/playlist/test/playlist_browsertest.cc @@ -216,8 +216,9 @@ class PlaylistBrowserTest : public PlatformBrowserTest, std::string log = "type" + PlaylistChangeParams::GetPlaylistChangeTypeAsString(type) + " wasn't found: ["; - for (const auto& type : called_change_types_) { - log += PlaylistChangeParams::GetPlaylistChangeTypeAsString(type) + ", "; + for (const auto& change_type : called_change_types_) { + log += PlaylistChangeParams::GetPlaylistChangeTypeAsString(change_type) + + ", "; } log += "]"; FAIL() << log; diff --git a/browser/profiles/BUILD.gn b/browser/profiles/BUILD.gn index 62202279b3c7..479598b7cdd4 100644 --- a/browser/profiles/BUILD.gn +++ b/browser/profiles/BUILD.gn @@ -40,7 +40,6 @@ source_set("profiles") { "//brave/components/constants", "//brave/components/ipfs/buildflags", "//brave/components/tor", - "//brave/content:browser", "//chrome/common", "//components/gcm_driver:gcm_buildflags", "//components/keyed_service/content", diff --git a/browser/profiles/brave_profile_manager.cc b/browser/profiles/brave_profile_manager.cc index 3a56909e7a78..b5b09f877743 100644 --- a/browser/profiles/brave_profile_manager.cc +++ b/browser/profiles/brave_profile_manager.cc @@ -23,7 +23,6 @@ #include "brave/components/content_settings/core/browser/brave_content_settings_pref_provider.h" #include "brave/components/ipfs/buildflags/buildflags.h" #include "brave/components/tor/tor_constants.h" -#include "brave/content/browser/webui/brave_shared_resources_data_source.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/profiles/profile_attributes_entry.h" @@ -50,24 +49,9 @@ using content::BrowserThread; -namespace { - -void AddBraveSharedResourcesDataSourceToProfile(Profile* profile) { - content::URLDataSource::Add( - profile, - std::make_unique(false)); - content::URLDataSource::Add( - profile, - std::make_unique(true)); -} - -} // namespace - BraveProfileManager::BraveProfileManager(const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { MigrateProfileNames(); - - AddObserver(this); } BraveProfileManager::~BraveProfileManager() { @@ -79,7 +63,6 @@ BraveProfileManager::~BraveProfileManager() { false, false); } } - RemoveObserver(this); } void BraveProfileManager::InitProfileUserPrefs(Profile* profile) { @@ -197,24 +180,6 @@ void BraveProfileManager::MigrateProfileNames() { #endif } -void BraveProfileManager::OnProfileAdded(Profile* profile) { - // Observe new profiles for creation of OTR profiles so that we can add our - // shared resources to them. - observed_profiles_.AddObservation(profile); - AddBraveSharedResourcesDataSourceToProfile(profile); -} - -void BraveProfileManager::OnOffTheRecordProfileCreated( - Profile* off_the_record) { - AddBraveSharedResourcesDataSourceToProfile(off_the_record); -} - -void BraveProfileManager::OnProfileWillBeDestroyed(Profile* profile) { - if (!profile->IsOffTheRecord()) { - observed_profiles_.RemoveObservation(profile); - } -} - BraveProfileManagerWithoutInit::BraveProfileManagerWithoutInit( const base::FilePath& user_data_dir) : BraveProfileManager(user_data_dir) { diff --git a/browser/profiles/brave_profile_manager.h b/browser/profiles/brave_profile_manager.h index b39a5391b7ed..fe6dfb8e7b9b 100644 --- a/browser/profiles/brave_profile_manager.h +++ b/browser/profiles/brave_profile_manager.h @@ -8,14 +8,9 @@ #include -#include "base/scoped_multi_source_observation.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/profiles/profile_manager_observer.h" -#include "chrome/browser/profiles/profile_observer.h" -class BraveProfileManager : public ProfileManager, - public ProfileManagerObserver, - public ProfileObserver { +class BraveProfileManager : public ProfileManager { public: explicit BraveProfileManager(const base::FilePath& user_data_dir); BraveProfileManager(const BraveProfileManager&) = delete; @@ -29,21 +24,12 @@ class BraveProfileManager : public ProfileManager, bool incognito, ProfileLoadedCallback callback) override; - // ProfileManagerObserver: - void OnProfileAdded(Profile* profile) override; - - // ProfileObserver: - void OnOffTheRecordProfileCreated(Profile* off_the_record) override; - void OnProfileWillBeDestroyed(Profile* profile) override; - protected: void DoFinalInitForServices(Profile* profile, bool go_off_the_record) override; private: void MigrateProfileNames(); - base::ScopedMultiSourceObservation - observed_profiles_{this}; }; class BraveProfileManagerWithoutInit : public BraveProfileManager { diff --git a/browser/profiles/brave_profile_manager_browsertest.cc b/browser/profiles/brave_profile_manager_browsertest.cc index e9677619dbf1..df7c652b636a 100644 --- a/browser/profiles/brave_profile_manager_browsertest.cc +++ b/browser/profiles/brave_profile_manager_browsertest.cc @@ -20,6 +20,7 @@ #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profile_test_util.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_service.h" @@ -41,15 +42,6 @@ namespace { -// An observer that returns back to test code after a new profile is -// initialized. -void OnUnblockOnProfileCreation(base::RunLoop* run_loop, - Profile* profile, - Profile::CreateStatus status) { - if (status == Profile::CREATE_STATUS_INITIALIZED) - run_loop->Quit(); -} - struct TestProfileData { std::u16string profile_name; std::u16string profile_name_expected_after_migration; @@ -110,11 +102,9 @@ IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest, profile_data[0].force_default_name); // Rest are generated for (auto& profile : profile_data) { - base::RunLoop run_loop; - profile_manager->CreateProfileAsync( - profile.profile_path, - base::BindRepeating(&OnUnblockOnProfileCreation, &run_loop)); - run_loop.Run(); + Profile* created_profile = profiles::testing::CreateProfileSync( + profile_manager, profile.profile_path); + EXPECT_TRUE(created_profile); ProfileAttributesEntry* entry = storage.GetProfileAttributesWithPath(profile.profile_path); ASSERT_NE(entry, nullptr); diff --git a/browser/resources/bookmarks/BUILD.gn b/browser/resources/bookmarks/BUILD.gn index 4a210cd55d33..aaa83f2d116a 100644 --- a/browser/resources/bookmarks/BUILD.gn +++ b/browser/resources/bookmarks/BUILD.gn @@ -3,50 +3,15 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. -import("//brave/resources/brave_grit.gni") -import("//chrome/common/features.gni") import("//tools/grit/preprocess_if_expr.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/generate_grd.gni") - -preprocess_folder = "preprocessed" -preprocess_manifest = "brave_preprocessed_manifest.json" - -brave_grit("resources") { - defines = chrome_grit_defines - - enable_input_discovery_for_gn_analyze = false - source = "$target_gen_dir/brave_bookmarks_resources.grd" - deps = [ ":build_grd" ] - - outputs = [ - "grit/brave_bookmarks_resources.h", - "grit/brave_bookmarks_resources_map.cc", - "grit/brave_bookmarks_resources_map.h", - "brave_bookmarks_resources.pak", - ] -} - -generate_grd("build_grd") { - grd_prefix = "brave_bookmarks" - out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" - input_files = [] - input_files_base_dir = rebase_path(".", "//") - - deps = [ ":preprocess" ] - manifest_files = [ - "$root_gen_dir/chrome/browser/resources/bookmarks/$preprocess_manifest", - ] -} +import("./sources.gni") +# Move brave files to the place where chromium bookmarks page is compiled from. It should be the same directory +# that build_webui.gni uses after it performs its own preprocess_if_expr. Once chromium and brave frontend files +# are all in the same place, build_webui.gni will continue its typescript and rollup compile (etc.) from that +# directory. preprocess_if_expr("preprocess") { in_folder = "./" - out_folder = - "$root_gen_dir/chrome/browser/resources/bookmarks/$preprocess_folder" - out_manifest = - "$root_gen_dir/chrome/browser/resources/bookmarks/$preprocess_manifest" - in_files = [ - "brave_overrides/folder_node.js", - "brave_overrides/index.js", - ] + out_folder = "$root_gen_dir/chrome/browser/resources/bookmarks/preprocessed" + in_files = brave_bookmarks_local_files } diff --git a/browser/resources/bookmarks/brave_overrides/folder_node.js b/browser/resources/bookmarks/brave_overrides/folder_node.ts similarity index 91% rename from browser/resources/bookmarks/brave_overrides/folder_node.js rename to browser/resources/bookmarks/brave_overrides/folder_node.ts index f9a4faa35048..fb1b878c999e 100644 --- a/browser/resources/bookmarks/brave_overrides/folder_node.js +++ b/browser/resources/bookmarks/brave_overrides/folder_node.ts @@ -3,8 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import {RegisterStyleOverride} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterStyleOverride} from 'chrome://resources/polymer_overriding.js' RegisterStyleOverride( 'bookmarks-folder-node', diff --git a/browser/resources/bookmarks/brave_overrides/index.js b/browser/resources/bookmarks/brave_overrides/index.ts similarity index 100% rename from browser/resources/bookmarks/brave_overrides/index.js rename to browser/resources/bookmarks/brave_overrides/index.ts diff --git a/browser/resources/bookmarks/sources.gni b/browser/resources/bookmarks/sources.gni index 1bb6990f0edc..ea4fbb47b0bb 100644 --- a/browser/resources/bookmarks/sources.gni +++ b/browser/resources/bookmarks/sources.gni @@ -3,10 +3,12 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. -brave_deps_chrome_browser_resources_bookmarks_in_files = [ - "brave_overrides/folder_node.js", - "brave_overrides/index.js", +brave_bookmarks_non_web_component_files = [ + "brave_overrides/folder_node.ts", + "brave_overrides/index.ts", ] -brave_deps_chrome_browser_resources_bookmarks_extra_deps = +brave_bookmarks_preprocess_extra_deps = [ "//brave/browser/resources/bookmarks:preprocess" ] + +brave_bookmarks_local_files = brave_bookmarks_non_web_component_files diff --git a/browser/resources/extensions/BUILD.gn b/browser/resources/extensions/BUILD.gn index cf63d006cee3..756f4eddc12e 100644 --- a/browser/resources/extensions/BUILD.gn +++ b/browser/resources/extensions/BUILD.gn @@ -1,68 +1,12 @@ -import("//brave/resources/brave_grit.gni") -import("//chrome/browser/resources/tools/optimize_webui.gni") -import("//chrome/common/features.gni") import("//tools/grit/preprocess_if_expr.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/generate_grd.gni") - -preprocess_folder = "preprocessed" -preprocess_manifest = "brave_preprocessed_manifest.json" -preprocess_gen_manifest = "brave_preprocessed_gen_manifest.json" - -brave_grit("resources") { - defines = chrome_grit_defines - - enable_input_discovery_for_gn_analyze = false - source = "$target_gen_dir/brave_extensions_resources.grd" - deps = [ ":build_grd" ] - - outputs = [ - "grit/brave_extensions_resources.h", - "grit/brave_extensions_resources_map.cc", - "grit/brave_extensions_resources_map.h", - "brave_extensions_resources.pak", - ] -} - -generate_grd("build_grd") { - grd_prefix = "brave_extensions" - out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" - input_files = [] - input_files_base_dir = rebase_path(".", "//") - - deps = [ - ":preprocess", - ":preprocess_generated", - ] - manifest_files = [ - "$root_gen_dir/chrome/browser/resources/extensions/$preprocess_manifest", - "$root_gen_dir/chrome/browser/resources/extensions/$preprocess_gen_manifest", - ] -} +import("./sources.gni") +# Move brave files to the place where chromium extensions page is compiled from. It should be the same directory +# that build_webui.gni uses after it performs its own preprocess_if_expr. Once chromium and brave frontend files +# are all in the same place, build_webui.gni will continue its typescript and rollup compile (etc.) from that +# directory. preprocess_if_expr("preprocess") { in_folder = "./" - out_folder = - "$root_gen_dir/chrome/browser/resources/extensions/$preprocess_folder" - out_manifest = - "$root_gen_dir/chrome/browser/resources/extensions/$preprocess_manifest" - in_files = [ - "brave_overrides/extensions_detail_view.js", - "brave_overrides/index.js", - ] -} - -preprocess_if_expr("preprocess_generated") { - deps = [ ":brave_item_list_more_items_module" ] - in_folder = target_gen_dir - out_folder = - "$root_gen_dir/chrome/browser/resources/extensions/$preprocess_folder" - out_manifest = "$root_gen_dir/chrome/browser/resources/extensions/$preprocess_gen_manifest" - in_files = [ "brave_item_list_more_items.js" ] -} - -polymer_modulizer("brave_item_list_more_items") { - js_file = "brave_item_list_more_items.js" - html_file = "brave_item_list_more_items.html" - html_type = "v3-ready" + out_folder = "$root_gen_dir/chrome/browser/resources/extensions/preprocessed" + in_files = brave_extensions_local_files } diff --git a/browser/resources/extensions/brave_item_list_more_items.js b/browser/resources/extensions/brave_item_list_more_items.ts similarity index 65% rename from browser/resources/extensions/brave_item_list_more_items.js rename to browser/resources/extensions/brave_item_list_more_items.ts index f8d9373dd2c8..41e62bebc363 100644 --- a/browser/resources/extensions/brave_item_list_more_items.js +++ b/browser/resources/extensions/brave_item_list_more_items.ts @@ -3,15 +3,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import 'chrome://resources/cr_elements/shared_style_css.m.js' +// @ts-nocheck TODO(petemill): Convert to Polymer class and remove ts-nocheck + +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js'; +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import 'chrome://resources/cr_elements/cr_shared_style.css.js' import 'chrome://resources/js/cr.m.js' -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {getTemplate} from './brave_item_list_more_items.html.js' Polymer({ is: 'extensions-brave-item-list-more-items', - _template: html`{__html_template__}`, + _template: getTemplate(), behaviors: [I18nBehavior], diff --git a/browser/resources/extensions/brave_overrides/extensions_detail_view.js b/browser/resources/extensions/brave_overrides/extensions_detail_view.ts similarity index 72% rename from browser/resources/extensions/brave_overrides/extensions_detail_view.js rename to browser/resources/extensions/brave_overrides/extensions_detail_view.ts index c02d32c20394..a2bf1bf0441a 100644 --- a/browser/resources/extensions/brave_overrides/extensions_detail_view.js +++ b/browser/resources/extensions/brave_overrides/extensions_detail_view.ts @@ -3,24 +3,27 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications, RegisterPolymerComponentBehaviors} from 'chrome://brave-resources/polymer_overriding.js' -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {RegisterPolymerTemplateModifications, RegisterPolymerComponentBehaviors} from 'chrome://resources/polymer_overriding.js' +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js' + RegisterPolymerTemplateModifications({ - 'extensions-detail-view': (templateContent) => { - let optionsTemplate = - templateContent.querySelector('template[is="dom-if"][if*="shouldShowOptionsSection_"]') + 'extensions-detail-view': (templateContent: DocumentFragment) => { + let optionsTemplate: HTMLTemplateElement | null = + templateContent.querySelector('template[is="dom-if"][if*="shouldShowOptionsSection_"]') if (!optionsTemplate) { console.error('[Brave Extensions Overrides] Could not find optionsTemplate') return } let incognitoTemplate = - optionsTemplate.content.querySelector('template[is="dom-if"][if*="shouldShowIncognitoOption_"]') + optionsTemplate.content.querySelector('template[is="dom-if"][if*="shouldShowIncognitoOption_"]') if (!incognitoTemplate) { console.error('[Brave Extensions Overrides] Could not find incognitoTemplate') return } - let incognitoWarningDiv = incognitoTemplate.content.querySelector('.section-content') + let incognitoWarningDiv = incognitoTemplate.content.querySelector('.section-content') if (!incognitoWarningDiv) { console.error('[Brave Extensions Overrides] Could not find incognitoWarningDiv') return diff --git a/browser/resources/extensions/brave_overrides/index.js b/browser/resources/extensions/brave_overrides/index.ts similarity index 100% rename from browser/resources/extensions/brave_overrides/index.js rename to browser/resources/extensions/brave_overrides/index.ts diff --git a/browser/resources/extensions/sources.gni b/browser/resources/extensions/sources.gni index b94bb9e71ecd..911f69cdcd8c 100644 --- a/browser/resources/extensions/sources.gni +++ b/browser/resources/extensions/sources.gni @@ -3,13 +3,19 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. -brave_deps_chrome_browser_resources_extensions_in_files = [ - "brave_item_list_more_items.js", - "brave_overrides/extensions_detail_view.js", - "brave_overrides/index.js", -] +brave_extensions_web_component_files = [ "brave_item_list_more_items.ts" ] -brave_deps_chrome_browser_resources_extensions_extra_deps = [ - "//brave/browser/resources/extensions:preprocess", - "//brave/browser/resources/extensions:preprocess_generated", +brave_extensions_non_web_component_files = [ + "brave_overrides/extensions_detail_view.ts", + "brave_overrides/index.ts", ] + +brave_extensions_preprocess_extra_deps = + [ "//brave/browser/resources/extensions:preprocess" ] + +brave_extensions_local_files = brave_extensions_web_component_files + + brave_extensions_non_web_component_files +foreach(component_file, brave_extensions_web_component_files) { + brave_extensions_local_files += + [ string_replace(component_file, ".ts", ".html") ] +} diff --git a/browser/resources/history/BUILD.gn b/browser/resources/history/BUILD.gn index 397701dc3b8f..f7fd77e1a210 100644 --- a/browser/resources/history/BUILD.gn +++ b/browser/resources/history/BUILD.gn @@ -3,49 +3,15 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. -import("//brave/resources/brave_grit.gni") -import("//chrome/common/features.gni") import("//tools/grit/preprocess_if_expr.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/generate_grd.gni") - -preprocess_folder = "preprocessed" -preprocess_manifest = "brave_preprocessed_manifest.json" - -brave_grit("resources") { - defines = chrome_grit_defines - - enable_input_discovery_for_gn_analyze = false - source = "$target_gen_dir/brave_history_resources.grd" - deps = [ ":build_grd" ] - - outputs = [ - "grit/brave_history_resources.h", - "grit/brave_history_resources_map.cc", - "grit/brave_history_resources_map.h", - "brave_history_resources.pak", - ] -} - -generate_grd("build_grd") { - grd_prefix = "brave_history" - out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" - input_files = [] - input_files_base_dir = rebase_path(".", "//") - - deps = [ ":preprocess" ] - manifest_files = - [ "$root_gen_dir/chrome/browser/resources/history/$preprocess_manifest" ] -} +import("./sources.gni") +# Move brave files to the place where chromium history page is compiled from. It should be the same directory +# that build_webui.gni uses after it performs its own preprocess_if_expr. Once chromium and brave frontend files +# are all in the same place, build_webui.gni will continue its typescript and rollup compile (etc.) from that +# directory. preprocess_if_expr("preprocess") { in_folder = "./" - out_folder = - "$root_gen_dir/chrome/browser/resources/history/$preprocess_folder" - out_manifest = - "$root_gen_dir/chrome/browser/resources/history/$preprocess_manifest" - in_files = [ - "brave_overrides/side_bar.js", - "brave_overrides/index.js", - ] + out_folder = "$root_gen_dir/chrome/browser/resources/history/preprocessed" + in_files = brave_history_local_files } diff --git a/browser/resources/history/brave_history_item.html b/browser/resources/history/brave_history_item.html new file mode 100644 index 000000000000..a87cc1c7b4b8 --- /dev/null +++ b/browser/resources/history/brave_history_item.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/ui/webui/resources/page_specific/history/brave_history_item.js b/browser/resources/history/brave_history_item.ts similarity index 53% rename from ui/webui/resources/page_specific/history/brave_history_item.js rename to browser/resources/history/brave_history_item.ts index 1cf3a1de844e..dd37080e6f62 100644 --- a/ui/webui/resources/page_specific/history/brave_history_item.js +++ b/browser/resources/history/brave_history_item.ts @@ -3,6 +3,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Convert to Polymer class and remove ts-nocheck + +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {getTemplate} from './brave_history_item.html.js' + Polymer({ is: 'brave-history-item', -}); + _template: getTemplate() +}) diff --git a/browser/resources/history/brave_overrides/index.js b/browser/resources/history/brave_overrides/index.ts similarity index 100% rename from browser/resources/history/brave_overrides/index.js rename to browser/resources/history/brave_overrides/index.ts diff --git a/browser/resources/history/brave_overrides/side_bar.js b/browser/resources/history/brave_overrides/side_bar.ts similarity index 88% rename from browser/resources/history/brave_overrides/side_bar.js rename to browser/resources/history/brave_overrides/side_bar.ts index 0fa788bab52c..522ccbbd061e 100644 --- a/browser/resources/history/brave_overrides/side_bar.js +++ b/browser/resources/history/brave_overrides/side_bar.ts @@ -3,8 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import {RegisterStyleOverride} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterStyleOverride} from 'chrome://resources/polymer_overriding.js' RegisterStyleOverride( 'history-side-bar', diff --git a/browser/resources/history/sources.gni b/browser/resources/history/sources.gni index 4132a0a4677a..089aa966af58 100644 --- a/browser/resources/history/sources.gni +++ b/browser/resources/history/sources.gni @@ -3,10 +3,20 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. -brave_deps_chrome_browser_resources_history_in_files = [ - "brave_overrides/side_bar.js", - "brave_overrides/index.js", +brave_history_web_component_files = [ "brave_history_item.ts" ] + +brave_history_non_web_component_files = [ + "brave_overrides/side_bar.ts", + "brave_overrides/index.ts", ] -brave_deps_chrome_browser_resources_history_extra_deps = +# Also include the .html sibling files +brave_history_local_files = + brave_history_web_component_files + brave_history_non_web_component_files +foreach(component_file, brave_history_web_component_files) { + brave_history_local_files += + [ string_replace(component_file, ".ts", ".html") ] +} + +brave_history_preprocess_extra_deps = [ "//brave/browser/resources/history:preprocess" ] diff --git a/browser/resources/settings/BUILD.gn b/browser/resources/settings/BUILD.gn index bab6b67e58f2..b6bf732c885e 100644 --- a/browser/resources/settings/BUILD.gn +++ b/browser/resources/settings/BUILD.gn @@ -3,25 +3,23 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. +import("//brave/browser/resources/settings/sources.gni") import("//brave/build/config.gni") import("//brave/components/brave_vpn/buildflags/buildflags.gni") import("//brave/components/brave_wayback_machine/buildflags/buildflags.gni") import("//brave/components/tor/buildflags/buildflags.gni") import("//brave/resources/brave_grit.gni") -import("//chrome/browser/resources/tools/optimize_webui.gni") import("//chrome/common/features.gni") import("//extensions/buildflags/buildflags.gni") -import("//third_party/closure_compiler/compile_js.gni") import("//tools/grit/preprocess_if_expr.gni") -import("//tools/polymer/html_to_js.gni") -import("//tools/polymer/polymer.gni") import("//ui/webui/resources/tools/generate_grd.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") preprocess_folder = "preprocessed" -preprocess_manifest = "brave_preprocessed_manifest.json" -preprocess_gen_manifest = "brave_preprocessed_gen_manifest.json" +# grit (and generate the GRD for) brave's own static resources, they don't need +# to be part of the build_webui.gni compile. +# TODO(petemill): It is no longer neccessary to make our own grd and pak, we can add to +# chromium's static_files list. brave_grit("resources") { defines = chrome_grit_defines defines += [ @@ -59,153 +57,23 @@ generate_grd("build_grd") { ] input_files_base_dir = rebase_path(".", "//") - deps = [ - ":preprocess", - ":preprocess_generated", - ] - manifest_files = [ - "$root_gen_dir/chrome/browser/resources/settings/$preprocess_manifest", - "$root_gen_dir/chrome/browser/resources/settings/$preprocess_gen_manifest", - ] + deps = [ ":preprocess" ] } +# Move brave files to the place where chromium settings page is compiled from. It should be the same directory +# that build_webui.gni uses after it performs its own preprocess_if_expr. Once chromium and brave frontend files +# are all in the same place, build_webui.gni will continue its typescript and rollup compile (etc.) from that +# directory. preprocess_if_expr("preprocess") { - defines = [ "enable_extensions=$enable_extensions" ] - in_folder = "./" - out_folder = - "$root_gen_dir/chrome/browser/resources/settings/$preprocess_folder" - out_manifest = - "$root_gen_dir/chrome/browser/resources/settings/$preprocess_manifest" - - # When adding new files, make sure to also add to sources.gni - in_files = [ - "brave_appearance_page/brave_appearance_browser_proxy.js", - "brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js", - "brave_overrides/about_page.js", - "brave_overrides/appearance_page.js", - "brave_overrides/basic_page.js", - "brave_overrides/clear_browsing_data_dialog.js", - "brave_overrides/config.js", - "brave_overrides/cookies_page.js", - "brave_overrides/default_browser_page.js", - "brave_overrides/icons.js", - "brave_overrides/import_data_dialog.js", - "brave_overrides/index.js", - "brave_overrides/page_visibility.js", - "brave_overrides/passwords_section.js", - "brave_overrides/payments_section.js", - "brave_overrides/people_page.js", - "brave_overrides/personalization_options.js", - "brave_overrides/printing_page.js", - "brave_overrides/privacy_page.js", - "brave_overrides/reset_profile_dialog.js", - "brave_overrides/safety_check_passwords_child.js", - "brave_overrides/search_page.js", - "brave_overrides/security_page.js", - "brave_overrides/settings_menu.js", - "brave_overrides/settings_section.js", - "brave_overrides/settings_ui.js", - "brave_overrides/site_details.js", - "brave_overrides/site_settings_page.js", - "brave_overrides/sync_account_control.js", - "brave_overrides/sync_controls.js", - "brave_reset_page/brave_reset_profile_dialog_behavior.js", - "brave_routes.js", - "brave_sync_page/brave_sync_browser_proxy.js", - "brave_tor_page/brave_tor_browser_proxy.js", - "default_brave_shields_page/brave_adblock_browser_proxy.js", - ] -} - -preprocess_if_expr("preprocess_generated") { - deps = [ ":web_modules" ] defines = [ "enable_tor=$enable_tor", "enable_brave_wayback_machine=$enable_brave_wayback_machine", "enable_brave_vpn=$enable_brave_vpn", "enable_extensions=$enable_extensions", ] - in_folder = target_gen_dir + in_folder = "./" out_folder = "$root_gen_dir/chrome/browser/resources/settings/$preprocess_folder" - out_manifest = - "$root_gen_dir/chrome/browser/resources/settings/$preprocess_gen_manifest" - - # When adding new files, make sure to also add to sources.gni - in_files = [ - "brave_appearance_page/brave_theme.js", - "brave_appearance_page/sidebar.js", - "brave_appearance_page/super_referral.js", - "brave_appearance_page/toolbar.js", - "brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.js", - "brave_ipfs_page/brave_ipfs_browser_proxy.m.js", - "brave_ipfs_page/brave_ipfs_page.js", - "brave_ipfs_page/change_ipfs_gateway_dialog.js", - "brave_ipfs_page/add_p2p_key_dialog.js", - "brave_ipfs_page/rotate_p2p_key_dialog.js", - "brave_ipfs_page/p2p_keys_subpage.m.js", - "brave_ipfs_page/ipfs_peers_subpage.m.js", - "brave_ipfs_page/add_ipfs_peer_dialog.js", - "brave_default_extensions_page/brave_default_extensions_browser_proxy.m.js", - "brave_default_extensions_page/brave_default_extensions_page.m.js", - "brave_help_tips_page/brave_help_tips_page.js", - "brave_icons.m.js", - "brave_new_tab_page/brave_new_tab_browser_proxy.m.js", - "brave_new_tab_page/brave_new_tab_page.m.js", - "brave_privacy_page/brave_personalization_options.m.js", - "brave_privacy_page/brave_privacy_page_browser_proxy.m.js", - "brave_rewards_page/brave_rewards_browser_proxy.m.js", - "brave_rewards_page/brave_rewards_page.js", - "brave_search_engines_page/brave_search_engines_page.js", - "brave_search_engines_page/brave_search_engines_page_browser_proxy.m.js", - "brave_sync_page/brave_sync_code_dialog.js", - "brave_sync_page/brave_sync_configure.js", - "brave_sync_page/brave_sync_page.js", - "brave_sync_page/brave_sync_setup.js", - "brave_sync_page/brave_sync_subpage.js", - "brave_tor_page/brave_tor_bridges_dialog.js", - "brave_tor_page/brave_tor_subpage.js", - "brave_wallet_page/add_wallet_network_dialog.js", - "brave_wallet_page/brave_wallet_browser_proxy.m.js", - "brave_wallet_page/brave_wallet_page.js", - "brave_wallet_page/wallet_networks_list.js", - "brave_wallet_page/wallet_networks_subpage.js", - "default_brave_shields_page/default_brave_shields_browser_proxy.m.js", - "default_brave_shields_page/default_brave_shields_page.js", - "default_brave_shields_page/brave_adblock_subpage.js", - "default_brave_shields_page/components/brave_adblock_subscribe_dropdown.js", - "default_brave_shields_page/components/brave_adblock_editor.js", - "getting_started_page/getting_started.js", - "social_blocking_page/social_blocking_page.m.js", - ] -} - -group("web_modules") { - public_deps = [ - # local targets - ":icons_module", - - # Sub-folder targets - "brave_appearance_page:web_modules", - "brave_clear_browsing_data_dialog:web_modules", - "brave_default_extensions_page:web_modules", - "brave_help_tips_page:web_modules", - "brave_ipfs_page:web_modules", - "brave_new_tab_page:web_modules", - "brave_privacy_page:web_modules", - "brave_rewards_page:web_modules", - "brave_search_engines_page:web_modules", - "brave_sync_page:web_modules", - "brave_tor_page:web_modules", - "brave_wallet_page:web_modules", - "default_brave_shields_page:web_modules", - "getting_started_page:web_modules", - "social_blocking_page:web_modules", - ] -} -polymer_modulizer("icons") { - js_file = "brave_icons.m.js" - html_file = "brave_icons.html" - html_type = "iron-iconset" + in_files = brave_settings_local_files } diff --git a/browser/resources/settings/brave_appearance_page/BUILD.gn b/browser/resources/settings/brave_appearance_page/BUILD.gn deleted file mode 100644 index 45c05547a955..000000000000 --- a/browser/resources/settings/brave_appearance_page/BUILD.gn +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//third_party/closure_compiler/compile_js.gni") -import("//tools/polymer/html_to_js.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -js_type_check("closure_compile_module") { - is_polymer3 = true - deps = [ - ":brave_appearance_browser_proxy", - ":brave_theme", - ":sidebar", - ":super_referral", - ":toolbar", - ] -} - -js_library("brave_appearance_browser_proxy") { - deps = [ "//ui/webui/resources/js:cr.m" ] - externs_list = [ - "$externs_path/chrome_send.js", - "$externs_path/management.js", - ] - extra_deps = [ ":templatize" ] -} - -js_library("brave_theme") { - deps = [ - ":brave_appearance_browser_proxy", - "//ui/webui/resources/js:cr.m", - "//ui/webui/resources/js:load_time_data.m", - "//ui/webui/resources/js:web_ui_listener_behavior.m", - ] - externs_list = [ "$externs_path/settings_private.js" ] - extra_deps = [ ":templatize" ] -} - -js_library("super_referral") { - deps = [ - "//ui/webui/resources/js:cr.m", - "//ui/webui/resources/js:i18n_behavior.m", - "//ui/webui/resources/js:load_time_data.m", - ] - externs_list = [ "$externs_path/settings_private.js" ] - extra_deps = [ ":templatize" ] -} - -js_library("toolbar") { - externs_list = [ "$externs_path/settings_private.js" ] - extra_deps = [ ":templatize" ] -} - -js_library("sidebar") { - externs_list = [ "$externs_path/settings_private.js" ] - extra_deps = [ ":templatize" ] -} - -# make modules -group("web_modules") { - public_deps = [ ":templatize" ] -} - -html_to_js("templatize") { - js_files = [ - "brave_theme.js", - "sidebar.js", - "super_referral.js", - "toolbar.js", - ] -} diff --git a/browser/resources/settings/brave_appearance_page/brave_appearance_browser_proxy.js b/browser/resources/settings/brave_appearance_page/brave_appearance_browser_proxy.js deleted file mode 100644 index 0f70254d5e51..000000000000 --- a/browser/resources/settings/brave_appearance_page/brave_appearance_browser_proxy.js +++ /dev/null @@ -1,39 +0,0 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ - -import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; - -/** @interface */ -export class BraveAppearanceBrowserProxy { - /** - * @return {!Promise} - */ - getBraveThemeList() {} - /** - * @return {!Promise} - */ - getBraveThemeType() {} - /** - * @param {Number} type - */ - setBraveThemeType(value) {} -} - -/** - * @implements {BraveAppearanceBrowserProxy} - */ -export class BraveAppearanceBrowserProxyImpl { - /** @override */ - getBraveThemeList() { - return new Promise(resolve => chrome.braveTheme.getBraveThemeList(resolve)) - } - getBraveThemeType() { - return sendWithPromise('getBraveThemeType'); - } - setBraveThemeType(value) { - chrome.send('setBraveThemeType', [value]); - } -} - -addSingletonGetter(BraveAppearanceBrowserProxyImpl); diff --git a/browser/resources/settings/brave_appearance_page/brave_appearance_browser_proxy.ts b/browser/resources/settings/brave_appearance_page/brave_appearance_browser_proxy.ts new file mode 100644 index 000000000000..d21b9071ed7c --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/brave_appearance_browser_proxy.ts @@ -0,0 +1,46 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; + +/** @interface */ +export interface BraveAppearanceBrowserProxy { + /** + * Returns JSON string with shape `chrome.braveTheme.ThemeItem[]` + */ + getBraveThemeList(): Promise + /** + * Index of current ThemeItem + */ + getBraveThemeType(): Promise + /** + * + * @param value index of ThemeItem + */ + setBraveThemeType(value: number): void +} + +/** + * @implements {BraveAppearanceBrowserProxy} + */ +export class BraveAppearanceBrowserProxyImpl implements + BraveAppearanceBrowserProxy { + getBraveThemeList() { + return new Promise(resolve => chrome.braveTheme.getBraveThemeList(resolve)) + } + + getBraveThemeType() { + return sendWithPromise('getBraveThemeType'); + } + + setBraveThemeType(value: number) { + chrome.send('setBraveThemeType', [value]); + } + + static getInstance(): BraveAppearanceBrowserProxyImpl { + return instance || (instance = new BraveAppearanceBrowserProxyImpl()) + } +} + +let instance: BraveAppearanceBrowserProxy|null = null diff --git a/browser/resources/settings/brave_appearance_page/brave_theme.js b/browser/resources/settings/brave_appearance_page/brave_theme.js deleted file mode 100644 index f72ca4188695..000000000000 --- a/browser/resources/settings/brave_appearance_page/brave_theme.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; -import {routes} from '../route.js'; -import {Router} from '../router.js'; -import 'chrome://resources/cr_elements/md_select_css.m.js'; -import '../settings_shared.css.js'; -import '../settings_vars.css.js'; -import {loadTimeData} from "../i18n_setup.js" -import {BraveAppearanceBrowserProxy, BraveAppearanceBrowserProxyImpl} from './brave_appearance_browser_proxy.js'; - -/** - * 'settings-brave-appearance-theme' is the settings page area containing - * brave's appearance related settings that located at the top of appearance - * area. - */ -Polymer({ - is: 'settings-brave-appearance-theme', - - _template: html`{__html_template__}`, - - behaviors: [ - WebUIListenerBehavior, - ], - - properties: { - braveThemeList_: Array, - braveThemeType_: Number, - }, - - /** @private {?settings.BraveAppearanceBrowserProxy} */ - browserProxy_: null, - - observers: [ - 'updateSelected_(braveThemeType_, braveThemeList_)', - ], - - /** @override */ - created: function() { - this.browserProxy_ = BraveAppearanceBrowserProxyImpl.getInstance(); - }, - - /** @override */ - ready: function() { - this.addWebUIListener('brave-theme-type-changed', (type) => { - this.braveThemeType_ = type; - }) - this.browserProxy_.getBraveThemeList().then(list => { - this.braveThemeList_ = JSON.parse(list); - }) - this.browserProxy_.getBraveThemeType().then(type => { - this.braveThemeType_ = type; - }) - }, - - onBraveThemeTypeChange_: function() { - this.browserProxy_.setBraveThemeType(Number(this.$.braveThemeType.value)); - }, - - braveThemeTypeEqual_: function(theme1, theme2) { - return theme1 === theme2; - }, - - onThemeTap_: function() { - Router.getInstance().navigateTo(routes.THEMES); - }, - - // Wait for the dom-repeat to populate the #value so the correct option gets selected. - updateSelected_: function() { - this.async(() => { - this.$.braveThemeType.value = this.braveThemeType_; - }); - }, - - useThemesSubPage_: function() { - return loadTimeData.valueExists('superReferralThemeName') && - loadTimeData.getString('superReferralThemeName') !== ''; - } -}); diff --git a/browser/resources/settings/brave_appearance_page/brave_theme.ts b/browser/resources/settings/brave_appearance_page/brave_theme.ts new file mode 100644 index 000000000000..fd98324427d5 --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/brave_theme.ts @@ -0,0 +1,93 @@ +// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. + +import {PolymerElement, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import {WebUIListenerMixin, WebUIListenerMixinInterface} from 'chrome://resources/js/web_ui_listener_mixin.js' +import {routes} from '../route.js' +import {Router} from '../router.js' +import 'chrome://resources/cr_elements/md_select.css.js'; +import '../settings_shared.css.js' +import '../settings_vars.css.js' +import {loadTimeData} from "../i18n_setup.js" +import {BraveAppearanceBrowserProxy, BraveAppearanceBrowserProxyImpl} from './brave_appearance_browser_proxy.js' +import {BaseMixin} from '../base_mixin.js' +import {getTemplate} from './brave_theme.html.js' + +export interface SettingsBraveAppearanceThemeElement { + $: { + braveThemeType: HTMLSelectElement + } +} + +const SettingsBraveAppearanceThemeElementBase = WebUIListenerMixin(BaseMixin(PolymerElement)) as { + new (): PolymerElement & WebUIListenerMixinInterface +} + +/** + * 'settings-brave-appearance-theme' is the settings page area containing + * brave's appearance related settings that located at the top of appearance + * area. + */ +export class SettingsBraveAppearanceThemeElement extends SettingsBraveAppearanceThemeElementBase { + static get is() { + return 'settings-brave-appearance-theme' + } + + static get template() { + return getTemplate() + } + + static get observers() { + return [ + 'updateSelected_(braveThemeType_, braveThemeList_)', + ] + } + + browserProxy_: BraveAppearanceBrowserProxy = BraveAppearanceBrowserProxyImpl.getInstance() + braveThemeList_: chrome.braveTheme.ThemeItem[] + braveThemeType_: number // index of current theme type in braveThemeList_ + + override ready() { + super.ready() + + this.addWebUIListener('brave-theme-type-changed', (type: number) => { + this.braveThemeType_ = type; + }) + this.browserProxy_.getBraveThemeList().then((list) => { + this.braveThemeList_ = JSON.parse(list) as chrome.braveTheme.ThemeItem[]; + }) + this.browserProxy_.getBraveThemeType().then(type => { + this.braveThemeType_ = type; + }) + } + + private onBraveThemeTypeChange_() { + this.browserProxy_.setBraveThemeType(Number(this.$.braveThemeType.value)) + } + + private braveThemeTypeEqual_(theme1: string, theme2: string) { + return theme1 === theme2 + } + + private onThemeTap_() { + Router.getInstance().navigateTo(routes.THEMES) + } + + private updateSelected_() { + // Wait for the dom-repeat to populate the #value so the correct option gets selected. + setTimeout(() => { + this.$.braveThemeType.value = String(this.braveThemeType_) + }) + } + + useThemesSubPage_() { + return loadTimeData.valueExists('superReferralThemeName') && + loadTimeData.getString('superReferralThemeName') !== '' + } +} + +customElements.define( + SettingsBraveAppearanceThemeElement.is, SettingsBraveAppearanceThemeElement) diff --git a/browser/resources/settings/brave_appearance_page/sidebar.html b/browser/resources/settings/brave_appearance_page/sidebar.html index 97025ba349a5..300ccdca684f 100644 --- a/browser/resources/settings/brave_appearance_page/sidebar.html +++ b/browser/resources/settings/brave_appearance_page/sidebar.html @@ -17,5 +17,5 @@ pref="{{prefs.brave.sidebar.sidebar_show_option}}" on-settings-control-change="onShowOptionChanged_" menu-options="[[sidebarShowOptions_]]"> - + diff --git a/browser/resources/settings/brave_appearance_page/sidebar.js b/browser/resources/settings/brave_appearance_page/sidebar.js deleted file mode 100644 index 1a924c004ad2..000000000000 --- a/browser/resources/settings/brave_appearance_page/sidebar.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. - -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import '../settings_shared.css.js'; -import '../settings_vars.css.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js' - -/** - * 'settings-brave-appearance-sidebar' is the settings page area containing - * brave's sidebar settings in appearance settings. - * This is separated from 'settings-brave-appearance-toolbar' because sidebar - * option is located below the home button option. - */ -Polymer({ - is: 'settings-brave-appearance-sidebar', - - _template: html`{__html_template__}`, - - behaviors: [I18nBehavior], - - properties: { - sidebarShowOptions_: { - readOnly: true, - type: Array, - value() { - return [ - {value: 0, name: this.i18n('appearanceSettingsShowOptionAlways')}, - {value: 1, name: this.i18n('appearanceSettingsShowOptionMouseOver')}, - {value: 3, name: this.i18n('appearanceSettingsShowOptionNever')}, - ]; - }, - }, - - sidebarShowEnabledLabel_: { - readOnly: false, - type: String, - }, - }, - - observers: [ - 'onShowOptionChanged_(prefs.brave.sidebar.sidebar_show_option.value)', - ], - - computeSidebarShowOptionSubLabel_(option) { - return option === 3 ? this.i18n('appearanceSettingsSidebarDisabledDesc') - : this.i18n('appearanceSettingsSidebarEnabledDesc'); - }, - - onShowOptionChanged_() { - this.sidebarShowEnabledLabel_ = - this.computeSidebarShowOptionSubLabel_(this.getCurrentSidebarOption_()); - }, - - getCurrentSidebarOption_() { - return this.get('prefs.brave.sidebar.sidebar_show_option.value'); - }, -}); diff --git a/browser/resources/settings/brave_appearance_page/sidebar.ts b/browser/resources/settings/brave_appearance_page/sidebar.ts new file mode 100644 index 000000000000..15d8b2e8616a --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/sidebar.ts @@ -0,0 +1,62 @@ +// Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. + +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import {I18nMixin, I18nMixinInterface} from 'chrome://resources/js/i18n_mixin.js' +import {PrefsMixin, PrefsMixinInterface} from '../prefs/prefs_mixin.js' +import '../settings_shared.css.js' +import '../settings_vars.css.js' +import {getTemplate} from './sidebar.html.js' + +const SettingsBraveAppearanceSidebarElementBase = PrefsMixin(I18nMixin(PolymerElement)) as { + new (): PolymerElement & I18nMixinInterface & PrefsMixinInterface +} + +/** + * 'settings-brave-appearance-sidebar' is the settings page area containing + * brave's sidebar settings in appearance settings. + * This is separated from 'settings-brave-appearance-toolbar' because sidebar + * option is located below the home button option. + */ +export class SettingsBraveAppearanceSidebarElement extends SettingsBraveAppearanceSidebarElementBase { + static get is() { + return 'settings-brave-appearance-sidebar' + } + + static get template() { + return getTemplate() + } + + + static get properties() { + return { + sidebarShowEnabledLabel_: { + readOnly: false, + type: String, + }, + } + } + + static get observers(){ + return [ + 'onShowOptionChanged_(prefs.brave.sidebar.sidebar_show_option.value)', + ] + } + + private sidebarShowOptions_ = [ + {value: 0, name: this.i18n('appearanceSettingsShowOptionAlways')}, + {value: 1, name: this.i18n('appearanceSettingsShowOptionMouseOver')}, + {value: 3, name: this.i18n('appearanceSettingsShowOptionNever')}, + ] + private sidebarShowEnabledLabel_: string + + private onShowOptionChanged_() { + this.sidebarShowEnabledLabel_ = (this.get('prefs.brave.sidebar.sidebar_show_option.value') === 3) + ? this.i18n('appearanceSettingsSidebarDisabledDesc') + : this.i18n('appearanceSettingsSidebarEnabledDesc') + } +} + +customElements.define(SettingsBraveAppearanceSidebarElement.is, SettingsBraveAppearanceSidebarElement) diff --git a/browser/resources/settings/brave_appearance_page/super_referral.html b/browser/resources/settings/brave_appearance_page/super_referral.html index c028ce54bef2..b3e936fd1fda 100644 --- a/browser/resources/settings/brave_appearance_page/super_referral.html +++ b/browser/resources/settings/brave_appearance_page/super_referral.html @@ -58,7 +58,7 @@ diff --git a/browser/resources/settings/brave_appearance_page/super_referral.js b/browser/resources/settings/brave_appearance_page/super_referral.js deleted file mode 100644 index 12802cf79d00..000000000000 --- a/browser/resources/settings/brave_appearance_page/super_referral.js +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {assert} from 'chrome://resources/js/assert.m.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; -import {loadTimeData} from "../i18n_setup.js" -import {AppearanceBrowserProxyImpl} from '../appearance_page/appearance_browser_proxy.js'; - -/** - * ID for autogenerated themes. Should match - * |ThemeService::kAutogeneratedThemeID|. - */ -const AUTOGENERATED_THEME_ID = 'autogenerated_theme_id'; - -/** - * 'settings-brave-appearance-theme' is the settings page area containing - * brave's themes settings. - */ -Polymer({ - is: 'settings-brave-appearance-super-referral', - - _template: html`{__html_template__}`, - - behaviors: [I18nBehavior], - - properties: { - /** @private */ - themeSublabel_: String, - - /** @private */ - themeUrl_: String, - - /** @private */ - useSystemTheme_: { - type: Boolean, - value: false, // Can only be true on Linux, but value exists everywhere. - }, - - // Sync with ThemesOption enum in ViewCounterService - /** @private */ - themeValues_: { - readOnly: true, - type: Object, - value: { - DEFAULT: 0, - SUPER_REFERRAL: 1, - }, - }, - }, - - /** @private {?settings.BraveAppearanceBrowserProxy} */ - appearanceBrowserProxy_: null, - - observers: [ - 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)', - - // - // NOTE: this pref only exists on Linux. - 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)', - // - ], - - /** @override */ - created: function() { - this.appearanceBrowserProxy_ = - AppearanceBrowserProxyImpl.getInstance(); - }, - - getSuperReferralThemeName_() { - return loadTimeData.getString('superReferralThemeName') - }, - /** - * Open URL for either current theme or the theme gallery. - * @private - */ - openThemeUrl_() { - window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); - }, - - /** @private */ - onUseDefaultTap_() { - this.appearanceBrowserProxy_.useDefaultTheme(); - }, - - // - /** - * @param {boolean} useSystemTheme - * @private - */ - useSystemThemePrefChanged_(useSystemTheme) { - this.useSystemTheme_ = useSystemTheme; - }, - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @return {boolean} Whether to show the "USE CLASSIC" button. - * @private - */ - showUseClassic_(themeId, useSystemTheme) { - return !!themeId || useSystemTheme; - }, - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @return {boolean} Whether to show the "USE GTK+" button. - * @private - */ - showUseSystem_(themeId, useSystemTheme) { - return (!!themeId || !useSystemTheme) && - !this.appearanceBrowserProxy_.isChildAccount(); - }, - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @return {boolean} Whether to show the secondary area where "USE CLASSIC" - * and "USE GTK+" buttons live. - * @private - */ - showThemesSecondary_(themeId, useSystemTheme) { - return this.showUseClassic_(themeId, useSystemTheme) || - this.showUseSystem_(themeId, useSystemTheme); - }, - - /** @private */ - onUseSystemTap_() { - this.appearanceBrowserProxy_.useSystemTheme(); - }, - // - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @private - */ - themeChanged_(themeId, useSystemTheme) { - if (this.prefs == undefined || useSystemTheme == undefined) { - return; - } - - if (themeId.length > 0 && themeId != AUTOGENERATED_THEME_ID) { - assert(!useSystemTheme); - - this.appearanceBrowserProxy_.getThemeInfo(themeId).then(info => { - this.themeSublabel_ = info.name; - }); - - this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; - return; - } - - this.themeUrl_ = ''; - - if (themeId == AUTOGENERATED_THEME_ID) { - this.themeSublabel_ = this.i18n('chromeColors'); - return; - } - - let i18nId; - // - i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; - // - // - i18nId = 'chooseFromWebStore'; - // - this.themeSublabel_ = this.i18n(i18nId); - }, - - /** - * Open URL for either current theme or the theme gallery. - * @private - */ - openThemeUrl_() { - window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); - }, - - /** @private */ - onUseDefaultTap_() { - this.appearanceBrowserProxy_.useDefaultTheme(); - }, - - // - /** - * @param {boolean} useSystemTheme - * @private - */ - useSystemThemePrefChanged_(useSystemTheme) { - this.useSystemTheme_ = useSystemTheme; - }, - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @return {boolean} Whether to show the "USE CLASSIC" button. - * @private - */ - showUseClassic_(themeId, useSystemTheme) { - return !!themeId || useSystemTheme; - }, - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @return {boolean} Whether to show the "USE GTK+" button. - * @private - */ - showUseSystem_(themeId, useSystemTheme) { - return (!!themeId || !useSystemTheme) && - !this.appearanceBrowserProxy_.isChildAccount(); - }, - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @return {boolean} Whether to show the secondary area where "USE CLASSIC" - * and "USE GTK+" buttons live. - * @private - */ - showThemesSecondary_(themeId, useSystemTheme) { - return this.showUseClassic_(themeId, useSystemTheme) || - this.showUseSystem_(themeId, useSystemTheme); - }, - - /** @private */ - onUseSystemTap_() { - this.appearanceBrowserProxy_.useSystemTheme(); - }, - // - - /** - * @param {string} themeId - * @param {boolean} useSystemTheme - * @private - */ - themeChanged_(themeId, useSystemTheme) { - if (this.prefs == undefined || useSystemTheme == undefined) { - return; - } - - if (themeId.length > 0 && themeId != AUTOGENERATED_THEME_ID) { - assert(!useSystemTheme); - - this.appearanceBrowserProxy_.getThemeInfo(themeId).then(info => { - this.themeSublabel_ = info.name; - }); - - this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; - return; - } - - this.themeUrl_ = ''; - - if (themeId == AUTOGENERATED_THEME_ID) { - this.themeSublabel_ = this.i18n('chromeColors'); - return; - } - - let i18nId; - // - i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; - // - // - i18nId = 'chooseFromWebStore'; - // - this.themeSublabel_ = this.i18n(i18nId); - } -}); - diff --git a/browser/resources/settings/brave_appearance_page/super_referral.ts b/browser/resources/settings/brave_appearance_page/super_referral.ts new file mode 100644 index 000000000000..0fdf8eb73b24 --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/super_referral.ts @@ -0,0 +1,162 @@ +// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. + +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {I18nMixin, I18nMixinInterface} from 'chrome://resources/js/i18n_mixin.js' +import {loadTimeData} from "../i18n_setup.js" +import {AppearanceBrowserProxy, AppearanceBrowserProxyImpl} from '../appearance_page/appearance_browser_proxy.js'; +import {getTemplate} from './super_referral.html.js' + +/** + * ID for autogenerated themes. Should match + * |ThemeService::kAutogeneratedThemeID|. + */ +const AUTOGENERATED_THEME_ID = 'autogenerated_theme_id'; + +const SettingsBraveAppearanceSuperReferralElementBase = I18nMixin(PolymerElement) as { + new (): PolymerElement & I18nMixinInterface +} + +/** + * 'settings-brave-appearance-theme' is the settings page area containing + * brave's themes settings. + */ + +export class SettingsBraveAppearanceSuperReferralElement extends + SettingsBraveAppearanceSuperReferralElementBase { + static get is() { + return 'settings-brave-appearance-super-referral' + } + + static get template() { + return getTemplate() + } + + static get properties() { + return { + /** + * Preferences state. + */ + prefs: { + type: Object, + notify: true, + }, + + useSystemTheme_: { + type: Boolean, + value: false, // Can only be true on Linux, but value exists everywhere. + } + } + } + + static get observers() { + return [ + 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)', + + // + // NOTE: this pref only exists on Linux. + 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)', + // + ] + } + + prefs: any + private useSystemTheme_: boolean + + private themeUrl_: string + private themeSublabel_: string + // Sync with ThemesOption enum in ViewCounterService + private themeValues_ = { + DEFAULT: 0, + SUPER_REFERRAL: 1 + } + private appearanceBrowserProxy_: AppearanceBrowserProxy = AppearanceBrowserProxyImpl.getInstance() + + + private getSuperReferralThemeName_() { + return loadTimeData.getString('superReferralThemeName') + } + /** + * Open URL for either current theme or the theme gallery. + */ + private openThemeUrl_() { + window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); + } + + private onUseDefaultTap_() { + this.appearanceBrowserProxy_.useDefaultTheme(); + } + + // + private useSystemThemePrefChanged_(useSystemTheme: boolean) { + this.useSystemTheme_ = useSystemTheme; + } + + /** + * Whether to show the "USE CLASSIC" button. + */ + private showUseClassic_(themeId: string, useSystemTheme: boolean): boolean { + return !!themeId || useSystemTheme; + } + + /** + * Whether to show the "USE GTK+" button. + */ + private showUseSystem_(themeId: string, useSystemTheme: boolean) { + return (!!themeId || !useSystemTheme) && + !this.appearanceBrowserProxy_.isChildAccount(); + } + + /** + * Whether to show the secondary area where "USE CLASSIC" + * and "USE GTK+" buttons live. + */ + private showThemesSecondary_(themeId: string, useSystemTheme: boolean) { + return this.showUseClassic_(themeId, useSystemTheme) || + this.showUseSystem_(themeId, useSystemTheme); + } + + private onUseSystemTap_() { + this.appearanceBrowserProxy_.useGtkTheme(); + } + // + + private themeChanged_(themeId: string, useSystemTheme: boolean) { + if (this.prefs == undefined || useSystemTheme == undefined) { + return; + } + + if (themeId.length > 0 && themeId != AUTOGENERATED_THEME_ID) { + assert(!useSystemTheme); + + this.appearanceBrowserProxy_.getThemeInfo(themeId).then(info => { + this.themeSublabel_ = info.name; + }); + + this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; + return; + } + + this.themeUrl_ = ''; + + if (themeId == AUTOGENERATED_THEME_ID) { + this.themeSublabel_ = this.i18n('chromeColors'); + return; + } + + let i18nId; + // + i18nId = useSystemTheme ? 'gtkTheme' : 'classicTheme'; + // + // + i18nId = 'chooseFromWebStore'; + // + this.themeSublabel_ = this.i18n(i18nId); + } +} + +customElements.define(SettingsBraveAppearanceSuperReferralElement.is, SettingsBraveAppearanceSuperReferralElement) + diff --git a/browser/resources/settings/brave_appearance_page/toolbar.js b/browser/resources/settings/brave_appearance_page/toolbar.js deleted file mode 100644 index c57c1d028ca8..000000000000 --- a/browser/resources/settings/brave_appearance_page/toolbar.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {loadTimeData} from "../i18n_setup.js" -import '../settings_shared.css.js'; -import '../settings_vars.css.js'; -import { I18nBehavior } from 'chrome://resources/js/i18n_behavior.m.js' - -/** - * 'settings-brave-appearance-toolbar' is the settings page area containing - * brave's appearance settings related to the toolbar. - */ -Polymer({ - is: 'settings-brave-appearance-toolbar', - - _template: html`{__html_template__}`, - - behaviors: [I18nBehavior], - - properties: { - tabTooltipModes_: { - readOnly: true, - type: Array, - value() { - return [ - { value: 1, name: this.i18n('appearanceSettingsTabHoverModeCard') }, - { - value: 2, - name: this.i18n('appearanceSettingsTabHoverModeCardWithPreview') - }, - { value: 0, name: this.i18n('appearanceSettingsTabHoverModeTooltip') } - ] - } - } - }, - - showBraveVPNOption_: function () { - return loadTimeData.getBoolean('isBraveVPNEnabled') - } -}) diff --git a/browser/resources/settings/brave_appearance_page/toolbar.ts b/browser/resources/settings/brave_appearance_page/toolbar.ts new file mode 100644 index 000000000000..d42690469feb --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/toolbar.ts @@ -0,0 +1,63 @@ +// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. + +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {I18nMixin, I18nMixinInterface} from 'chrome://resources/js/i18n_mixin.js' +import {loadTimeData} from "../i18n_setup.js" +import '../settings_shared.css.js'; +import '../settings_vars.css.js'; +import {getTemplate} from './toolbar.html.js' + +const SettingsBraveAppearanceToolbarElementBase = I18nMixin(PolymerElement) as { + new (): PolymerElement & I18nMixinInterface +} + +/** + * 'settings-brave-appearance-toolbar' is the settings page area containing + * brave's appearance settings related to the toolbar. + */ +class SettingsBraveAppearanceToolbarElement extends SettingsBraveAppearanceToolbarElementBase { + static get is() { + return 'settings-brave-appearance-toolbar' + } + + static get template() { + return getTemplate() + } + + // static get properties() { + // return { + // tabTooltipModes_: { + // readOnly: true, + // type: Array, + // value() { + // return [ + // { value: 1, name: this.i18n('appearanceSettingsTabHoverModeCard') }, + // { + // value: 2, + // name: this.i18n('appearanceSettingsTabHoverModeCardWithPreview') + // }, + // { value: 0, name: this.i18n('appearanceSettingsTabHoverModeTooltip') } + // ] + // } + // } + // } + // } + + private tabTooltipModes_ = [ + { value: 1, name: this.i18n('appearanceSettingsTabHoverModeCard') }, + { + value: 2, + name: this.i18n('appearanceSettingsTabHoverModeCardWithPreview') + }, + { value: 0, name: this.i18n('appearanceSettingsTabHoverModeTooltip') } + ] + + private showBraveVPNOption_() { + return loadTimeData.getBoolean('isBraveVPNEnabled') + } +} + +customElements.define(SettingsBraveAppearanceToolbarElement.is, SettingsBraveAppearanceToolbarElement) diff --git a/browser/resources/settings/brave_clear_browsing_data_dialog/BUILD.gn b/browser/resources/settings/brave_clear_browsing_data_dialog/BUILD.gn deleted file mode 100644 index 9f916205481d..000000000000 --- a/browser/resources/settings/brave_clear_browsing_data_dialog/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") - -group("web_modules") { - public_deps = [ - ":templatize", - ] -} - -html_to_js("templatize") { - js_files = [ - "brave_clear_browsing_data_on_exit_page.js", - ] -} diff --git a/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js b/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.ts similarity index 72% rename from browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js rename to browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.ts index 478182c5da1a..27a5e25e5776 100644 --- a/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js +++ b/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.ts @@ -1,46 +1,51 @@ +// @ts-nocheck /* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */ + * you can obtain one at http://mozilla.org/MPL/2.0/. */ -import "./brave_clear_browsing_data_on_exit_page.js" -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import "./brave_clear_browsing_data_on_exit_page.js" import {loadTimeData} from "../i18n_setup.js" -import {I18nBehavior} from "chrome://resources/js/i18n_behavior.m.js" +import {WebUIListenerMixin} from 'chrome://resources/js/web_ui_listener_mixin.js'; +import {SettingsClearBrowsingDataDialogElement} from '../clear_browsing_data_dialog/clear_browsing_data_dialog.js' +import type {SettingsClearBrowsingDataDialogElement as BraveSettingsClearBrowsingDataDialogElement} from '../clear_browsing_data_dialog/clear_browsing_data_dialog.js' -const BraveClearBrowsingDataOnExitBehaviorImpl = { - - ready: function() { +const BaseElement = WebUIListenerMixin(SettingsClearBrowsingDataDialogElement) +export class BraveSettingsClearBrowsingDataDialogElement extends BaseElement { + ready() { + super.ready() this.addOnExitElements_(); this.addWebUIListener( - 'update-counter-text', this.updateOnExitCountersText.bind(this)); - }, + 'update-counter-text', this.updateOnExitCountersText.bind(this)); + } - attached: function() { + attached() { + super.attached() this.listen(this.$.tabs, 'selected-item-changed', - 'onSelectedTabChanged_'); + 'onSelectedTabChanged_'); this.listen(this.$$('#on-exit-tab'), 'clear-data-on-exit-page-change', - 'updateSaveButtonState_'); + 'updateSaveButtonState_'); this.listen(this.$$('#saveOnExitSettingsConfirm'), 'click', - 'saveOnExitSettings_'); - }, + 'saveOnExitSettings_'); + } - detached: function() { + detached() { + super.detached() this.unlisten(this.$.tabs, 'selected-item-changed', - 'onSelectedTabChanged_'); + 'onSelectedTabChanged_'); this.unlisten(this.$$('#on-exit-tab'), 'clear-data-on-exit-page-change', - 'updateSaveButtonState_'); + 'updateSaveButtonState_'); this.unlisten(this.$$('#saveOnExitSettingsConfirm'), 'click', - 'saveOnExitSettings_'); - }, + 'saveOnExitSettings_'); + } /** * Adds OnExit tab and Save button to the DOM. * @private */ - addOnExitElements_: function() { + addOnExitElements_() { // Append On exit tab to tab selector. this.tabsNames_.push(loadTimeData.getString('onExitPageTitle')); // Append On exit tab page. @@ -58,7 +63,7 @@ const BraveClearBrowsingDataOnExitBehaviorImpl = { saveButton.innerText = this.i18n('save'); this.$.clearBrowsingDataConfirm.parentNode.appendChild( saveButton); - }, + } /** * Updates the text of a browsing data counter corresponding to the given @@ -67,18 +72,18 @@ const BraveClearBrowsingDataOnExitBehaviorImpl = { * @param {string} text The text with which to update the counter * @private */ - updateOnExitCountersText: function(prefName, text) { + updateOnExitCountersText(prefName, text) { // Data type deletion preferences are named "browser.clear_data.". // Strip the common prefix, i.e. use only "". const matches = prefName.match(/^browser\.clear_data\.(\w+)$/); this.$$('#on-exit-tab').setCounter(matches[1], text); - }, + } /** * Updates Clear and Save buttons visibility based on the selected tab. * @private */ - onSelectedTabChanged_: function () { + onSelectedTabChanged_() { const tab = this.$.tabs.selectedItem; if (!tab) { return; @@ -86,22 +91,22 @@ const BraveClearBrowsingDataOnExitBehaviorImpl = { const isOnExitTab = (this.$.tabs.selectedItem.id == 'on-exit-tab'); this.$.clearBrowsingDataConfirm.hidden = isOnExitTab; this.$$('#saveOnExitSettingsConfirm').hidden = !isOnExitTab; - }, + } /** * Updates Save button enabled state based on on-exit-tab's changed state. * @private */ - updateSaveButtonState_: function () { + updateSaveButtonState_() { this.$$('#saveOnExitSettingsConfirm').disabled = !this.$$('#on-exit-tab').isModified; - }, + } /** * Saves on exit settings selections. * @private */ - saveOnExitSettings_: function () { + saveOnExitSettings_() { const changed = this.$$('#on-exit-tab').getChangedSettings(); changed.forEach((change) => { this.set('prefs.' + change.key + '.value', change.value); @@ -110,10 +115,5 @@ const BraveClearBrowsingDataOnExitBehaviorImpl = { if (!this.clearingInProgress_) { this.$.clearBrowsingDataDialog.close(); } - }, -}; - -// Extend I18nBehavior so that we can use i18n. -export const BraveClearBrowsingDataOnExitBehavior = [ - BraveClearBrowsingDataOnExitBehaviorImpl -] + } +} diff --git a/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.js b/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.ts similarity index 81% rename from browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.js rename to browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.ts index be00f3ef8ebc..d6f5ab9a2aec 100644 --- a/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.js +++ b/browser/resources/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.ts @@ -3,18 +3,19 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +// @ts-nocheck + +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {loadTimeData} from '../i18n_setup.js'; import '../settings_shared.css.js'; import '../settings_vars.css.js'; import '../controls/settings_checkbox.js'; - -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {getTemplate} from './brave_clear_browsing_data_on_exit_page.html.js' Polymer({ is: 'settings-brave-clear-browsing-data-on-exit-page', - _template: html`{__html_template__}`, + _template: getTemplate(), properties: { prefs: { @@ -46,12 +47,12 @@ Polymer({ listeners: {'settings-boolean-control-change': 'updateModified_'}, - setCounter: function (counter, text) { + setCounter: function (counter: string, text: string) { this.set('counters.' + counter, text); }, getChangedSettings: function () { - let changed = []; + let changed: {key: string, value: boolean}[] = []; const boxes = this.$.checkboxes.querySelectorAll('settings-checkbox'); boxes.forEach((checkbox) => { if (checkbox.checked != this.get(checkbox.pref.key, this.prefs).value) { @@ -61,7 +62,7 @@ Polymer({ return changed; }, - updateModified_: function (checkbox) { + updateModified_: function () { let modified = false; const boxes = this.$.checkboxes.querySelectorAll('settings-checkbox'); for (let checkbox of boxes) { diff --git a/browser/resources/settings/brave_default_extensions_page/BUILD.gn b/browser/resources/settings/brave_default_extensions_page/BUILD.gn deleted file mode 100644 index d4199560ea7d..000000000000 --- a/browser/resources/settings/brave_default_extensions_page/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -group("web_modules") { - public_deps = [ - ":brave_default_extensions_page_module", - ":modules", - ] -} - -polymer_modulizer("brave_default_extensions_page") { - js_file = "brave_default_extensions_page.js" - html_file = "brave_default_extensions_page.html" - html_type = "dom-module" - auto_imports = settings_auto_imports + [ "brave/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.html|BraveDefaultExtensionsBrowserProxy, BraveDefaultExtensionsBrowserProxyImpl" ] - namespace_rewrites = settings_namespace_rewrites -} - -js_modulizer("modules") { - input_files = [ "brave_default_extensions_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} diff --git a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.html b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.html deleted file mode 100644 index fe9dcf805023..000000000000 --- a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.js b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.js deleted file mode 100644 index e83a9f0461b3..000000000000 --- a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.js +++ /dev/null @@ -1,74 +0,0 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ - -// clang-format off -// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; -// clang-format on - -cr.define('settings', function () { - /** @interface */ - /* #export */ class BraveDefaultExtensionsBrowserProxy { - /** - * @param {boolean} value name. - */ - setWebTorrentEnabled (value) {} - setHangoutsEnabled (value) {} - setWidevineEnabled() {} - isWidevineEnabled() {} - getRestartNeeded () {} - wasSignInEnabledAtStartup () {} - isMediaRouterEnabled () {} - getDecentralizedDnsResolveMethodList() {} - } - - /** - * @implements {settings.BraveDefaultExtensionsBrowserProxy} - */ - /* #export */ class BraveDefaultExtensionsBrowserProxyImpl { - /** @override */ - setWebTorrentEnabled (value) { - chrome.send('setWebTorrentEnabled', [value]) - } - - setHangoutsEnabled (value) { - chrome.send('setHangoutsEnabled', [value]) - } - - setMediaRouterEnabled (value) { - chrome.send('setMediaRouterEnabled', [value]) - } - - setWidevineEnabled (value) { - chrome.send('setWidevineEnabled', [value]) - } - - isWidevineEnabled () { - return cr.sendWithPromise('isWidevineEnabled') - } - - getRestartNeeded () { - return cr.sendWithPromise('getRestartNeeded') - } - - wasSignInEnabledAtStartup () { - return loadTimeData.getBoolean('signInAllowedOnNextStartupInitialValue') - } - - isMediaRouterEnabled () { - return loadTimeData.getBoolean('isMediaRouterEnabled') - } - - getDecentralizedDnsResolveMethodList () { - return cr.sendWithPromise('getDecentralizedDnsResolveMethodList') - } - } - - cr.addSingletonGetter(BraveDefaultExtensionsBrowserProxyImpl) - - // #cr_define_end - return { - BraveDefaultExtensionsBrowserProxy, - BraveDefaultExtensionsBrowserProxyImpl - } -}) diff --git a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.ts b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.ts new file mode 100644 index 000000000000..e7cd66d324c9 --- /dev/null +++ b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_browser_proxy.ts @@ -0,0 +1,73 @@ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js' +import {loadTimeData} from '../i18n_setup.js'; + +export interface BraveDefaultExtensionsBrowserProxy { + setWebTorrentEnabled(value: boolean): void + setHangoutsEnabled(value: boolean): void + setWidevineEnabled(value: boolean): void + setMediaRouterEnabled(value: boolean): void + isWidevineEnabled(): Promise + getRestartNeeded(): Promise + wasSignInEnabledAtStartup(): boolean + isMediaRouterEnabled(): boolean + getDecentralizedDnsResolveMethodList(): Promise // TODO(petemill): Define type + getEnsOffchainResolveMethodList(): Promise // TODO(petemill): Define type + isENSL2Enabled(): boolean +} + +export class BraveDefaultExtensionsBrowserProxyImpl implements BraveDefaultExtensionsBrowserProxy { + setWebTorrentEnabled(value: boolean) { + chrome.send('setWebTorrentEnabled', [value]) + } + + setHangoutsEnabled(value: boolean) { + chrome.send('setHangoutsEnabled', [value]) + } + + setMediaRouterEnabled(value: boolean) { + chrome.send('setMediaRouterEnabled', [value]) + } + + setWidevineEnabled(value: boolean) { + chrome.send('setWidevineEnabled', [value]) + } + + isWidevineEnabled() { + return sendWithPromise('isWidevineEnabled') + } + + getRestartNeeded() { + return sendWithPromise('getRestartNeeded') + } + + wasSignInEnabledAtStartup() { + return loadTimeData.getBoolean('signInAllowedOnNextStartupInitialValue') + } + + isMediaRouterEnabled() { + return loadTimeData.getBoolean('isMediaRouterEnabled') + } + + getDecentralizedDnsResolveMethodList() { + return sendWithPromise('getDecentralizedDnsResolveMethodList') + } + + getEnsOffchainResolveMethodList() { + return sendWithPromise('getEnsOffchainResolveMethodList') + } + + isENSL2Enabled() { + return loadTimeData.getBoolean('isENSL2Enabled') + } + + static getInstance(): BraveDefaultExtensionsBrowserProxy { + return instance || (instance = new BraveDefaultExtensionsBrowserProxyImpl()) + } +} + +let instance: BraveDefaultExtensionsBrowserProxy|null = null diff --git a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.html b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.html index 6e479780a7dc..262872806ec6 100644 --- a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.html +++ b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.html @@ -1,162 +1,145 @@ - - + - .restart-notice { - font-size: .9375rem; - line-height: 1.4; - } - - button.primary { - background: var(--interactive-color); - border: 0; - border-radius: 3px; - color: white; - font-size: .875rem; - padding: 14px 38px; - } - - - - - - - - - - -
-
-
$i18n{resolveUnstoppableDomainsDesc}
-
$i18nRaw{resolveUnstoppableDomainsSubDesc}
-
- -
-
-
$i18n{resolveENSDesc}
- -
- - - - -
- - -
-
- - -
-
- - -
- - - + + diff --git a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.js b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.js deleted file mode 100644 index f2dfae9792f3..000000000000 --- a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.js +++ /dev/null @@ -1,127 +0,0 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ - -(function() { -'use strict'; - -/** - * 'settings-brave-default-extensions-page' is the settings page containing - * brave's default extensions. - */ -Polymer({ - is: 'settings-brave-default-extensions-page', - - behaviors: [ - WebUIListenerBehavior, - ], - - /** - * Keep it the same as Provider in - * brave/componentsdecentralized_dns/constants.h. - */ - Provider: { - UNSTOPPABLE_DOMAINS: 0, - ENS: 1 - }, - - properties: { - showRestartToast_: Boolean, - unstoppableDomainsResolveMethod_: Array, - ensResolveMethod_: Array, - widevineEnabledPref_: { - type: Object, - value() { - // TODO(dbeam): this is basically only to appease PrefControlMixin. - // Maybe add a no-validate attribute instead? This makes little sense. - return {}; - }, - }, - }, - - /** @private {?settings.BraveDefaultExtensionsBrowserProxy} */ - browserProxy_: null, - - /** @override */ - created: function() { - this.browserProxy_ = settings.BraveDefaultExtensionsBrowserProxyImpl.getInstance(); - }, - - /** @override */ - ready: function() { - this.onWebTorrentEnabledChange_ = this.onWebTorrentEnabledChange_.bind(this) - this.onHangoutsEnabledChange_ = this.onHangoutsEnabledChange_.bind(this) - this.openExtensionsPage_ = this.openExtensionsPage_.bind(this) - this.openKeyboardShortcutsPage_ = this.openKeyboardShortcutsPage_.bind(this) - this.onWidevineEnabledChange_ = this.onWidevineEnabledChange_.bind(this) - this.restartBrowser_ = this.restartBrowser_.bind(this) - - this.addWebUIListener('brave-needs-restart-changed', (needsRestart) => { - this.showRestartToast_ = needsRestart - }) - - this.browserProxy_.getRestartNeeded().then(show => { - this.showRestartToast_ = show; - }); - this.browserProxy_.getDecentralizedDnsResolveMethodList().then(list => { - this.unstoppableDomainsResolveMethod_ = list - }) - this.browserProxy_.getDecentralizedDnsResolveMethodList().then(list => { - this.ensResolveMethod_ = list - }) - - // PrefControlMixin checks for a pref being valid, so have to fake it, - // same as upstream. - const setWidevineEnabledPref = (enabled) => this.setWidevineEnabledPref_(enabled); - this.addWebUIListener('widevine-enabled-changed', setWidevineEnabledPref); - this.browserProxy_.isWidevineEnabled().then(setWidevineEnabledPref); - }, - - onWebTorrentEnabledChange_: function() { - this.browserProxy_.setWebTorrentEnabled(this.$.webTorrentEnabled.checked); - }, - - onHangoutsEnabledChange_: function() { - this.browserProxy_.setHangoutsEnabled(this.$.hangoutsEnabled.checked); - }, - - restartBrowser_: function(e) { - e.stopPropagation(); - window.open("chrome://restart", "_self"); - }, - - setWidevineEnabledPref_: function (enabled) { - const pref = { - key: '', - type: chrome.settingsPrivate.PrefType.BOOLEAN, - value: enabled, - }; - this.widevineEnabledPref_ = pref; - }, - - onWidevineEnabledChange_: function() { - this.browserProxy_.setWidevineEnabled(this.$.widevineEnabled.checked); - }, - - openExtensionsPage_: function() { - window.open("chrome://extensions", "_self"); - }, - - openKeyboardShortcutsPage_: function() { - window.open("chrome://extensions/shortcuts", "_self"); - }, - - openWebStoreUrl_: function() { - window.open(loadTimeData.getString('getMoreExtensionsUrl')); - }, - - shouldShowRestartForGoogleLogin_: function(value) { - return this.browserProxy_.wasSignInEnabledAtStartup() != value; - }, - - shouldShowRestartForMediaRouter_: function(value) { - return this.browserProxy_.isMediaRouterEnabled() != value; - } - -}); -})(); diff --git a/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.ts b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.ts new file mode 100644 index 000000000000..4fc10bdfbf1b --- /dev/null +++ b/browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.ts @@ -0,0 +1,148 @@ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import { WebUIListenerMixin, WebUIListenerMixinInterface } from 'chrome://resources/js/web_ui_listener_mixin.js' +import {SettingsCheckboxElement} from '../controls/settings_checkbox.js'; +import { loadTimeData } from '../i18n_setup.js'; +import { PrefsMixin, PrefsMixinInterface } from '../prefs/prefs_mixin.js' +import { BraveDefaultExtensionsBrowserProxyImpl } from './brave_default_extensions_browser_proxy.js' +import { getTemplate } from './brave_default_extensions_page.html.js' + +const SettingBraveDefaultExtensionsPageElementBase = WebUIListenerMixin(PrefsMixin(PolymerElement)) as { + new (): PolymerElement & WebUIListenerMixinInterface & PrefsMixinInterface +} + +export interface SettingBraveDefaultExtensionsPageElement { + $: { + widevineEnabled: SettingsCheckboxElement, + webTorrentEnabled: SettingsCheckboxElement, + hangoutsEnabled: SettingsCheckboxElement + } +} + +/** + * 'settings-brave-default-extensions-page' is the settings page containing + * brave's default extensions. + */ +export class SettingBraveDefaultExtensionsPageElement extends SettingBraveDefaultExtensionsPageElementBase { + static get is() { + return 'settings-brave-default-extensions-page' + } + + static get template() { + return getTemplate() + } + + static get properties() { + return { + showRestartToast_: Boolean, + unstoppableDomainsResolveMethod_: Array, + ensResolveMethod_: Array, + widevineEnabledPref_: { + type: Object, + value() { + // TODO(dbeam): this is basically only to appease PrefControlMixin. + // Maybe add a no-validate attribute instead? This makes little sense. + return {} + }, + } + } + } + + /** + * Keep it the same as Provider in + * brave/componentsdecentralized_dns/constants.h. + */ + Provider: { + UNSTOPPABLE_DOMAINS: 0, + ENS: 1 + } + + private browserProxy_ = BraveDefaultExtensionsBrowserProxyImpl.getInstance() + showRestartToast_: Boolean + unstoppableDomainsResolveMethod_: any[] // TODO(petemill): Define type + ensResolveMethod_: any[] // TODO(petemill): Define type + widevineEnabledPref_: chrome.settingsPrivate.PrefObject + + override ready() { + super.ready() + this.onWebTorrentEnabledChange_ = this.onWebTorrentEnabledChange_.bind(this) + this.onHangoutsEnabledChange_ = this.onHangoutsEnabledChange_.bind(this) + this.openExtensionsPage_ = this.openExtensionsPage_.bind(this) + this.openKeyboardShortcutsPage_ = this.openKeyboardShortcutsPage_.bind(this) + this.onWidevineEnabledChange_ = this.onWidevineEnabledChange_.bind(this) + this.restartBrowser_ = this.restartBrowser_.bind(this) + + this.addWebUIListener('brave-needs-restart-changed', (needsRestart: boolean) => { + this.showRestartToast_ = needsRestart + }) + + this.browserProxy_.getRestartNeeded().then(show => { + this.showRestartToast_ = show + }) + this.browserProxy_.getDecentralizedDnsResolveMethodList().then(list => { + this.unstoppableDomainsResolveMethod_ = list + }) + this.browserProxy_.getDecentralizedDnsResolveMethodList().then(list => { + this.ensResolveMethod_ = list + }) + + // PrefControlMixin checks for a pref being valid, so have to fake it, + // same as upstream. + const setWidevineEnabledPref = (enabled: boolean) => this.setWidevineEnabledPref_(enabled) + this.addWebUIListener('widevine-enabled-changed', setWidevineEnabledPref) + this.browserProxy_.isWidevineEnabled().then(setWidevineEnabledPref) + } + + onWebTorrentEnabledChange_() { + this.browserProxy_.setWebTorrentEnabled(this.$.webTorrentEnabled.checked) + } + + onHangoutsEnabledChange_() { + this.browserProxy_.setHangoutsEnabled(this.$.hangoutsEnabled.checked) + } + + restartBrowser_(e: Event) { + e.stopPropagation() + window.open("chrome://restart", "_self") + } + + setWidevineEnabledPref_(enabled: boolean) { + const pref = { + key: '', + type: chrome.settingsPrivate.PrefType.BOOLEAN, + value: enabled, + } + this.widevineEnabledPref_ = pref + } + + onWidevineEnabledChange_() { + this.browserProxy_.setWidevineEnabled(this.$.widevineEnabled.checked) + } + + openExtensionsPage_() { + window.open("chrome://extensions", "_self") + } + + openKeyboardShortcutsPage_() { + window.open("chrome://extensions/shortcuts", "_self") + } + + openWebStoreUrl_() { + window.open(loadTimeData.getString('getMoreExtensionsUrl')) + } + + shouldShowRestartForGoogleLogin_(value: boolean) { + return this.browserProxy_.wasSignInEnabledAtStartup() != value + } + + shouldShowRestartForMediaRouter_(value: boolean) { + return this.browserProxy_.isMediaRouterEnabled() != value + } +} + +customElements.define( + SettingBraveDefaultExtensionsPageElement.is, SettingBraveDefaultExtensionsPageElement) diff --git a/browser/resources/settings/brave_help_tips_page/BUILD.gn b/browser/resources/settings/brave_help_tips_page/BUILD.gn deleted file mode 100644 index 2e1cd62b9b0f..000000000000 --- a/browser/resources/settings/brave_help_tips_page/BUILD.gn +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -group("web_modules") { - public_deps = [ ":templatize" ] -} - -html_to_js("templatize") { - js_files = [ "brave_help_tips_page.js" ] -} diff --git a/browser/resources/settings/brave_help_tips_page/brave_help_tips_page.js b/browser/resources/settings/brave_help_tips_page/brave_help_tips_page.ts similarity index 91% rename from browser/resources/settings/brave_help_tips_page/brave_help_tips_page.js rename to browser/resources/settings/brave_help_tips_page/brave_help_tips_page.ts index deec6ab86bb3..bd3e776660d5 100644 --- a/browser/resources/settings/brave_help_tips_page/brave_help_tips_page.js +++ b/browser/resources/settings/brave_help_tips_page/brave_help_tips_page.ts @@ -2,13 +2,13 @@ * 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 http://mozilla.org/MPL/2.0/. */ - + import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {WebUIListenerMixin} from 'chrome://resources/js/web_ui_listener_mixin.js'; import {PrefsMixin} from '../prefs/prefs_mixin.js'; - - const SettingBraveHelpTipsPageElementBase = WebUIListenerMixin(PrefsMixin(PolymerElement)) + import {getTemplate} from './brave_help_tips_page.html.js' + const SettingBraveHelpTipsPageElementBase = WebUIListenerMixin(PrefsMixin(PolymerElement)) class SettingsBraveHelpTipsPageElement extends SettingBraveHelpTipsPageElementBase { static get is() { @@ -16,7 +16,7 @@ class SettingsBraveHelpTipsPageElement extends SettingBraveHelpTipsPageElementBa } static get template() { - return html`{__html_template__}` + return getTemplate() } } diff --git a/browser/resources/settings/brave_icons.html b/browser/resources/settings/brave_icons.html index 656d0965ccc2..e7441f720c15 100644 --- a/browser/resources/settings/brave_icons.html +++ b/browser/resources/settings/brave_icons.html @@ -4,7 +4,7 @@ diff --git a/browser/resources/settings/brave_ipfs_page/BUILD.gn b/browser/resources/settings/brave_ipfs_page/BUILD.gn deleted file mode 100644 index 391b54f8ffb1..000000000000 --- a/browser/resources/settings/brave_ipfs_page/BUILD.gn +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -group("web_modules") { - public_deps = [ - ":ipfs_peers_subpage_module", - ":modules", - ":p2p_keys_subpage_module", - ":templatize", - ] -} - -polymer_modulizer("p2p_keys_subpage") { - js_file = "p2p_keys_subpage.js" - html_file = "p2p_keys_subpage.html" - html_type = "dom-module" - auto_imports = settings_auto_imports + [ "brave/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.html|BraveIPFSBrowserProxy, BraveIPFSBrowserProxyImpl" ] - namespace_rewrites = settings_namespace_rewrites -} -polymer_modulizer("ipfs_peers_subpage") { - js_file = "ipfs_peers_subpage.js" - html_file = "ipfs_peers_subpage.html" - html_type = "dom-module" - auto_imports = settings_auto_imports + [ "brave/browser/resources/settings/brave_ipfs_page/brave_ipfs_browser_proxy.html|BraveIPFSBrowserProxy, BraveIPFSBrowserProxyImpl" ] - namespace_rewrites = settings_namespace_rewrites -} -js_modulizer("modules") { - input_files = [ "brave_ipfs_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} -html_to_js("templatize") { - js_files = [ - "brave_ipfs_page.js", - "change_ipfs_gateway_dialog.js", - "add_ipfs_peer_dialog.js", - "add_p2p_key_dialog.js", - "rotate_p2p_key_dialog.js", - ] -} diff --git a/browser/resources/settings/brave_ipfs_page/add_ipfs_peer_dialog.html b/browser/resources/settings/brave_ipfs_page/add_ipfs_peer_dialog.html index a351ea12277c..951c561516e0 100644 --- a/browser/resources/settings/brave_ipfs_page/add_ipfs_peer_dialog.html +++ b/browser/resources/settings/brave_ipfs_page/add_ipfs_peer_dialog.html @@ -1,6 +1,3 @@ - - -
- - - -
- - - - + + +
+ + + +
+ diff --git a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js deleted file mode 100644 index 670bf71d9caf..000000000000 --- a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -(function() { - 'use strict'; - - /** - * 'settings-brave-new-tab-page' is the settings page containing - * brave's new tab features. - */ - Polymer({ - is: 'settings-brave-new-tab-page', - - /** @private {?settings.BraveNewTabBrowserProxy} */ - browserProxy_: null, - - behaviors: [ - WebUIListenerBehavior, - ], - - properties: { - newTabShowOptions_: Array, - shouldNewTabShowDashboardSettings_: Boolean, - }, - - /** @override */ - created: function() { - this.browserProxy_ = settings.BraveNewTabBrowserProxyImpl.getInstance(); - this.showNewTabDashboardSettings_ = false; - }, - - /** @override */ - ready: function() { - this.openNewTabPage_ = this.openNewTabPage_.bind(this) - - this.browserProxy_.getNewTabShowsOptionsList().then(list => { - this.newTabShowOptions_ = list; - }) - this.browserProxy_.shouldShowNewTabDashboardSettings().then(showNewTabDashboardSettings => { - this.showNewTabDashboardSettings_ = showNewTabDashboardSettings; - }) - - this.addWebUIListener('show-new-tab-dashboard-settings-changed', (show) => { - this.showNewTabDashboardSettings_ = show - }) - }, - - openNewTabPage_: function () { - window.open("chrome://newTab?openSettings=1", "_self"); - } - }); -})(); diff --git a/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.ts b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.ts new file mode 100644 index 000000000000..d28dc07ad2bc --- /dev/null +++ b/browser/resources/settings/brave_new_tab_page/brave_new_tab_page.ts @@ -0,0 +1,58 @@ +// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. + +// @ts-nocheck TODO(petemill): Convert to Polymer class and remove ts-nocheck + +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {WebUIListenerBehavior} from 'chrome://resources/cr_elements/web_ui_listener_behavior.js'; +import {BraveNewTabBrowserProxyImpl} from './brave_new_tab_browser_proxy.js' +import {getTemplate} from './brave_new_tab_page.html.js' + +/** + * 'settings-brave-new-tab-page' is the settings page containing + * brave's new tab features. + */ +Polymer({ + is: 'settings-brave-new-tab-page', + + _template: getTemplate(), + + browserProxy_: null, + + behaviors: [ + WebUIListenerBehavior, + ], + + properties: { + newTabShowOptions_: Array, + shouldNewTabShowDashboardSettings_: Boolean, + }, + + /** @override */ + created: function() { + this.browserProxy_ = BraveNewTabBrowserProxyImpl.getInstance() + this.showNewTabDashboardSettings_ = false + }, + + /** @override */ + ready: function() { + this.openNewTabPage_ = this.openNewTabPage_.bind(this) + + this.browserProxy_.getNewTabShowsOptionsList().then(list => { + this.newTabShowOptions_ = list + }) + this.browserProxy_.shouldShowNewTabDashboardSettings().then(showNewTabDashboardSettings => { + this.showNewTabDashboardSettings_ = showNewTabDashboardSettings + }) + + this.addWebUIListener('show-new-tab-dashboard-settings-changed', (show) => { + this.showNewTabDashboardSettings_ = show + }) + }, + + openNewTabPage_: function () { + window.open("chrome://newTab?openSettings=1", "_self") + } +}) diff --git a/browser/resources/settings/brave_overrides/BUILD.gn b/browser/resources/settings/brave_overrides/BUILD.gn deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/browser/resources/settings/brave_overrides/about_page.js b/browser/resources/settings/brave_overrides/about_page.ts similarity index 93% rename from browser/resources/settings/brave_overrides/about_page.js rename to browser/resources/settings/brave_overrides/about_page.ts index 164707743dcd..c433a561fad2 100644 --- a/browser/resources/settings/brave_overrides/about_page.js +++ b/browser/resources/settings/brave_overrides/about_page.ts @@ -3,7 +3,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import { html, RegisterStyleOverride, RegisterPolymerTemplateModifications } from 'chrome://brave-resources/polymer_overriding.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import { html, RegisterStyleOverride, RegisterPolymerTemplateModifications } from 'chrome://resources/polymer_overriding.js' import {getSectionElement} from './basic_page.js' RegisterStyleOverride( diff --git a/browser/resources/settings/brave_overrides/appearance_page.js b/browser/resources/settings/brave_overrides/appearance_page.ts similarity index 95% rename from browser/resources/settings/brave_overrides/appearance_page.js rename to browser/resources/settings/brave_overrides/appearance_page.ts index b8fc89fdff47..5c1fcbe80cad 100644 --- a/browser/resources/settings/brave_overrides/appearance_page.js +++ b/browser/resources/settings/brave_overrides/appearance_page.ts @@ -3,8 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js' import {Router} from '../router.js' import {loadTimeData} from '../i18n_setup.js' diff --git a/browser/resources/settings/brave_overrides/basic_page.js b/browser/resources/settings/brave_overrides/basic_page.ts similarity index 98% rename from browser/resources/settings/brave_overrides/basic_page.js rename to browser/resources/settings/brave_overrides/basic_page.ts index f3e9baa42dba..99b81fe9fa53 100644 --- a/browser/resources/settings/brave_overrides/basic_page.js +++ b/browser/resources/settings/brave_overrides/basic_page.ts @@ -3,13 +3,15 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {html, RegisterPolymerTemplateModifications, RegisterStyleOverride} from 'chrome://brave-resources/polymer_overriding.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {html, RegisterPolymerTemplateModifications, RegisterStyleOverride} from 'chrome://resources/polymer_overriding.js' import {loadTimeData} from '../i18n_setup.js' -import '../brave_default_extensions_page/brave_default_extensions_page.m.js' +import '../brave_default_extensions_page/brave_default_extensions_page.js' import '../brave_help_tips_page/brave_help_tips_page.js' import '../brave_ipfs_page/brave_ipfs_page.js' -import '../brave_new_tab_page/brave_new_tab_page.m.js' +import '../brave_new_tab_page/brave_new_tab_page.js' import '../brave_rewards_page/brave_rewards_page.js' import '../brave_search_engines_page/brave_search_engines_page.js' import '../brave_sync_page/brave_sync_page.js' @@ -17,7 +19,7 @@ import '../brave_tor_page/brave_tor_subpage.js' import '../brave_wallet_page/brave_wallet_page.js' import '../default_brave_shields_page/default_brave_shields_page.js' import '../getting_started_page/getting_started.js' -import '../social_blocking_page/social_blocking_page.m.js' +import '../social_blocking_page/social_blocking_page.js' const isGuest = loadTimeData.getBoolean('isGuest') diff --git a/browser/resources/settings/brave_overrides/clear_browsing_data_dialog.js b/browser/resources/settings/brave_overrides/clear_browsing_data_dialog.ts similarity index 68% rename from browser/resources/settings/brave_overrides/clear_browsing_data_dialog.js rename to browser/resources/settings/brave_overrides/clear_browsing_data_dialog.ts index cddce6736c22..e9c260d59770 100644 --- a/browser/resources/settings/brave_overrides/clear_browsing_data_dialog.js +++ b/browser/resources/settings/brave_overrides/clear_browsing_data_dialog.ts @@ -3,9 +3,11 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import {BraveClearBrowsingDataOnExitBehavior} from '../brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js' -import {RegisterPolymerComponentBehaviors, RegisterPolymerTemplateModifications, RegisterStyleOverride} from 'chrome://brave-resources/polymer_overriding.js' +import {BraveSettingsClearBrowsingDataDialogElement} from '../brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js' +import {RegisterPolymerComponentReplacement, RegisterPolymerTemplateModifications, RegisterStyleOverride} from 'chrome://resources/polymer_overriding.js' import {loadTimeData} from '../i18n_setup.js' RegisterStyleOverride( @@ -20,11 +22,10 @@ RegisterStyleOverride( ` ) -RegisterPolymerComponentBehaviors({ - 'settings-clear-browsing-data-dialog': [ - BraveClearBrowsingDataOnExitBehavior - ] -}) +RegisterPolymerComponentReplacement( + 'settings-clear-browsing-data-dialog', + BraveSettingsClearBrowsingDataDialogElement +) RegisterPolymerTemplateModifications({ 'settings-clear-browsing-data-dialog': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/config.js b/browser/resources/settings/brave_overrides/config.ts similarity index 83% rename from browser/resources/settings/brave_overrides/config.js rename to browser/resources/settings/brave_overrides/config.ts index 1ab8dfb078f0..0ae429fbcc4b 100644 --- a/browser/resources/settings/brave_overrides/config.js +++ b/browser/resources/settings/brave_overrides/config.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerComponentToIgnore} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerComponentToIgnore} from 'chrome://resources/polymer_overriding.js' // Replacing chromium polymer components with subclasses of them is a // 2-step process: @@ -15,3 +15,4 @@ import {RegisterPolymerComponentToIgnore} from 'chrome://brave-resources/polymer // is imported). RegisterPolymerComponentToIgnore('settings-site-settings-page') +RegisterPolymerComponentToIgnore('settings-clear-browsing-data-dialog') diff --git a/browser/resources/settings/brave_overrides/cookies_page.js b/browser/resources/settings/brave_overrides/cookies_page.ts similarity index 91% rename from browser/resources/settings/brave_overrides/cookies_page.js rename to browser/resources/settings/brave_overrides/cookies_page.ts index d889f87e71f1..d812094593e6 100644 --- a/browser/resources/settings/brave_overrides/cookies_page.js +++ b/browser/resources/settings/brave_overrides/cookies_page.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-cookies-page': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/default_browser_page.js b/browser/resources/settings/brave_overrides/default_browser_page.ts similarity index 86% rename from browser/resources/settings/brave_overrides/default_browser_page.js rename to browser/resources/settings/brave_overrides/default_browser_page.ts index 03e2c88045e8..50513977d5fa 100644 --- a/browser/resources/settings/brave_overrides/default_browser_page.js +++ b/browser/resources/settings/brave_overrides/default_browser_page.ts @@ -3,7 +3,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' function queryInAllTemplates(element, selector, onFound) { if (!element) { diff --git a/browser/resources/settings/brave_overrides/icons.js b/browser/resources/settings/brave_overrides/icons.ts similarity index 80% rename from browser/resources/settings/brave_overrides/icons.js rename to browser/resources/settings/brave_overrides/icons.ts index d244d0bbe4a0..55b5fa28d964 100644 --- a/browser/resources/settings/brave_overrides/icons.js +++ b/browser/resources/settings/brave_overrides/icons.ts @@ -3,10 +3,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {OverrideIronIcons} from 'chrome://brave-resources/polymer_overriding.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {OverrideIronIcons} from 'chrome://resources/polymer_overriding.js' import '../icons.html.js' -import '../brave_icons.m.js' +import '../brave_icons.html.js' OverrideIronIcons('settings', 'brave_settings', { palette: 'appearance', diff --git a/browser/resources/settings/brave_overrides/import_data_dialog.js b/browser/resources/settings/brave_overrides/import_data_dialog.ts similarity index 82% rename from browser/resources/settings/brave_overrides/import_data_dialog.js rename to browser/resources/settings/brave_overrides/import_data_dialog.ts index 5860ccec3b62..5b30841825bf 100644 --- a/browser/resources/settings/brave_overrides/import_data_dialog.js +++ b/browser/resources/settings/brave_overrides/import_data_dialog.ts @@ -3,8 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {html, RegisterPolymerTemplateModifications, RegisterPolymerComponentBehaviors} from 'chrome://brave-resources/polymer_overriding.js' -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {html, RegisterPolymerTemplateModifications, RegisterPolymerComponentBehaviors} from 'chrome://resources/polymer_overriding.js' +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js' RegisterPolymerTemplateModifications({ 'settings-import-data-dialog': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/index.js b/browser/resources/settings/brave_overrides/index.ts similarity index 100% rename from browser/resources/settings/brave_overrides/index.js rename to browser/resources/settings/brave_overrides/index.ts diff --git a/browser/resources/settings/brave_overrides/page_visibility.js b/browser/resources/settings/brave_overrides/page_visibility.ts similarity index 87% rename from browser/resources/settings/brave_overrides/page_visibility.js rename to browser/resources/settings/brave_overrides/page_visibility.ts index 54968df97431..855b08040cde 100644 --- a/browser/resources/settings/brave_overrides/page_visibility.js +++ b/browser/resources/settings/brave_overrides/page_visibility.ts @@ -1,6 +1,9 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; diff --git a/browser/resources/settings/brave_overrides/passwords_section.js b/browser/resources/settings/brave_overrides/passwords_section.ts similarity index 89% rename from browser/resources/settings/brave_overrides/passwords_section.js rename to browser/resources/settings/brave_overrides/passwords_section.ts index cb4cdb090eea..7561ef8f1723 100644 --- a/browser/resources/settings/brave_overrides/passwords_section.js +++ b/browser/resources/settings/brave_overrides/passwords_section.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'passwords-section': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/payments_section.js b/browser/resources/settings/brave_overrides/payments_section.ts similarity index 85% rename from browser/resources/settings/brave_overrides/payments_section.js rename to browser/resources/settings/brave_overrides/payments_section.ts index 4aea4546f6ff..4fe2ebc0113f 100644 --- a/browser/resources/settings/brave_overrides/payments_section.js +++ b/browser/resources/settings/brave_overrides/payments_section.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-payments-section': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/people_page.js b/browser/resources/settings/brave_overrides/people_page.ts similarity index 98% rename from browser/resources/settings/brave_overrides/people_page.js rename to browser/resources/settings/brave_overrides/people_page.ts index 0f5d0f307711..87e51dc20db7 100644 --- a/browser/resources/settings/brave_overrides/people_page.js +++ b/browser/resources/settings/brave_overrides/people_page.ts @@ -4,7 +4,7 @@ // you can obtain one at http://mozilla.org/MPL/2.0/. import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import {RegisterStyleOverride, RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterStyleOverride, RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterStyleOverride( 'settings-people-page', diff --git a/browser/resources/settings/brave_overrides/personalization_options.js b/browser/resources/settings/brave_overrides/personalization_options.ts similarity index 77% rename from browser/resources/settings/brave_overrides/personalization_options.js rename to browser/resources/settings/brave_overrides/personalization_options.ts index 844844ad5c5a..512015dcfbeb 100644 --- a/browser/resources/settings/brave_overrides/personalization_options.js +++ b/browser/resources/settings/brave_overrides/personalization_options.ts @@ -3,9 +3,11 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck -import '../brave_privacy_page/brave_personalization_options.m.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' + +import '../brave_privacy_page/brave_personalization_options.js' RegisterPolymerTemplateModifications({ 'settings-personalization-options': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/printing_page.js b/browser/resources/settings/brave_overrides/printing_page.ts similarity index 85% rename from browser/resources/settings/brave_overrides/printing_page.js rename to browser/resources/settings/brave_overrides/printing_page.ts index 89b579fb3768..9ae7c8be9d4d 100644 --- a/browser/resources/settings/brave_overrides/printing_page.js +++ b/browser/resources/settings/brave_overrides/printing_page.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-printing-page': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/privacy_page.js b/browser/resources/settings/brave_overrides/privacy_page.ts similarity index 95% rename from browser/resources/settings/brave_overrides/privacy_page.js rename to browser/resources/settings/brave_overrides/privacy_page.ts index 62f0170a249f..6cec1724b970 100644 --- a/browser/resources/settings/brave_overrides/privacy_page.js +++ b/browser/resources/settings/brave_overrides/privacy_page.ts @@ -3,8 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js' import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; RegisterPolymerTemplateModifications({ diff --git a/browser/resources/settings/brave_overrides/reset_profile_dialog.js b/browser/resources/settings/brave_overrides/reset_profile_dialog.ts similarity index 83% rename from browser/resources/settings/brave_overrides/reset_profile_dialog.js rename to browser/resources/settings/brave_overrides/reset_profile_dialog.ts index 04315d4fc998..d35bcbeaa552 100644 --- a/browser/resources/settings/brave_overrides/reset_profile_dialog.js +++ b/browser/resources/settings/brave_overrides/reset_profile_dialog.ts @@ -4,7 +4,7 @@ // you can obtain one at http://mozilla.org/MPL/2.0/. import {BraveResetProfileDialogBehavior} from '../brave_reset_page/brave_reset_profile_dialog_behavior.js' -import {RegisterPolymerComponentBehaviors} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerComponentBehaviors} from 'chrome://resources/polymer_overriding.js' RegisterPolymerComponentBehaviors({ 'settings-reset-profile-dialog': [ diff --git a/browser/resources/settings/brave_overrides/safety_check_passwords_child.js b/browser/resources/settings/brave_overrides/safety_check_passwords_child.ts similarity index 87% rename from browser/resources/settings/brave_overrides/safety_check_passwords_child.js rename to browser/resources/settings/brave_overrides/safety_check_passwords_child.ts index 48eb7d5ffa20..9648d9073a9e 100644 --- a/browser/resources/settings/brave_overrides/safety_check_passwords_child.js +++ b/browser/resources/settings/brave_overrides/safety_check_passwords_child.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-safety-check-passwords-child': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/search_page.js b/browser/resources/settings/brave_overrides/search_page.ts similarity index 89% rename from browser/resources/settings/brave_overrides/search_page.js rename to browser/resources/settings/brave_overrides/search_page.ts index ce07efa37e20..aae380170d9c 100644 --- a/browser/resources/settings/brave_overrides/search_page.js +++ b/browser/resources/settings/brave_overrides/search_page.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' import '../brave_search_engines_page/brave_search_engines_page.js' diff --git a/browser/resources/settings/brave_overrides/security_page.js b/browser/resources/settings/brave_overrides/security_page.ts similarity index 94% rename from browser/resources/settings/brave_overrides/security_page.js rename to browser/resources/settings/brave_overrides/security_page.ts index bda1e6d49eaf..780bafa7e7be 100644 --- a/browser/resources/settings/brave_overrides/security_page.js +++ b/browser/resources/settings/brave_overrides/security_page.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-security-page': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/settings_menu.js b/browser/resources/settings/brave_overrides/settings_menu.ts similarity index 98% rename from browser/resources/settings/brave_overrides/settings_menu.js rename to browser/resources/settings/brave_overrides/settings_menu.ts index ad81022248b6..ee1b007978a8 100644 --- a/browser/resources/settings/brave_overrides/settings_menu.js +++ b/browser/resources/settings/brave_overrides/settings_menu.ts @@ -3,10 +3,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import { html } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import { RegisterStyleOverride, RegisterPolymerTemplateModifications } from 'chrome://brave-resources/polymer_overriding.js' +import { RegisterStyleOverride, RegisterPolymerTemplateModifications } from 'chrome://resources/polymer_overriding.js' import { loadTimeData } from '../i18n_setup.js' -import '../brave_icons.m.js' +import '../brave_icons.html.js' function createMenuElement(title, href, iconName, pageVisibilitySection) { const menuEl = document.createElement('a') diff --git a/browser/resources/settings/brave_overrides/settings_section.js b/browser/resources/settings/brave_overrides/settings_section.ts similarity index 84% rename from browser/resources/settings/brave_overrides/settings_section.js rename to browser/resources/settings/brave_overrides/settings_section.ts index 30acba7c5010..fb0b68ad6da8 100644 --- a/browser/resources/settings/brave_overrides/settings_section.js +++ b/browser/resources/settings/brave_overrides/settings_section.ts @@ -4,7 +4,7 @@ // you can obtain one at http://mozilla.org/MPL/2.0/. import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import {RegisterStyleOverride} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterStyleOverride} from 'chrome://resources/polymer_overriding.js' RegisterStyleOverride( 'settings-section', diff --git a/browser/resources/settings/brave_overrides/settings_ui.js b/browser/resources/settings/brave_overrides/settings_ui.ts similarity index 95% rename from browser/resources/settings/brave_overrides/settings_ui.js rename to browser/resources/settings/brave_overrides/settings_ui.ts index eb6e9158ee52..b9ed0dec96a3 100644 --- a/browser/resources/settings/brave_overrides/settings_ui.js +++ b/browser/resources/settings/brave_overrides/settings_ui.ts @@ -3,10 +3,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' -import {RegisterStyleOverride, RegisterPolymerComponentBehaviors} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterStyleOverride, RegisterPolymerComponentBehaviors} from 'chrome://resources/polymer_overriding.js' -// TODO: move throttle utility to a chrome://brave-resources module +// TODO: move throttle utility to a chrome://resources module function throttle (callback, maxWaitTime = 30) { // Call on first invocation let shouldWait = false; diff --git a/browser/resources/settings/brave_overrides/site_details.js b/browser/resources/settings/brave_overrides/site_details.ts similarity index 89% rename from browser/resources/settings/brave_overrides/site_details.js rename to browser/resources/settings/brave_overrides/site_details.ts index 6ebe39f57192..bfed733c27d8 100644 --- a/browser/resources/settings/brave_overrides/site_details.js +++ b/browser/resources/settings/brave_overrides/site_details.ts @@ -3,8 +3,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js' import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; RegisterPolymerTemplateModifications({ diff --git a/browser/resources/settings/brave_overrides/site_settings_page.js b/browser/resources/settings/brave_overrides/site_settings_page.ts similarity index 96% rename from browser/resources/settings/brave_overrides/site_settings_page.js rename to browser/resources/settings/brave_overrides/site_settings_page.ts index 956d7a719530..fcb17dd74f3e 100644 --- a/browser/resources/settings/brave_overrides/site_settings_page.js +++ b/browser/resources/settings/brave_overrides/site_settings_page.ts @@ -3,7 +3,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {define, RegisterPolymerComponentReplacement} from 'chrome://brave-resources/polymer_overriding.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {RegisterPolymerComponentReplacement} from 'chrome://resources/polymer_overriding.js' import {ContentSettingsTypes} from '../site_settings/constants.js' import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {SettingsSiteSettingsPageElement} from '../site_settings_page/site_settings_page.js' diff --git a/browser/resources/settings/brave_overrides/sync_account_control.js b/browser/resources/settings/brave_overrides/sync_account_control.ts similarity index 93% rename from browser/resources/settings/brave_overrides/sync_account_control.js rename to browser/resources/settings/brave_overrides/sync_account_control.ts index d68f9845f0f7..72de2a817d0d 100644 --- a/browser/resources/settings/brave_overrides/sync_account_control.js +++ b/browser/resources/settings/brave_overrides/sync_account_control.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerComponentProperties, RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerComponentProperties, RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-sync-account-control': (templateContent) => { diff --git a/browser/resources/settings/brave_overrides/sync_controls.js b/browser/resources/settings/brave_overrides/sync_controls.ts similarity index 88% rename from browser/resources/settings/brave_overrides/sync_controls.js rename to browser/resources/settings/brave_overrides/sync_controls.ts index c5cec67a01fd..4b2eb47a999f 100644 --- a/browser/resources/settings/brave_overrides/sync_controls.js +++ b/browser/resources/settings/brave_overrides/sync_controls.ts @@ -3,7 +3,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {RegisterPolymerTemplateModifications} from 'chrome://brave-resources/polymer_overriding.js' +import {RegisterPolymerTemplateModifications} from 'chrome://resources/polymer_overriding.js' RegisterPolymerTemplateModifications({ 'settings-sync-controls': (templateContent) => { diff --git a/browser/resources/settings/brave_privacy_page/BUILD.gn b/browser/resources/settings/brave_privacy_page/BUILD.gn deleted file mode 100644 index 08f3ea78aa56..000000000000 --- a/browser/resources/settings/brave_privacy_page/BUILD.gn +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -group("web_modules") { - public_deps = [ - ":brave_personalization_options_module", - ":modules", - ] -} - -polymer_modulizer("brave_personalization_options") { - js_file = "brave_personalization_options.js" - html_file = "brave_personalization_options.html" - html_type = "dom-module" - auto_imports = settings_auto_imports + [ "brave/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.html|BravePrivacyBrowserProxy, BravePrivacyBrowserProxyImpl" ] - namespace_rewrites = settings_namespace_rewrites -} - -js_modulizer("modules") { - input_files = [ "brave_privacy_page_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} diff --git a/browser/resources/settings/brave_privacy_page/brave_personalization_options.html b/browser/resources/settings/brave_privacy_page/brave_personalization_options.html index 616bbf06ca0b..225511230f95 100644 --- a/browser/resources/settings/brave_privacy_page/brave_personalization_options.html +++ b/browser/resources/settings/brave_privacy_page/brave_personalization_options.html @@ -1,8 +1,8 @@ - - - + + + diff --git a/browser/resources/settings/brave_privacy_page/brave_personalization_options.js b/browser/resources/settings/brave_privacy_page/brave_personalization_options.ts similarity index 87% rename from browser/resources/settings/brave_privacy_page/brave_personalization_options.js rename to browser/resources/settings/brave_privacy_page/brave_personalization_options.ts index 22177307401c..08e3f669e720 100644 --- a/browser/resources/settings/brave_privacy_page/brave_personalization_options.js +++ b/browser/resources/settings/brave_privacy_page/brave_personalization_options.ts @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -(function() { -'use strict'; +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import { Polymer } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {WebUIListenerBehavior} from 'chrome://resources/cr_elements/web_ui_listener_behavior.js'; +import {BravePrivacyBrowserProxy, BravePrivacyBrowserProxyImpl} from './brave_privacy_page_browser_proxy.js' Polymer({ is: 'settings-brave-personalization-options', @@ -45,12 +48,12 @@ Polymer({ }, }, - /** @private {?settings.BravePrivacyBrowserProxy} */ + /** @private {?BravePrivacyBrowserProxy} */ browserProxy_: null, /** @override */ created: function() { - this.browserProxy_ = settings.BravePrivacyBrowserProxyImpl.getInstance(); + this.browserProxy_ = BravePrivacyBrowserProxyImpl.getInstance(); }, /** @override */ @@ -104,4 +107,3 @@ Polymer({ }, }); -})(); diff --git a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.html b/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.html deleted file mode 100644 index 6a67fcac1487..000000000000 --- a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js b/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js deleted file mode 100644 index 713e6fc5d6cc..000000000000 --- a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.js +++ /dev/null @@ -1,67 +0,0 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ - -// clang-format off -// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; -// clang-format on - -cr.define('settings', function() { - /** @interface */ - /* #export */ class BravePrivacyBrowserProxy { - /** - * @return {!Promise} - */ - getP3AEnabled() {} - /** - * @param {boolean} enabled (true/false). - */ - setP3AEnabled(value) {} - /** - * @return {!Promise} - */ - getStatsUsagePingEnabled() {} - /** - * @param {boolean} enabled (true/false). - */ - setStatsUsagePingEnabled(value) {} - /** - * @return {boolean} - */ - wasPushMessagingEnabledAtStartup() {} - } - - /** - * @implements {settings.BravePrivacyBrowserProxy} - */ - /* #export */ class BravePrivacyBrowserProxyImpl { - /** @overrides */ - getP3AEnabled() { - return cr.sendWithPromise('getP3AEnabled'); - } - - setP3AEnabled(value) { - chrome.send('setP3AEnabled', [value]) - } - - getStatsUsagePingEnabled() { - return cr.sendWithPromise('getStatsUsagePingEnabled'); - } - - setStatsUsagePingEnabled(value) { - chrome.send('setStatsUsagePingEnabled', [value]) - } - - wasPushMessagingEnabledAtStartup() { - return loadTimeData.getBoolean('pushMessagingEnabledAtStartup'); - } - } - - cr.addSingletonGetter(BravePrivacyBrowserProxyImpl); - - // #cr_define_end - return { - BravePrivacyBrowserProxy: BravePrivacyBrowserProxy, - BravePrivacyBrowserProxyImpl: BravePrivacyBrowserProxyImpl, - }; -}); diff --git a/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.ts b/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.ts new file mode 100644 index 000000000000..5709b2448777 --- /dev/null +++ b/browser/resources/settings/brave_privacy_page/brave_privacy_page_browser_proxy.ts @@ -0,0 +1,44 @@ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; + +export interface BravePrivacyBrowserProxy { + getP3AEnabled(): Promise + setP3AEnabled(value: boolean) + getStatsUsagePingEnabled(): Promise + setStatsUsagePingEnabled(value: boolean) + wasPushMessagingEnabledAtStartup(): boolean +} + +export class BravePrivacyBrowserProxyImpl implements BravePrivacyBrowserProxy { + getP3AEnabled() { + return sendWithPromise('getP3AEnabled'); + } + + setP3AEnabled(value) { + chrome.send('setP3AEnabled', [value]) + } + + getStatsUsagePingEnabled() { + return sendWithPromise('getStatsUsagePingEnabled'); + } + + setStatsUsagePingEnabled(value) { + chrome.send('setStatsUsagePingEnabled', [value]) + } + + wasPushMessagingEnabledAtStartup() { + return loadTimeData.getBoolean('pushMessagingEnabledAtStartup'); + } + + static getInstance(): BravePrivacyBrowserProxyImpl { + return instance || (instance = new BravePrivacyBrowserProxyImpl()) + } +} + +let instance: BravePrivacyBrowserProxy|null = null \ No newline at end of file diff --git a/browser/resources/settings/brave_reset_page/brave_reset_profile_dialog_behavior.js b/browser/resources/settings/brave_reset_page/brave_reset_profile_dialog_behavior.ts similarity index 92% rename from browser/resources/settings/brave_reset_page/brave_reset_profile_dialog_behavior.js rename to browser/resources/settings/brave_reset_page/brave_reset_profile_dialog_behavior.ts index fa60e9ae793f..95bdb1fd50aa 100644 --- a/browser/resources/settings/brave_reset_page/brave_reset_profile_dialog_behavior.js +++ b/browser/resources/settings/brave_reset_page/brave_reset_profile_dialog_behavior.ts @@ -3,6 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + const BraveResetProfileDialogBehaviorImpl = { ready: function() { this.fixSendSettingsCheckbox(); diff --git a/browser/resources/settings/brave_rewards_page/BUILD.gn b/browser/resources/settings/brave_rewards_page/BUILD.gn deleted file mode 100644 index 76486948da99..000000000000 --- a/browser/resources/settings/brave_rewards_page/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -group("web_modules") { - public_deps = [ - ":modules", - ":templatize", - ] -} - -html_to_js("templatize") { - js_files = [ "brave_rewards_page.js" ] -} - -js_modulizer("modules") { - input_files = [ "brave_rewards_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} diff --git a/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.html b/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.html deleted file mode 100644 index deaf332aae80..000000000000 --- a/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.js b/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.js deleted file mode 100644 index d63e889e5132..000000000000 --- a/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ - -import {addSingletonGetter} from 'chrome://resources/js/cr.m.js'; - -/** @interface */ -export class BraveRewardsBrowserProxy { - getAdsData() { /* Intentionally empty */ } - getRewardsEnabled() { /* Intentionally empty */ } - getRewardsParameters() { /* Intentionally empty */ } - isAutoContributeSupported() { /* Intentionally empty */ } -} - -/** - * @implements {settings.BraveRewardsBrowserProxy} - */ -export class BraveRewardsBrowserProxyImpl { - /** @override */ - getAdsData () { - return new Promise((resolve) => chrome.braveRewards.getAdsData( - (data) => { resolve(data) })) - } - /** @override */ - getRewardsEnabled () { - return new Promise((resolve) => chrome.braveRewards.getRewardsEnabled( - (enabled) => { resolve(enabled) })) - } - /** @override */ - getRewardsParameters () { - return new Promise((resolve) => chrome.braveRewards.getRewardsParameters( - (parameters) => { resolve(parameters) })) - } - /** @override */ - isAutoContributeSupported () { - return new Promise((resolve) => chrome.braveRewards.isAutoContributeSupported( - (supported) => { resolve(supported) })) - } -} - -addSingletonGetter(BraveRewardsBrowserProxyImpl) diff --git a/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.ts b/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.ts new file mode 100644 index 000000000000..aa12e7320adf --- /dev/null +++ b/browser/resources/settings/brave_rewards_page/brave_rewards_browser_proxy.ts @@ -0,0 +1,44 @@ +/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +export interface BraveRewardsBrowserProxy { + getAdsData(): Promise + getRewardsEnabled(): Promise + getRewardsParameters(): Promise + isAutoContributeSupported(): Promise +} + +/** + * @implements {settings.BraveRewardsBrowserProxy} + */ +export class BraveRewardsBrowserProxyImpl implements BraveRewardsBrowserProxy { + getAdsData () { + return new Promise((resolve) => chrome.braveRewards.getAdsData( + (data) => { resolve(data) })) + } + + getRewardsEnabled () { + return new Promise((resolve) => chrome.braveRewards.getRewardsEnabled( + (enabled) => { resolve(enabled) })) + } + + getRewardsParameters () { + return new Promise((resolve) => chrome.braveRewards.getRewardsParameters( + (parameters) => { resolve(parameters) })) + } + + isAutoContributeSupported () { + return new Promise((resolve) => chrome.braveRewards.isAutoContributeSupported( + (supported) => { resolve(supported) })) + } + + static getInstance() { + return instance || (instance = new BraveRewardsBrowserProxyImpl()) + } +} + +let instance: BraveRewardsBrowserProxy|null = null diff --git a/browser/resources/settings/brave_rewards_page/brave_rewards_page.js b/browser/resources/settings/brave_rewards_page/brave_rewards_page.ts similarity index 97% rename from browser/resources/settings/brave_rewards_page/brave_rewards_page.js rename to browser/resources/settings/brave_rewards_page/brave_rewards_page.ts index 210a10da53e9..9332c6ab3820 100644 --- a/browser/resources/settings/brave_rewards_page/brave_rewards_page.js +++ b/browser/resources/settings/brave_rewards_page/brave_rewards_page.ts @@ -2,16 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + 'use strict'; import {loadTimeData} from '../i18n_setup.js'; import '//resources/js/cr.m.js'; -import {html, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; import {PrefsMixin} from '../prefs/prefs_mixin.js'; -import {BraveRewardsBrowserProxyImpl} from './brave_rewards_browser_proxy.m.js'; +import {BraveRewardsBrowserProxyImpl} from './brave_rewards_browser_proxy.js'; +import {getTemplate} from './brave_rewards_page.html.js' const SettingsBraveRewardsPageBase = I18nMixin(PrefsMixin(PolymerElement)) @@ -25,7 +28,7 @@ class SettingsBraveRewardsPage extends SettingsBraveRewardsPageBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_routes.js b/browser/resources/settings/brave_routes.ts similarity index 98% rename from browser/resources/settings/brave_routes.js rename to browser/resources/settings/brave_routes.ts index c35505c4570c..9be410e63996 100644 --- a/browser/resources/settings/brave_routes.js +++ b/browser/resources/settings/brave_routes.ts @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {pageVisibility} from './brave_overrides/page_visibility.js' import {loadTimeData} from './i18n_setup.js' diff --git a/browser/resources/settings/brave_search_engines_page/BUILD.gn b/browser/resources/settings/brave_search_engines_page/BUILD.gn deleted file mode 100644 index bbd165423d8d..000000000000 --- a/browser/resources/settings/brave_search_engines_page/BUILD.gn +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -group("web_modules") { - public_deps = [ - ":modules", - ":templatize", - ] -} - -js_modulizer("modules") { - input_files = [ "brave_search_engines_page_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} - -html_to_js("templatize") { - js_files = [ "brave_search_engines_page.js" ] -} diff --git a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page.js b/browser/resources/settings/brave_search_engines_page/brave_search_engines_page.ts similarity index 83% rename from browser/resources/settings/brave_search_engines_page/brave_search_engines_page.js rename to browser/resources/settings/brave_search_engines_page/brave_search_engines_page.ts index 2d0899c12fc3..a988fee98fef 100644 --- a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page.js +++ b/browser/resources/settings/brave_search_engines_page/brave_search_engines_page.ts @@ -1,15 +1,18 @@ /* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ + * you can obtain one at http://mozilla.org/MPL/2.0/. */ + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck import '../settings_shared.css.js'; import '../settings_vars.css.js'; -import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {WebUIListenerMixin} from 'chrome://resources/js/web_ui_listener_mixin.js'; import {loadTimeData} from "../i18n_setup.js" -import {BraveSearchEnginesPageBrowserProxyImpl} from './brave_search_engines_page_browser_proxy.m.js'; +import {BraveSearchEnginesPageBrowserProxyImpl} from './brave_search_engines_page_browser_proxy.js'; +import {getTemplate} from './brave_search_engines_page.html.js' const BraveSearchEnginesPageBase = WebUIListenerMixin(PolymerElement) @@ -19,7 +22,7 @@ class BraveSearchEnginesPage extends BraveSearchEnginesPageBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.html b/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.html deleted file mode 100644 index a9d60eadbaf4..000000000000 --- a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.js b/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.js deleted file mode 100644 index bcd0e8497913..000000000000 --- a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. - -import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; - -/** @interface */ -export class BraveSearchEnginesPageBrowserProxy { - /** - * @return {!Promise} - */ - getPrivateSearchEnginesList() {} -} - -/** - * @implements {settings.BraveSearchEnginesPageBrowserProxy} - */ -export class BraveSearchEnginesPageBrowserProxyImpl { - /** @override */ - getPrivateSearchEnginesList() { - return sendWithPromise('getPrivateSearchEnginesList'); - } -} - -addSingletonGetter(BraveSearchEnginesPageBrowserProxyImpl) diff --git a/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.ts b/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.ts new file mode 100644 index 000000000000..bef49a2070ec --- /dev/null +++ b/browser/resources/settings/brave_search_engines_page/brave_search_engines_page_browser_proxy.ts @@ -0,0 +1,21 @@ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; + +export interface BraveSearchEnginesPageBrowserProxy { + getPrivateSearchEnginesList(): Promise // TODO(petemill): Define the expected type +} + +export class BraveSearchEnginesPageBrowserProxyImpl implements BraveSearchEnginesPageBrowserProxy { + getPrivateSearchEnginesList() { + return sendWithPromise('getPrivateSearchEnginesList'); + } + static getInstance() { + return instance || (instance = new BraveSearchEnginesPageBrowserProxyImpl()) + } +} + +let instance: BraveSearchEnginesPageBrowserProxy|null = null diff --git a/browser/resources/settings/brave_sync_page/BUILD.gn b/browser/resources/settings/brave_sync_page/BUILD.gn deleted file mode 100644 index 1ca9daab7848..000000000000 --- a/browser/resources/settings/brave_sync_page/BUILD.gn +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") - -group("web_modules") { - public_deps = [ - ":templatize", - ] -} - -html_to_js("templatize") { - js_files = [ - "brave_sync_code_dialog.js", - "brave_sync_configure.js", - "brave_sync_page.js", - "brave_sync_subpage.js", - "brave_sync_setup.js", - ] -} diff --git a/browser/resources/settings/brave_sync_page/brave_sync_browser_proxy.js b/browser/resources/settings/brave_sync_page/brave_sync_browser_proxy.ts similarity index 76% rename from browser/resources/settings/brave_sync_page/brave_sync_browser_proxy.js rename to browser/resources/settings/brave_sync_page/brave_sync_browser_proxy.ts index 42f79a2f4b0b..d962656c7020 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_browser_proxy.js +++ b/browser/resources/settings/brave_sync_page/brave_sync_browser_proxy.ts @@ -3,7 +3,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; export class BraveSyncBrowserProxy { getSyncCode() { @@ -27,6 +29,9 @@ export class BraveSyncBrowserProxy { deleteDevice(deviceId) { return sendWithPromise('SyncDeleteDevice', deviceId); } + static getInstance() { + return instance || (instance = new BraveSyncBrowserProxy()) + } } -addSingletonGetter(BraveSyncBrowserProxy); +let instance: BraveSyncBrowserProxy|null = null diff --git a/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.js b/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts similarity index 90% rename from browser/resources/settings/brave_sync_page/brave_sync_code_dialog.js rename to browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts index dd649f9f1ade..5338271c6274 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.js +++ b/browser/resources/settings/brave_sync_page/brave_sync_code_dialog.ts @@ -3,17 +3,18 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import '../settings_shared.css.js'; import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js'; import 'chrome://resources/cr_elements/cr_button/cr_button.js'; import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.js'; -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; - +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js'; import {BraveSyncBrowserProxy} from './brave_sync_browser_proxy.js'; - +import {getTemplate} from './brave_sync_code_dialog.html.js' /** * @fileoverview @@ -25,7 +26,7 @@ import {BraveSyncBrowserProxy} from './brave_sync_browser_proxy.js'; Polymer({ is: 'settings-brave-sync-code-dialog', - _template: html`{__html_template__}`, + _template: getTemplate(), behaviors: [ I18nBehavior diff --git a/browser/resources/settings/brave_sync_page/brave_sync_configure.js b/browser/resources/settings/brave_sync_page/brave_sync_configure.ts similarity index 88% rename from browser/resources/settings/brave_sync_page/brave_sync_configure.js rename to browser/resources/settings/brave_sync_page/brave_sync_configure.ts index a5cccebaff06..ca02fa900708 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_configure.js +++ b/browser/resources/settings/brave_sync_page/brave_sync_configure.ts @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + /** * @fileoverview * 'settings-brave-sync-configure' is the set of controls which fetches, displays @@ -11,17 +13,18 @@ import './brave_sync_code_dialog.js'; -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; -import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js'; +import {WebUIListenerBehavior} from 'chrome://resources/cr_elements/web_ui_listener_behavior.js'; import {Router} from '../router.js'; import {BraveSyncBrowserProxy} from './brave_sync_browser_proxy.js'; +import {getTemplate} from './brave_sync_configure.html.js' Polymer({ is: 'settings-brave-sync-configure', - _template: html`{__html_template__}`, + _template: getTemplate(), behaviors: [ I18nBehavior, diff --git a/browser/resources/settings/brave_sync_page/brave_sync_page.js b/browser/resources/settings/brave_sync_page/brave_sync_page.ts similarity index 87% rename from browser/resources/settings/brave_sync_page/brave_sync_page.js rename to browser/resources/settings/brave_sync_page/brave_sync_page.ts index 602580a76a5d..2a1c14c0c7ff 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_page.js +++ b/browser/resources/settings/brave_sync_page/brave_sync_page.ts @@ -3,30 +3,33 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + /** * 'settings-brave-sync-page' is the settings page containing brave's * custom sync. */ import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js'; -import 'chrome://resources/cr_elements/icons.m.js'; +import 'chrome://resources/cr_elements/icons.html.js'; import '../settings_page/settings_animated_pages.js'; import '../settings_page/settings_subpage.js'; import '../settings_shared.css.js'; import '../settings_vars.css.js'; import './brave_sync_subpage.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; -import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js'; +import {WebUIListenerBehavior} from 'chrome://resources/cr_elements/web_ui_listener_behavior.js'; +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {Router} from '../router.js'; import {SyncBrowserProxyImpl} from '../people_page/sync_browser_proxy.js'; import {BraveSyncBrowserProxy} from './brave_sync_browser_proxy.js'; +import {getTemplate} from './brave_sync_page.html.js' Polymer({ is: 'settings-brave-sync-page', - _template: html`{__html_template__}`, + _template: getTemplate(), behaviors: [ I18nBehavior, diff --git a/browser/resources/settings/brave_sync_page/brave_sync_setup.js b/browser/resources/settings/brave_sync_page/brave_sync_setup.ts similarity index 88% rename from browser/resources/settings/brave_sync_page/brave_sync_setup.js rename to browser/resources/settings/brave_sync_page/brave_sync_setup.ts index 8a478c22d9c7..28bb6496b325 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_setup.js +++ b/browser/resources/settings/brave_sync_page/brave_sync_setup.ts @@ -3,6 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + /** * @fileoverview * 'brave-sync-setup' is the UI for starting or joining a sync chain @@ -10,15 +12,16 @@ */ import './brave_sync_code_dialog.js'; -import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {I18nBehavior} from 'chrome://resources/cr_elements/i18n_behavior.js'; import {BraveSyncBrowserProxy} from './brave_sync_browser_proxy.js'; +import {getTemplate} from './brave_sync_setup.html.js' Polymer({ is: 'settings-brave-sync-setup', - _template: html`{__html_template__}`, + _template: getTemplate(), behaviors: [ I18nBehavior, diff --git a/browser/resources/settings/brave_sync_page/brave_sync_subpage.js b/browser/resources/settings/brave_sync_page/brave_sync_subpage.ts similarity index 94% rename from browser/resources/settings/brave_sync_page/brave_sync_subpage.js rename to browser/resources/settings/brave_sync_page/brave_sync_subpage.ts index 64cf45cb0cb7..177893e3dbc3 100644 --- a/browser/resources/settings/brave_sync_page/brave_sync_subpage.js +++ b/browser/resources/settings/brave_sync_page/brave_sync_subpage.ts @@ -3,14 +3,15 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck import 'chrome://resources/js/util.m.js'; import 'chrome://resources/cr_elements/cr_button/cr_button.js'; import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.js'; -import 'chrome://resources/cr_elements/icons.m.js'; -import 'chrome://resources/cr_elements/shared_style_css.m.js'; -import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/cr_elements/icons.html.js'; +import 'chrome://resources/cr_elements/cr_shared_style.css.js'; +import 'chrome://resources/cr_elements/cr_shared_vars.css.js'; import '../settings_shared.css.js'; import '../settings_vars.css.js'; import '../people_page/sync_controls.js'; @@ -18,11 +19,12 @@ import './brave_sync_configure.js'; import './brave_sync_setup.js'; import { assert } from 'chrome://resources/js/assert.m.js'; -import { html, PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import { I18nMixin } from 'chrome://resources/js/i18n_mixin.js'; import { Route, RouteObserverMixin, Router } from '../router.js'; import { SyncBrowserProxyImpl, StatusAction } from '../people_page/sync_browser_proxy.js'; +import {getTemplate} from './brave_sync_subpage.html.js' const SettingBraveSyncSubpageBase = I18nMixin(RouteObserverMixin(PolymerElement)) @@ -32,7 +34,7 @@ class SettingBraveSyncSubpage extends SettingBraveSyncSubpageBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_tor_page/BUILD.gn b/browser/resources/settings/brave_tor_page/BUILD.gn deleted file mode 100644 index 4f219b3be752..000000000000 --- a/browser/resources/settings/brave_tor_page/BUILD.gn +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -group("web_modules") { - public_deps = [ - ":modules", - ":templatize", - ] -} - -js_modulizer("modules") { - input_files = [ "brave_tor_browser_proxy.js" ] - - namespace_rewrites = settings_namespace_rewrites -} - -html_to_js("templatize") { - js_files = [ - "brave_tor_subpage.js", - "brave_tor_bridges_dialog.js", - ] -} diff --git a/browser/resources/settings/brave_tor_page/brave_tor_bridges_dialog.js b/browser/resources/settings/brave_tor_page/brave_tor_bridges_dialog.ts similarity index 90% rename from browser/resources/settings/brave_tor_page/brave_tor_bridges_dialog.js rename to browser/resources/settings/brave_tor_page/brave_tor_bridges_dialog.ts index ab7ef8e45047..74afbbe024d4 100644 --- a/browser/resources/settings/brave_tor_page/brave_tor_bridges_dialog.js +++ b/browser/resources/settings/brave_tor_page/brave_tor_bridges_dialog.ts @@ -3,14 +3,17 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import 'chrome://resources/cr_elements/cr_button/cr_button.js'; import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js'; import 'chrome://resources/cr_elements/cr_input/cr_input.js'; -import { html, PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import { I18nMixin } from 'chrome://resources/js/i18n_mixin.js'; import { PrefsMixin } from '../prefs/prefs_mixin.js'; import '../settings_shared.css.js'; import { BraveTorBrowserProxyImpl } from './brave_tor_browser_proxy.js' +import {getTemplate} from './brave_tor_bridges_dialog.html.js' const RequestBridgesDialogBase = I18nMixin(PrefsMixin(PolymerElement)) @@ -20,7 +23,7 @@ class RequestBridgesDialog extends RequestBridgesDialogBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_tor_page/brave_tor_browser_proxy.js b/browser/resources/settings/brave_tor_page/brave_tor_browser_proxy.ts similarity index 61% rename from browser/resources/settings/brave_tor_page/brave_tor_browser_proxy.js rename to browser/resources/settings/brave_tor_page/brave_tor_browser_proxy.ts index dbd6c42b07f6..7d2d30e3c891 100644 --- a/browser/resources/settings/brave_tor_page/brave_tor_browser_proxy.js +++ b/browser/resources/settings/brave_tor_page/brave_tor_browser_proxy.ts @@ -3,32 +3,25 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import { sendWithPromise } from 'chrome://resources/js/cr.m.js'; - -/** @interface */ -export class BraveTorBrowserProxy { - getInstance() { } +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck - getBridgesConfig() { } - setBridgesConfig() { } - requestBridgesCaptcha() { } - resolveBridgesCaptcha() { } +import { sendWithPromise } from 'chrome://resources/js/cr.m.js'; - setTorEnabled() { } - isTorEnabled() { } - isTorManaged() { } +export interface BraveTorBrowserProxy { + getBridgesConfig(): Promise // TODO(petemill): Define the expected type + setBridgesConfig(config: any) // TODO(petemill): Define the expected type + requestBridgesCaptcha(): Promise // TODO(petemill): Define the expected type + resolveBridgesCaptcha(captcha: any) // TODO(petemill): Define the expected type + setTorEnabled(value: boolean) + isTorEnabled(): Promise + isTorManaged(): Promise } -/** -* @implements {BraveTorBrowserProxy} -*/ -export class BraveTorBrowserProxyImpl { - /** @instance */ +export class BraveTorBrowserProxyImpl implements BraveTorBrowserProxy { static getInstance() { return instance || (instance = new BraveTorBrowserProxyImpl()); } - /** @returns {Promise} */ getBridgesConfig() { return sendWithPromise('brave_tor.getBridgesConfig') } @@ -58,5 +51,4 @@ export class BraveTorBrowserProxyImpl { } } -/** @type {BraveTorBrowserProxyImpl} */ -let instance \ No newline at end of file +let instance: BraveTorBrowserProxy|null = null diff --git a/browser/resources/settings/brave_tor_page/brave_tor_subpage.js b/browser/resources/settings/brave_tor_page/brave_tor_subpage.ts similarity index 97% rename from browser/resources/settings/brave_tor_page/brave_tor_subpage.js rename to browser/resources/settings/brave_tor_page/brave_tor_subpage.ts index 80ef0c22c71e..1a9363effea0 100644 --- a/browser/resources/settings/brave_tor_page/brave_tor_subpage.js +++ b/browser/resources/settings/brave_tor_page/brave_tor_subpage.ts @@ -3,13 +3,16 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import { html, PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' import { WebUIListenerMixin } from 'chrome://resources/js/web_ui_listener_mixin.js' import { I18nMixin } from 'chrome://resources/js/i18n_mixin.js'; import { RouteObserverMixin } from '../router.js' import { PrefsMixin } from '../prefs/prefs_mixin.js' import { BraveTorBrowserProxyImpl } from './brave_tor_browser_proxy.js' import './brave_tor_bridges_dialog.js' +import {getTemplate} from './brave_tor_subpage.html.js' const SettingBraveTorPageElementBase = I18nMixin(RouteObserverMixin(WebUIListenerMixin(PrefsMixin(PolymerElement)))) @@ -30,7 +33,7 @@ class SettingsBraveTorPageElement extends SettingBraveTorPageElementBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_wallet_page/BUILD.gn b/browser/resources/settings/brave_wallet_page/BUILD.gn deleted file mode 100644 index 9a9b1dd914cf..000000000000 --- a/browser/resources/settings/brave_wallet_page/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. - -import("//third_party/closure_compiler/compile_js.gni") -import("//tools/polymer/html_to_js.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -js_type_check("closure_compile_module") { - is_polymer3 = true - deps = [ - ":modules", - ":wallet_networks", - ] -} - -group("web_modules") { - public_deps = [ - ":modules", - ":templatize", - ] -} - -js_modulizer("modules") { - input_files = [ "brave_wallet_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} - -js_library("wallet_networks") { - deps = [ - "//ui/webui/resources/js:cr.m", - "//ui/webui/resources/js:i18n_behavior.m", - "//ui/webui/resources/js:load_time_data.m", - ] - externs_list = [ "$externs_path/settings_private.js" ] - extra_deps = [ ":templatize" ] -} - -html_to_js("templatize") { - js_files = [ - "add_wallet_network_dialog.js", - "brave_wallet_page.js", - "wallet_networks_subpage.js", - "wallet_networks_list.js", - ] -} diff --git a/browser/resources/settings/brave_wallet_page/add_wallet_network_dialog.js b/browser/resources/settings/brave_wallet_page/add_wallet_network_dialog.ts similarity index 97% rename from browser/resources/settings/brave_wallet_page/add_wallet_network_dialog.js rename to browser/resources/settings/brave_wallet_page/add_wallet_network_dialog.ts index d56ed8269ef9..e94895dd4fe4 100644 --- a/browser/resources/settings/brave_wallet_page/add_wallet_network_dialog.js +++ b/browser/resources/settings/brave_wallet_page/add_wallet_network_dialog.ts @@ -3,18 +3,21 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import 'chrome://resources/cr_elements/cr_button/cr_button.js'; import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js'; import 'chrome://resources/cr_elements/cr_input/cr_input.js'; import 'chrome://resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.js'; import { Polymer, html } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import { I18nBehavior } from 'chrome://resources/js/i18n_behavior.m.js'; -import { BraveWalletBrowserProxyImpl } from './brave_wallet_browser_proxy.m.js'; +import { I18nBehavior } from 'chrome://resources/cr_elements/i18n_behavior.js'; +import { BraveWalletBrowserProxyImpl } from './brave_wallet_browser_proxy.js'; +import { getTemplate } from './add_wallet_network_dialog.html.js' Polymer({ is: 'add-wallet-network-dialog', - _template: html`{__html_template__}`, + _template: getTemplate(), behaviors: [ I18nBehavior diff --git a/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.html b/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.html deleted file mode 100644 index ab8d76f0d239..000000000000 --- a/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.js b/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.ts similarity index 60% rename from browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.js rename to browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.ts index 35b17459f5ac..0dd9e4b150a0 100644 --- a/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.js +++ b/browser/resources/settings/brave_wallet_page/brave_wallet_browser_proxy.ts @@ -1,26 +1,27 @@ /* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ - -import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; - -/** @interface */ -export class BraveWalletBrowserProxy { - setBraveWalletEnabled (value) {} - getWeb3ProviderList () {} - getSolanaProviderList () {} - isNativeWalletEnabled () {} - getAutoLockMinutes () {} - getNetworksList (coin) {} - getPrepopulatedNetworksList () {} - removeChain (chainId, coin) {} - resetChain (chainId, coin) {} - addChain (value) {} - addHiddenNetwork (chainId, coin) {} - removeHiddenNetwork (chainId, coin) {} - setActiveNetwork (chainId, coin) {} - resetTransactionInfo () {} + * you can obtain one at http://mozilla.org/MPL/2.0/. */ + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; + +export interface BraveWalletBrowserProxy { + setBraveWalletEnabled (value: boolean) + getWeb3ProviderList () // TODO(petemill): Define the expected type + getSolanaProviderList () // TODO(petemill): Define the expected type + isNativeWalletEnabled () // TODO(petemill): Define the expected type + getAutoLockMinutes () // TODO(petemill): Define the expected type + getNetworksList (coin) // TODO(petemill): Define the expected type + getPrepopulatedNetworksList () // TODO(petemill): Define the expected type + removeChain (chainId, coin) // TODO(petemill): Define the expected type + resetChain (chainId, coin) // TODO(petemill): Define the expected type + addChain (value) // TODO(petemill): Define the expected type + addHiddenNetwork (chainId, coin) // TODO(petemill): Define the expected type + removeHiddenNetwork (chainId, coin) // TODO(petemill): Define the expected type + setActiveNetwork (chainId, coin) // TODO(petemill): Define the expected type + resetTransactionInfo () } /** @@ -99,6 +100,10 @@ export class BraveWalletBrowserProxyImpl { getSolanaProviderOptions() { return sendWithPromise('getSolanaProviderOptions') } + + static getInstance() { + return instance || (instance = new BraveWalletBrowserProxyImpl()) + } } -addSingletonGetter(BraveWalletBrowserProxyImpl) +let instance: BraveWalletBrowserProxy|null = null diff --git a/browser/resources/settings/brave_wallet_page/brave_wallet_page.js b/browser/resources/settings/brave_wallet_page/brave_wallet_page.ts similarity index 94% rename from browser/resources/settings/brave_wallet_page/brave_wallet_page.js rename to browser/resources/settings/brave_wallet_page/brave_wallet_page.ts index 850cdb1ad32b..a040b7196739 100644 --- a/browser/resources/settings/brave_wallet_page/brave_wallet_page.js +++ b/browser/resources/settings/brave_wallet_page/brave_wallet_page.ts @@ -2,15 +2,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import 'chrome://resources/cr_elements/cr_input/cr_input.js'; import './wallet_networks_subpage.js'; -import {BraveWalletBrowserProxy, BraveWalletBrowserProxyImpl} from './brave_wallet_browser_proxy.m.js'; +import {BraveWalletBrowserProxy, BraveWalletBrowserProxyImpl} from './brave_wallet_browser_proxy.js'; import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; import {PrefsMixin} from '../prefs/prefs_mixin.js'; -import {PolymerElement, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {Router, RouteObserverMixin} from '../router.js'; import {WebUIListenerMixin} from 'chrome://resources/js/web_ui_listener_mixin.js'; +import {getTemplate} from './brave_wallet_page.html.js' const SettingsBraveWalletPageBase = WebUIListenerMixin(PrefsMixin(I18nMixin(RouteObserverMixin(PolymerElement)))) @@ -24,7 +27,7 @@ class SettingsBraveWalletPage extends SettingsBraveWalletPageBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_wallet_page/wallet_networks_list.js b/browser/resources/settings/brave_wallet_page/wallet_networks_list.ts similarity index 96% rename from browser/resources/settings/brave_wallet_page/wallet_networks_list.js rename to browser/resources/settings/brave_wallet_page/wallet_networks_list.ts index 28d259165812..f32f41d14e79 100644 --- a/browser/resources/settings/brave_wallet_page/wallet_networks_list.js +++ b/browser/resources/settings/brave_wallet_page/wallet_networks_list.ts @@ -2,13 +2,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import 'chrome://resources/cr_elements/cr_button/cr_button.js'; import './add_wallet_network_dialog.js'; -import { BraveWalletBrowserProxyImpl } from './brave_wallet_browser_proxy.m.js'; +import { BraveWalletBrowserProxyImpl } from './brave_wallet_browser_proxy.js'; import { I18nMixin } from 'chrome://resources/js/i18n_mixin.js'; -import { PolymerElement, html } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import { BaseMixin } from '../base_mixin.js'; +import {getTemplate} from './wallet_networks_list.html.js' const SettingsWalletNetworksListBase = I18nMixin(BaseMixin(PolymerElement)) @@ -18,7 +21,7 @@ class SettingsWalletNetworksList extends SettingsWalletNetworksListBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/brave_wallet_page/wallet_networks_subpage.js b/browser/resources/settings/brave_wallet_page/wallet_networks_subpage.ts similarity index 81% rename from browser/resources/settings/brave_wallet_page/wallet_networks_subpage.js rename to browser/resources/settings/brave_wallet_page/wallet_networks_subpage.ts index fa25cfd2cb49..405d8769292a 100644 --- a/browser/resources/settings/brave_wallet_page/wallet_networks_subpage.js +++ b/browser/resources/settings/brave_wallet_page/wallet_networks_subpage.ts @@ -2,15 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import 'chrome://resources/cr_elements/cr_button/cr_button.js'; import './add_wallet_network_dialog.js'; import './wallet_networks_list.js'; -import {BraveWalletBrowserProxyImpl} from './brave_wallet_browser_proxy.m.js'; import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; -import {PolymerElement, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {BaseMixin} from '../base_mixin.js'; import {PrefsMixin} from '../prefs/prefs_mixin.js'; +import {getTemplate} from './wallet_networks_subpage.html.js' const SettingsWalletNetworksSubpageBase = PrefsMixin(I18nMixin(BaseMixin(PolymerElement))) @@ -20,7 +22,7 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/default_brave_shields_page/BUILD.gn b/browser/resources/settings/default_brave_shields_page/BUILD.gn deleted file mode 100644 index 27c2f6131251..000000000000 --- a/browser/resources/settings/default_brave_shields_page/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//third_party/closure_compiler/compile_js.gni") -import("//tools/polymer/html_to_js.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -group("web_modules") { - public_deps = [ - ":modules", - ":templatize", - ] -} - -js_modulizer("modules") { - input_files = [ "default_brave_shields_browser_proxy.js" ] - namespace_rewrites = settings_namespace_rewrites -} - -html_to_js("templatize") { - js_files = [ - "default_brave_shields_page.js", - "brave_adblock_subpage.js", - "components/brave_adblock_subscribe_dropdown.js", - "components/brave_adblock_editor.js", - ] -} diff --git a/browser/resources/settings/default_brave_shields_page/brave_adblock_browser_proxy.js b/browser/resources/settings/default_brave_shields_page/brave_adblock_browser_proxy.ts similarity index 67% rename from browser/resources/settings/default_brave_shields_page/brave_adblock_browser_proxy.js rename to browser/resources/settings/default_brave_shields_page/brave_adblock_browser_proxy.ts index c4672376d5ee..5de2b9eed296 100644 --- a/browser/resources/settings/default_brave_shields_page/brave_adblock_browser_proxy.js +++ b/browser/resources/settings/default_brave_shields_page/brave_adblock_browser_proxy.ts @@ -3,28 +3,24 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * you can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import { sendWithPromise, addWebUIListener } from 'chrome://resources/js/cr.m.js'; -/** @interface */ -export class BraveAdblockBrowserProxy { - getInstance() { } - getRegionalLists() { } - enableFilterList() { } - getListSubscriptions() { } - getCustomFilters() { } - setSubscriptionEnabled() { } - addSubscription() { } - addWebUIListener() { } - updateSubscription() { } - deleteSubscription() { } - viewSubscription() { } +export interface BraveAdblockBrowserProxy { + getRegionalLists(): Promise // TODO(petemill): Define the expected type + enableFilterList(uuid: string, enabled: boolean) + getListSubscriptions(): Promise // TODO(petemill): Define the expected type + getCustomFilters(): Promise // TODO(petemill): Define the expected type + setSubscriptionEnabled(url: string, enabled: boolean) + addSubscription(url: string) + addWebUIListener(eventName: string, callback: Function) + updateSubscription(url: string) + deleteSubscription(url: string) + viewSubscription(url: string) } -/** -* @implements {BraveAdblockBrowserProxy} -*/ -export class BraveAdblockBrowserProxyImpl { - /** @instance */ +export class BraveAdblockBrowserProxyImpl implements BraveAdblockBrowserProxy { static getInstance() { return instance || (instance = new BraveAdblockBrowserProxyImpl()); } @@ -77,5 +73,4 @@ export class BraveAdblockBrowserProxyImpl { } } -/** @type {BraveAdblockBrowserProxyImpl} */ -let instance +let instance: BraveAdblockBrowserProxy|null = null diff --git a/browser/resources/settings/default_brave_shields_page/brave_adblock_subpage.js b/browser/resources/settings/default_brave_shields_page/brave_adblock_subpage.ts similarity index 92% rename from browser/resources/settings/default_brave_shields_page/brave_adblock_subpage.js rename to browser/resources/settings/default_brave_shields_page/brave_adblock_subpage.ts index aa613d2b7857..7379d9da64ea 100644 --- a/browser/resources/settings/default_brave_shields_page/brave_adblock_subpage.js +++ b/browser/resources/settings/default_brave_shields_page/brave_adblock_subpage.ts @@ -3,17 +3,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; -import {PolymerElement, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {BaseMixin} from '../base_mixin.js'; import {PrefsMixin} from '../prefs/prefs_mixin.js'; import 'chrome://resources/cr_elements/cr_button/cr_button.js'; -import 'chrome://resources/cr_elements/icons.m.js'; +import 'chrome://resources/cr_elements/icons.html.js'; import './components/brave_adblock_subscribe_dropdown.js'; import './components/brave_adblock_editor.js'; import { BraveAdblockBrowserProxyImpl } from './brave_adblock_browser_proxy.js' - +import {getTemplate} from './brave_adblock_subpage.html.js' + const AdBlockSubpageBase = PrefsMixin(I18nMixin(BaseMixin(PolymerElement))) class AdBlockSubpage extends AdBlockSubpageBase { @@ -22,7 +25,7 @@ class AdBlockSubpage extends AdBlockSubpageBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { @@ -125,7 +128,7 @@ class AdBlockSubpage extends AdBlockSubpageBase { getStatus_(last_update_attempt, last_successful_update_attempt, last_updated_pretty_text) { /* "Last updated" column can have four distinct states: * No update ever attempted: fine to show blank - * Update attempted and failed, and never succeeded previously: show + * Update attempted and failed, and never succeeded previously: show * "Download failure" * Update attempted and failed, but succeeded previously: show * "Download failure since + last updated time" diff --git a/browser/resources/settings/default_brave_shields_page/components/brave_adblock_editor.js b/browser/resources/settings/default_brave_shields_page/components/brave_adblock_editor.ts similarity index 81% rename from browser/resources/settings/default_brave_shields_page/components/brave_adblock_editor.js rename to browser/resources/settings/default_brave_shields_page/components/brave_adblock_editor.ts index f5488c0c72dc..16affbe9b38f 100644 --- a/browser/resources/settings/default_brave_shields_page/components/brave_adblock_editor.js +++ b/browser/resources/settings/default_brave_shields_page/components/brave_adblock_editor.ts @@ -3,10 +3,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; -import {PolymerElement, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {BaseMixin} from '../../base_mixin.js'; import {PrefsMixin} from '../../prefs/prefs_mixin.js'; +import {getTemplate} from './brave_adblock_editor.html.js' import 'chrome://resources/cr_elements/cr_button/cr_button.js'; @@ -18,7 +21,7 @@ class AdBlockFiltersEditor extends AdBlockFiltersEditorBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } static get properties() { diff --git a/browser/resources/settings/default_brave_shields_page/components/brave_adblock_subscribe_dropdown.js b/browser/resources/settings/default_brave_shields_page/components/brave_adblock_subscribe_dropdown.ts similarity index 71% rename from browser/resources/settings/default_brave_shields_page/components/brave_adblock_subscribe_dropdown.js rename to browser/resources/settings/default_brave_shields_page/components/brave_adblock_subscribe_dropdown.ts index 3c2628f67cee..8ea2463a4b9e 100644 --- a/browser/resources/settings/default_brave_shields_page/components/brave_adblock_subscribe_dropdown.js +++ b/browser/resources/settings/default_brave_shields_page/components/brave_adblock_subscribe_dropdown.ts @@ -1,15 +1,18 @@ /* 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 http://mozilla.org/MPL/2.0/. */ + * you can obtain one at http://mozilla.org/MPL/2.0/. */ - import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; -import {PolymerElement, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {BaseMixin} from '../../base_mixin.js'; import {PrefsMixin} from '../../prefs/prefs_mixin.js'; +import {getTemplate} from './brave_adblock_subscribe_dropdown.html.js' import 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.js'; import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.js'; -import 'chrome://resources/cr_elements/icons.m.js'; +import 'chrome://resources/cr_elements/icons.html.js'; const AdblockSubscribeDropDownBase = PrefsMixin(I18nMixin(BaseMixin(PolymerElement))) @@ -19,7 +22,7 @@ class AdBlockSubscribeDropDown extends AdblockSubscribeDropDownBase { } static get template() { - return html`{__html_template__}` + return getTemplate() } ready() { diff --git a/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js b/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js deleted file mode 100644 index 7a5fba1dce0e..000000000000 --- a/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js +++ /dev/null @@ -1,121 +0,0 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ - -// clang-format off -// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; -// clang-format on - -cr.define('settings', function() { - /** @interface */ - /* #export */ class DefaultBraveShieldsBrowserProxy { - /** - * @return {!Promise} - */ - isAdControlEnabled() {} - /** - * @param {string} value name. - */ - setAdControlType(value) {} - - /** - * @return {!Promise} - */ - isFirstPartyCosmeticFilteringEnabled() {} - /** - * @param {string} value name. - */ - setCosmeticFilteringControlType(value) {} - - /** - * @return {!Promise} - */ - getCookieControlType() {} - /** - * @param {string} value name. - */ - setCookieControlType(value) {} - - /** - * @return {!Promise} - */ - getFingerprintingControlType() {} - /** - * @param {string} value name. - */ - setFingerprintingControlType(value) {} - - /** - * @param {string} value name. - */ - setHTTPSEverywhereEnabled(value) {} - - /** - * @param {string} value name. - */ - setNoScriptControlType(value) {} - } - - /** - * @implements {settings.DefaultBraveShieldsBrowserProxy} - */ - /* #export */ class DefaultBraveShieldsBrowserProxyImpl { - /** @override */ - isAdControlEnabled() { - return cr.sendWithPromise('isAdControlEnabled'); - } - - /** @override */ - setAdControlType(value) { - chrome.send('setAdControlType', [value]); - } - - /** @override */ - isFirstPartyCosmeticFilteringEnabled() { - return cr.sendWithPromise('isFirstPartyCosmeticFilteringEnabled'); - } - - /** @override */ - setCosmeticFilteringControlType(value) { - chrome.send('setCosmeticFilteringControlType', [value]); - } - - /** @override */ - getCookieControlType() { - return cr.sendWithPromise('getCookieControlType'); - } - - /** @override */ - setCookieControlType(value) { - chrome.send('setCookieControlType', [value]); - } - - /** @override */ - getFingerprintingControlType() { - return cr.sendWithPromise('getFingerprintingControlType'); - } - - /** @override */ - setFingerprintingControlType(value) { - chrome.send('setFingerprintingControlType', [value]); - } - - /** @override */ - setHTTPSEverywhereEnabled(value) { - chrome.send('setHTTPSEverywhereEnabled', [value]); - } - - /** @override */ - setNoScriptControlType(value) { - chrome.send('setNoScriptControlType', [value]); - } - } - - cr.addSingletonGetter(DefaultBraveShieldsBrowserProxyImpl); - - // #cr_define_end - return { - DefaultBraveShieldsBrowserProxy, - DefaultBraveShieldsBrowserProxyImpl - }; -}); diff --git a/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.ts b/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.ts new file mode 100644 index 000000000000..7a20467d4727 --- /dev/null +++ b/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.ts @@ -0,0 +1,116 @@ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; + +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + +export interface DefaultBraveShieldsBrowserProxy { + /** + * @return {!Promise} + */ + isAdControlEnabled() + /** + * @param {string} value name. + */ + setAdControlType(value) + + /** + * @return {!Promise} + */ + isFirstPartyCosmeticFilteringEnabled() + /** + * @param {string} value name. + */ + setCosmeticFilteringControlType(value) + + /** + * @return {!Promise} + */ + getCookieControlType() + /** + * @param {string} value name. + */ + setCookieControlType(value) + + /** + * @return {!Promise} + */ + getFingerprintingControlType() + /** + * @param {string} value name. + */ + setFingerprintingControlType(value) + + /** + * @param {string} value name. + */ + setHTTPSEverywhereEnabled(value) + + /** + * @param {string} value name. + */ + setNoScriptControlType(value) +} + +export class DefaultBraveShieldsBrowserProxyImpl implements DefaultBraveShieldsBrowserProxy { + /** @override */ + isAdControlEnabled() { + return sendWithPromise('isAdControlEnabled'); + } + + /** @override */ + setAdControlType(value) { + chrome.send('setAdControlType', [value]); + } + + /** @override */ + isFirstPartyCosmeticFilteringEnabled() { + return sendWithPromise('isFirstPartyCosmeticFilteringEnabled'); + } + + /** @override */ + setCosmeticFilteringControlType(value) { + chrome.send('setCosmeticFilteringControlType', [value]); + } + + /** @override */ + getCookieControlType() { + return sendWithPromise('getCookieControlType'); + } + + /** @override */ + setCookieControlType(value) { + chrome.send('setCookieControlType', [value]); + } + + /** @override */ + getFingerprintingControlType() { + return sendWithPromise('getFingerprintingControlType'); + } + + /** @override */ + setFingerprintingControlType(value) { + chrome.send('setFingerprintingControlType', [value]); + } + + /** @override */ + setHTTPSEverywhereEnabled(value) { + chrome.send('setHTTPSEverywhereEnabled', [value]); + } + + /** @override */ + setNoScriptControlType(value) { + chrome.send('setNoScriptControlType', [value]); + } + + static getInstance(): DefaultBraveShieldsBrowserProxy { + return instance || (instance = new DefaultBraveShieldsBrowserProxyImpl()) + } +} + +let instance: DefaultBraveShieldsBrowserProxy|null = null \ No newline at end of file diff --git a/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.js b/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.ts similarity index 93% rename from browser/resources/settings/default_brave_shields_page/default_brave_shields_page.js rename to browser/resources/settings/default_brave_shields_page/default_brave_shields_page.ts index 3e5a3db8faa1..ea559450fd82 100644 --- a/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.js +++ b/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.ts @@ -3,16 +3,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck + import './brave_adblock_subpage.js'; -import { html, PolymerElement } from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import '//resources/cr_elements/md_select_css.m.js'; -import { DefaultBraveShieldsBrowserProxyImpl } from './default_brave_shields_browser_proxy.m.js'; -'use strict'; +import { PolymerElement } from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import '//resources/cr_elements/md_select.css.js'; +import { DefaultBraveShieldsBrowserProxyImpl } from './default_brave_shields_browser_proxy.js'; import {Router, RouteObserverMixin} from '../router.js'; import {loadTimeData} from '../i18n_setup.js'; import {I18nMixin} from 'chrome://resources/js/i18n_mixin.js'; import {PrefsMixin} from '../prefs/prefs_mixin.js'; +import {getTemplate} from './default_brave_shields_page.html.js' const BraveShieldsPageBase = I18nMixin(PrefsMixin(RouteObserverMixin(PolymerElement))) @@ -26,7 +28,7 @@ class BraveShieldsPage extends BraveShieldsPageBase { } static get template () { - return html`{__html_template__}` + return getTemplate() } static get properties () { @@ -100,7 +102,7 @@ class BraveShieldsPage extends BraveShieldsPageBase { this.adControlType_ = 'allow' } }) - + this.browserProxy_.getCookieControlType().then(value => { this.cookieControlType_ = value }) diff --git a/browser/resources/settings/getting_started_page/BUILD.gn b/browser/resources/settings/getting_started_page/BUILD.gn deleted file mode 100644 index 75b986ace0ec..000000000000 --- a/browser/resources/settings/getting_started_page/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//tools/polymer/html_to_js.gni") - -group("web_modules") { - public_deps = [ - ":templatize", - ] -} - -html_to_js("templatize") { - js_files = [ - "getting_started.js", - ] -} diff --git a/browser/resources/settings/getting_started_page/getting_started.js b/browser/resources/settings/getting_started_page/getting_started.ts similarity index 52% rename from browser/resources/settings/getting_started_page/getting_started.js rename to browser/resources/settings/getting_started_page/getting_started.ts index a302e54090ed..ab2146c2de07 100644 --- a/browser/resources/settings/getting_started_page/getting_started.js +++ b/browser/resources/settings/getting_started_page/getting_started.ts @@ -3,15 +3,22 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. -import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' import '../people_page/people_page.js' import '../settings_page/settings_animated_pages.js' import '../default_browser_page/default_browser_page.js' import '../on_startup_page/on_startup_page.js' +import {getTemplate} from './getting_started.html.js' -Polymer({ - is: 'brave-settings-getting-started', +export class BraveSettingsGettingStarted extends PolymerElement { + static get is() { + return 'brave-settings-getting-started' + } - _template: html`{__html_template__}` -}) + static get template() { + return getTemplate() + } +} + +customElements.define(BraveSettingsGettingStarted.is, BraveSettingsGettingStarted); diff --git a/browser/resources/settings/social_blocking_page/BUILD.gn b/browser/resources/settings/social_blocking_page/BUILD.gn deleted file mode 100644 index b2192a17ab12..000000000000 --- a/browser/resources/settings/social_blocking_page/BUILD.gn +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import("//third_party/closure_compiler/compile_js.gni") -import("//tools/polymer/polymer.gni") -import("//ui/webui/resources/tools/js_modulizer.gni") -import("../settings.gni") - -# ES Module conversion from HTML Imports code - -group("web_modules") { - public_deps = [ - ":social_blocking_page_module", - ] -} - -polymer_modulizer("social_blocking_page") { - js_file = "social_blocking_page.js" - html_file = "social_blocking_page.html" - html_type = "dom-module" - auto_imports = settings_auto_imports - namespace_rewrites = settings_namespace_rewrites -} diff --git a/browser/resources/settings/social_blocking_page/social_blocking_page.html b/browser/resources/settings/social_blocking_page/social_blocking_page.html index df50a50869d9..f5570ace4000 100644 --- a/browser/resources/settings/social_blocking_page/social_blocking_page.html +++ b/browser/resources/settings/social_blocking_page/social_blocking_page.html @@ -1,43 +1,32 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/browser/resources/settings/social_blocking_page/social_blocking_page.js b/browser/resources/settings/social_blocking_page/social_blocking_page.js deleted file mode 100644 index c11877e20b59..000000000000 --- a/browser/resources/settings/social_blocking_page/social_blocking_page.js +++ /dev/null @@ -1,11 +0,0 @@ -/* 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 http://mozilla.org/MPL/2.0/. */ - -/** - * 'settings-social-blocking-page' is the settings page containing brave's - * social blocking options - */ -Polymer({ - is: 'settings-social-blocking-page' -}); diff --git a/browser/resources/settings/social_blocking_page/social_blocking_page.ts b/browser/resources/settings/social_blocking_page/social_blocking_page.ts new file mode 100644 index 000000000000..049466fd08db --- /dev/null +++ b/browser/resources/settings/social_blocking_page/social_blocking_page.ts @@ -0,0 +1,19 @@ +// Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. + +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import {getTemplate} from './social_blocking_page.html.js' + +export class BraveSettingsSocialBlockingPage extends PolymerElement { + static get is() { + return 'settings-social-blocking-page' + } + + static get template() { + return getTemplate() + } +} + +customElements.define(BraveSettingsSocialBlockingPage.is, BraveSettingsSocialBlockingPage); diff --git a/browser/resources/settings/sources.gni b/browser/resources/settings/sources.gni index 3bfba9b92372..fa27eecbf891 100644 --- a/browser/resources/settings/sources.gni +++ b/browser/resources/settings/sources.gni @@ -3,89 +3,110 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # you can obtain one at http://mozilla.org/MPL/2.0/. -brave_deps_chrome_browser_resources_settings_in_files = [ - "brave_appearance_page/brave_appearance_browser_proxy.js", - "brave_appearance_page/brave_theme.js", - "brave_appearance_page/sidebar.js", - "brave_appearance_page/super_referral.js", - "brave_appearance_page/toolbar.js", - "brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.js", - "brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.js", - "brave_default_extensions_page/brave_default_extensions_browser_proxy.m.js", - "brave_default_extensions_page/brave_default_extensions_page.m.js", - "brave_help_tips_page/brave_help_tips_page.js", - "brave_icons.m.js", - "brave_ipfs_page/brave_ipfs_browser_proxy.m.js", - "brave_ipfs_page/brave_ipfs_page.js", - "brave_ipfs_page/change_ipfs_gateway_dialog.js", - "brave_ipfs_page/add_p2p_key_dialog.js", - "brave_ipfs_page/rotate_p2p_key_dialog.js", - "brave_ipfs_page/p2p_keys_subpage.m.js", - "brave_ipfs_page/ipfs_peers_subpage.m.js", - "brave_ipfs_page/add_ipfs_peer_dialog.js", - "brave_new_tab_page/brave_new_tab_browser_proxy.m.js", - "brave_new_tab_page/brave_new_tab_page.m.js", - "brave_overrides/about_page.js", - "brave_overrides/appearance_page.js", - "brave_overrides/basic_page.js", - "brave_overrides/clear_browsing_data_dialog.js", - "brave_overrides/config.js", - "brave_overrides/cookies_page.js", - "brave_overrides/default_browser_page.js", - "brave_overrides/icons.js", - "brave_overrides/import_data_dialog.js", - "brave_overrides/index.js", - "brave_overrides/page_visibility.js", - "brave_overrides/passwords_section.js", - "brave_overrides/payments_section.js", - "brave_overrides/people_page.js", - "brave_overrides/personalization_options.js", - "brave_overrides/printing_page.js", - "brave_overrides/privacy_page.js", - "brave_overrides/reset_profile_dialog.js", - "brave_overrides/safety_check_passwords_child.js", - "brave_overrides/search_page.js", - "brave_overrides/security_page.js", - "brave_overrides/settings_menu.js", - "brave_overrides/settings_section.js", - "brave_overrides/settings_ui.js", - "brave_overrides/site_details.js", - "brave_overrides/site_settings_page.js", - "brave_overrides/sync_account_control.js", - "brave_overrides/sync_controls.js", - "brave_privacy_page/brave_personalization_options.m.js", - "brave_privacy_page/brave_privacy_page_browser_proxy.m.js", - "brave_reset_page/brave_reset_profile_dialog_behavior.js", - "brave_rewards_page/brave_rewards_browser_proxy.m.js", - "brave_rewards_page/brave_rewards_page.js", - "brave_routes.js", - "brave_search_engines_page/brave_search_engines_page.js", - "brave_search_engines_page/brave_search_engines_page_browser_proxy.m.js", - "brave_sync_page/brave_sync_browser_proxy.js", - "brave_sync_page/brave_sync_code_dialog.js", - "brave_sync_page/brave_sync_configure.js", - "brave_sync_page/brave_sync_page.js", - "brave_sync_page/brave_sync_setup.js", - "brave_sync_page/brave_sync_subpage.js", - "brave_tor_page/brave_tor_browser_proxy.js", - "brave_tor_page/brave_tor_bridges_dialog.js", - "brave_tor_page/brave_tor_subpage.js", - "brave_wallet_page/add_wallet_network_dialog.js", - "brave_wallet_page/brave_wallet_browser_proxy.m.js", - "brave_wallet_page/brave_wallet_page.js", - "brave_wallet_page/wallet_networks_list.js", - "brave_wallet_page/wallet_networks_subpage.js", - "default_brave_shields_page/default_brave_shields_browser_proxy.m.js", - "default_brave_shields_page/default_brave_shields_page.js", - "default_brave_shields_page/brave_adblock_subpage.js", - "default_brave_shields_page/brave_adblock_browser_proxy.js", - "default_brave_shields_page/components/brave_adblock_subscribe_dropdown.js", - "default_brave_shields_page/components/brave_adblock_editor.js", - "getting_started_page/getting_started.js", - "social_blocking_page/social_blocking_page.m.js", +# Provide our file list to chromium's settings page build +# Since our components start in a different path, we'll do the first step (move them to +# the generated preprocessed path via preprocess_if_expr, but let chromium handle the rest of the +# webui build pipeline. +brave_settings_preprocess_deps = + [ "//brave/browser/resources/settings:preprocess" ] +brave_settings_web_component_files = [ + "brave_appearance_page/brave_theme.ts", + "brave_appearance_page/sidebar.ts", + "brave_appearance_page/super_referral.ts", + "brave_appearance_page/toolbar.ts", + "brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.ts", + "brave_default_extensions_page/brave_default_extensions_page.ts", + "brave_help_tips_page/brave_help_tips_page.ts", + "brave_ipfs_page/brave_ipfs_page.ts", + "brave_ipfs_page/change_ipfs_gateway_dialog.ts", + "brave_ipfs_page/add_p2p_key_dialog.ts", + "brave_ipfs_page/rotate_p2p_key_dialog.ts", + "brave_ipfs_page/p2p_keys_subpage.ts", + "brave_ipfs_page/ipfs_peers_subpage.ts", + "brave_ipfs_page/add_ipfs_peer_dialog.ts", + "brave_new_tab_page/brave_new_tab_page.ts", + "brave_privacy_page/brave_personalization_options.ts", + "brave_rewards_page/brave_rewards_page.ts", + "brave_search_engines_page/brave_search_engines_page.ts", + "brave_sync_page/brave_sync_code_dialog.ts", + "brave_sync_page/brave_sync_configure.ts", + "brave_sync_page/brave_sync_page.ts", + "brave_sync_page/brave_sync_setup.ts", + "brave_sync_page/brave_sync_subpage.ts", + "brave_tor_page/brave_tor_bridges_dialog.ts", + "brave_tor_page/brave_tor_subpage.ts", + "brave_wallet_page/add_wallet_network_dialog.ts", + "brave_wallet_page/brave_wallet_page.ts", + "brave_wallet_page/wallet_networks_list.ts", + "brave_wallet_page/wallet_networks_subpage.ts", + "default_brave_shields_page/default_brave_shields_page.ts", + "default_brave_shields_page/brave_adblock_subpage.ts", + "default_brave_shields_page/components/brave_adblock_subscribe_dropdown.ts", + "default_brave_shields_page/components/brave_adblock_editor.ts", + "getting_started_page/getting_started.ts", + "social_blocking_page/social_blocking_page.ts", ] - -brave_deps_chrome_browser_resources_settings_extra_deps = [ - "//brave/browser/resources/settings:preprocess", - "//brave/browser/resources/settings:preprocess_generated", +brave_settings_non_web_component_files = [ + "brave_appearance_page/brave_appearance_browser_proxy.ts", + "brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.ts", + "brave_default_extensions_page/brave_default_extensions_browser_proxy.ts", + "brave_ipfs_page/brave_ipfs_browser_proxy.ts", + "brave_new_tab_page/brave_new_tab_browser_proxy.ts", + "brave_overrides/about_page.ts", + "brave_overrides/appearance_page.ts", + "brave_overrides/basic_page.ts", + "brave_overrides/clear_browsing_data_dialog.ts", + "brave_overrides/config.ts", + "brave_overrides/cookies_page.ts", + "brave_overrides/default_browser_page.ts", + "brave_overrides/icons.ts", + "brave_overrides/import_data_dialog.ts", + "brave_overrides/index.ts", + "brave_overrides/page_visibility.ts", + "brave_overrides/passwords_section.ts", + "brave_overrides/payments_section.ts", + "brave_overrides/people_page.ts", + "brave_overrides/personalization_options.ts", + "brave_overrides/printing_page.ts", + "brave_overrides/privacy_page.ts", + "brave_overrides/reset_profile_dialog.ts", + "brave_overrides/safety_check_passwords_child.ts", + "brave_overrides/search_page.ts", + "brave_overrides/security_page.ts", + "brave_overrides/settings_menu.ts", + "brave_overrides/settings_section.ts", + "brave_overrides/settings_ui.ts", + "brave_overrides/site_details.ts", + "brave_overrides/site_settings_page.ts", + "brave_overrides/sync_account_control.ts", + "brave_overrides/sync_controls.ts", + "brave_privacy_page/brave_privacy_page_browser_proxy.ts", + "brave_reset_page/brave_reset_profile_dialog_behavior.ts", + "brave_rewards_page/brave_rewards_browser_proxy.ts", + "brave_search_engines_page/brave_search_engines_page_browser_proxy.ts", + "brave_sync_page/brave_sync_browser_proxy.ts", + "brave_tor_page/brave_tor_browser_proxy.ts", + "brave_wallet_page/brave_wallet_browser_proxy.ts", + "default_brave_shields_page/brave_adblock_browser_proxy.ts", + "default_brave_shields_page/default_brave_shields_browser_proxy.ts", + "brave_routes.ts", +] +brave_settings_icons_html_files = [ "brave_icons.html" ] +brave_settings_ts_definitions = [ + "//brave/components/definitions/chrome_brave_theme.d.ts", + "//brave/components/definitions/chrome_ipfs.d.ts", + "//brave/components/definitions/chrome_brave_wallet.d.ts", ] + +# Generate the list for inclusion via preprocess and exclusion for chromium's preprocess +brave_settings_local_files = + brave_settings_web_component_files + + brave_settings_non_web_component_files + brave_settings_icons_html_files +foreach(component_file, brave_settings_web_component_files) { + brave_settings_local_files += + [ string_replace(component_file, ".ts", ".html") ] +} +brave_settings_exclude_preprocess_files = brave_settings_local_files + +brave_settings_ts_extra_deps = + [ "//brave/browser/resources/settings:preprocess" ] diff --git a/browser/resources/tools/brave_optimize_webui.gni b/browser/resources/tools/brave_optimize_webui.gni deleted file mode 100644 index d8e0d4b019b3..000000000000 --- a/browser/resources/tools/brave_optimize_webui.gni +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. - -brave_webui_deps = [ "//brave/ui/webui/resources:modulize" ] - -brave_resources_path = - rebase_path("$root_gen_dir/brave/ui/webui/resources/", root_build_dir) -brave_webui_external_paths = - [ "chrome://brave-resources/|$brave_resources_path" ] diff --git a/browser/sync/brave_sync_client_unittest.cc b/browser/sync/brave_sync_client_unittest.cc index 4320afb56246..db64ce3ed5af 100644 --- a/browser/sync/brave_sync_client_unittest.cc +++ b/browser/sync/brave_sync_client_unittest.cc @@ -21,7 +21,7 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/search_engines/search_engines_pref_names.h" -#include "components/sync/driver/test_sync_service.h" +#include "components/sync/test/test_sync_service.h" #include "components/sync_preferences/pref_service_mock_factory.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/test/browser_task_environment.h" diff --git a/browser/sync/brave_sync_devices_android.cc b/browser/sync/brave_sync_devices_android.cc index 6e9ce5824f0b..c9a129da2b87 100644 --- a/browser/sync/brave_sync_devices_android.cc +++ b/browser/sync/brave_sync_devices_android.cc @@ -74,15 +74,13 @@ base::Value::List BraveSyncDevicesAndroid::GetSyncDeviceList() { base::Value::List device_list; for (const auto& device : tracker->GetAllBraveDeviceInfo()) { - auto device_value = base::Value::FromUniquePtrValue(device->ToValue()); - bool is_current_device = local_device_info - ? local_device_info->guid() == device->guid() - : false; - device_value.SetBoolKey("isCurrentDevice", is_current_device); + auto device_value = device->ToValue(); + bool is_current_device = + local_device_info ? local_device_info->guid() == device->guid() : false; + device_value.Set("isCurrentDevice", is_current_device); // DeviceInfo::ToValue doesn't put guid - device_value.SetStringKey("guid", device->guid()); - device_value.SetBoolKey("supportsSelfDelete", - device->is_self_delete_supported()); + device_value.Set("guid", device->guid()); + device_value.Set("supportsSelfDelete", device->is_self_delete_supported()); device_list.Append(std::move(device_value)); } diff --git a/browser/tor/tor_profile_service_factory.cc b/browser/tor/tor_profile_service_factory.cc index eab441f6236f..30760a7c077e 100644 --- a/browser/tor/tor_profile_service_factory.cc +++ b/browser/tor/tor_profile_service_factory.cc @@ -63,9 +63,8 @@ void TorProfileServiceFactory::SetTorBridgesConfig( tor::BridgesConfig TorProfileServiceFactory::GetTorBridgesConfig() { if (!g_browser_process) return {}; - return tor::BridgesConfig::FromValue( - g_browser_process->local_state()->GetDictionary( - tor::prefs::kBridgesConfig)) + return tor::BridgesConfig::FromDict(g_browser_process->local_state()->GetDict( + tor::prefs::kBridgesConfig)) .value_or(tor::BridgesConfig()); } diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index b028279903f6..b172afb0a365 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -224,6 +224,8 @@ source_set("ui") { "views/side_panel/brave_side_panel.h", "views/tabs/brave_browser_tab_strip_controller.cc", "views/tabs/brave_browser_tab_strip_controller.h", + "views/tabs/brave_compound_tab_container.cc", + "views/tabs/brave_compound_tab_container.h", "views/tabs/brave_tab.cc", "views/tabs/brave_tab.h", "views/tabs/brave_tab_container.cc", @@ -468,8 +470,6 @@ source_set("ui") { deps += [ "//brave/app:brave_generated_resources_grit", "//brave/browser/brave_rewards:util", - "//brave/browser/resources/bookmarks:resources", - "//brave/browser/resources/history:resources", "//brave/browser/resources/settings:resources", "//brave/browser/ui/bookmark", "//brave/components/brave_adaptive_captcha", @@ -579,7 +579,6 @@ source_set("ui") { deps += [ "//brave/browser/extensions", - "//brave/browser/resources/extensions:resources", "//brave/components/brave_extension:generated_resources", "//brave/components/brave_extension:static_resources", "//brave/components/decentralized_dns", diff --git a/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/BraveAutocompleteCoordinator.java b/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/BraveAutocompleteCoordinator.java index 76f0c0e448f3..eac1b48a5f80 100644 --- a/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/BraveAutocompleteCoordinator.java +++ b/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/BraveAutocompleteCoordinator.java @@ -58,12 +58,13 @@ import java.util.List; public class BraveAutocompleteCoordinator { - public ViewProvider createViewProvider( - Context context, MVCListAdapter.ModelList modelList) { + public ViewProvider createViewProvider(Context context, + MVCListAdapter.ModelList modelList, LocationBarDataProvider locationBarDataProvider) { ViewProvider provider = (ViewProvider) BraveReflectionUtil.InvokeMethod( AutocompleteCoordinator.class, this, "createViewProvider", Context.class, - context, MVCListAdapter.ModelList.class, modelList); + context, MVCListAdapter.ModelList.class, modelList, + LocationBarDataProvider.class, locationBarDataProvider); return new ViewProvider() { private List> mCallbacks = new ArrayList<>(); diff --git a/browser/ui/android/strings/android_chrome_strings.grd b/browser/ui/android/strings/android_chrome_strings.grd index 3c11782ad7e8..a8813f105731 100644 --- a/browser/ui/android/strings/android_chrome_strings.grd +++ b/browser/ui/android/strings/android_chrome_strings.grd @@ -745,6 +745,12 @@ CHAR_LIMIT guidelines: The unified password manager was automatically disabled. Please submit an issue via the bug app! + + Not secure + + + To protect your privacy, Brave will not autofill your password in this field. + @@ -2101,6 +2107,9 @@ To change this setting, <resetlink>reset sync

Sign in again to start sync + + Sign back in to start sync + Make sure you can always access your sync data @@ -3871,6 +3880,12 @@ To change this setting, <resetlink>reset sync

Request desktop sites by default? + + Brave will remember your choice + + + When you select desktop site once, the setting is applied to the site each time you visit + @@ -4059,6 +4074,9 @@ To change this setting, <resetlink>reset sync

%1$s3 tabs closed + + Do you want to delete %1$sexample.pdf? + Deleted %1$sYouTube diff --git a/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsMediator.java b/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsMediator.java index 7887aead8bbf..a6c6a69eb3b6 100644 --- a/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsMediator.java +++ b/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsMediator.java @@ -9,6 +9,7 @@ import org.chromium.base.supplier.ObservableSupplierImpl; import org.chromium.chrome.browser.browser_controls.BrowserControlsSizer; import org.chromium.chrome.browser.fullscreen.FullscreenManager; +import org.chromium.chrome.browser.tab.TabObscuringHandler; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.modelutil.PropertyModel; @@ -28,9 +29,10 @@ class BraveBottomControlsMediator extends BottomControlsMediator { BraveBottomControlsMediator(WindowAndroid windowAndroid, PropertyModel model, BrowserControlsSizer controlsSizer, FullscreenManager fullscreenManager, - int bottomControlsHeight, ObservableSupplier overlayPanelVisibilitySupplier) { - super(windowAndroid, model, controlsSizer, fullscreenManager, bottomControlsHeight, - overlayPanelVisibilitySupplier); + TabObscuringHandler tabObscuringHandler, int bottomControlsHeight, + ObservableSupplier overlayPanelVisibilitySupplier) { + super(windowAndroid, model, controlsSizer, fullscreenManager, tabObscuringHandler, + bottomControlsHeight, overlayPanelVisibilitySupplier); mTabGroupUiVisibleSupplier.set(false); mBottomToolbarVisibleSupplier.set(false); diff --git a/browser/ui/omnibox/brave_omnibox_client_impl.cc b/browser/ui/omnibox/brave_omnibox_client_impl.cc index 6983b6bf446e..b0771c59201c 100644 --- a/browser/ui/omnibox/brave_omnibox_client_impl.cc +++ b/browser/ui/omnibox/brave_omnibox_client_impl.cc @@ -62,8 +62,7 @@ BraveOmniboxClientImpl::BraveOmniboxClientImpl( profile_(profile), scheme_classifier_(profile) { // Record initial search count p3a value. - const base::Value::List& search_p3a = - profile_->GetPrefs()->GetValueList(kSearchCountPrefName); + const auto& search_p3a = profile_->GetPrefs()->GetList(kSearchCountPrefName); if (search_p3a.size() == 0) { RecordSearchEventP3A(0); } diff --git a/browser/ui/toolbar/brave_app_menu_model.cc b/browser/ui/toolbar/brave_app_menu_model.cc index 75f8a538ba11..b3dad081f15b 100644 --- a/browser/ui/toolbar/brave_app_menu_model.cc +++ b/browser/ui/toolbar/brave_app_menu_model.cc @@ -280,8 +280,8 @@ void BraveAppMenuModel::InsertBraveMenuItems() { auto& bundle = ui::ResourceBundle::GetSharedInstance(); const auto& ipfs_logo = *bundle.GetImageSkiaNamed(IDR_BRAVE_IPFS_LOGO); - ui::ImageModel model = ui::ImageModel::FromImageSkia(ipfs_logo); - SetIcon(index, model); + ui::ImageModel image_model = ui::ImageModel::FromImageSkia(ipfs_logo); + SetIcon(index, image_model); } #endif } diff --git a/browser/ui/views/brave_actions/brave_actions_container.cc b/browser/ui/views/brave_actions/brave_actions_container.cc index 63e3fced2704..87d9e6c761f7 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.cc +++ b/browser/ui/views/brave_actions/brave_actions_container.cc @@ -538,3 +538,7 @@ void BraveActionsContainer::ToggleExtensionsMenu() {} bool BraveActionsContainer::HasAnyExtensions() const { return false; } + +void BraveActionsContainer::UpdateToolbarActionHoverCard( + ToolbarActionView* action_view, + ToolbarActionHoverCardUpdateType update_type) {} diff --git a/browser/ui/views/brave_actions/brave_actions_container.h b/browser/ui/views/brave_actions/brave_actions_container.h index 557665cb95db..4bc4c8940ec5 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.h +++ b/browser/ui/views/brave_actions/brave_actions_container.h @@ -160,6 +160,9 @@ class BraveActionsContainer : public views::View, std::unique_ptr bubble) override; void ToggleExtensionsMenu() override; bool HasAnyExtensions() const override; + void UpdateToolbarActionHoverCard( + ToolbarActionView* action_view, + ToolbarActionHoverCardUpdateType update_type) override; // Actions operations bool ShouldShowAction(const std::string& id) const; diff --git a/browser/ui/views/frame/brave_browser_view.cc b/browser/ui/views/frame/brave_browser_view.cc index ba05790fe140..cba2df6b2a22 100644 --- a/browser/ui/views/frame/brave_browser_view.cc +++ b/browser/ui/views/frame/brave_browser_view.cc @@ -182,12 +182,12 @@ BraveBrowserView::BraveBrowserView(std::unique_ptr browser) return; // Wrap chromium side panel with our sidebar container - auto original_side_panel = RemoveChildViewT(right_aligned_side_panel_.get()); + auto original_side_panel = RemoveChildViewT(unified_side_panel_.get()); sidebar_container_view_ = contents_container_->AddChildView(std::make_unique( GetBraveBrowser(), side_panel_coordinator(), std::move(original_side_panel))); - right_aligned_side_panel_ = sidebar_container_view_->side_panel(); + unified_side_panel_ = sidebar_container_view_->side_panel(); if (show_vertical_tabs) { vertical_tabs_container_ = contents_container_->AddChildView( std::make_unique(tab_strip_region_view_)); @@ -330,7 +330,7 @@ ShowTranslateBubbleResult BraveBrowserView::ShowTranslateBubble( translate::TranslateStep step, const std::string& source_language, const std::string& target_language, - translate::TranslateErrors::Type error_type, + translate::TranslateErrors error_type, bool is_user_gesture) { #if BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO) if (translate::IsInternalTranslationEnabled(GetProfile())) { diff --git a/browser/ui/views/frame/brave_browser_view.h b/browser/ui/views/frame/brave_browser_view.h index f2c3a2de99cf..400a8979a5fd 100644 --- a/browser/ui/views/frame/brave_browser_view.h +++ b/browser/ui/views/frame/brave_browser_view.h @@ -52,7 +52,7 @@ class BraveBrowserView : public BrowserView { translate::TranslateStep step, const std::string& source_language, const std::string& target_language, - translate::TranslateErrors::Type error_type, + translate::TranslateErrors error_type, bool is_user_gesture) override; speedreader::SpeedreaderBubbleView* ShowSpeedreaderBubble( speedreader::SpeedreaderTabHelper* tab_helper, diff --git a/browser/ui/views/frame/brave_contents_layout_manager.cc b/browser/ui/views/frame/brave_contents_layout_manager.cc index 3682c00e7614..efce06e399d8 100644 --- a/browser/ui/views/frame/brave_contents_layout_manager.cc +++ b/browser/ui/views/frame/brave_contents_layout_manager.cc @@ -31,10 +31,10 @@ void BraveContentsLayoutManager::Layout(views::View* contents_container) { if (!view || !view->GetVisible()) continue; - auto width = view->GetPreferredSize().width(); - const gfx::Rect bounds(taken_width, 0, width, height); + auto preferred_width = view->GetPreferredSize().width(); + const gfx::Rect bounds(taken_width, 0, preferred_width, height); view->SetBoundsRect(host_->GetMirroredRect(bounds)); - taken_width += width; + taken_width += preferred_width; } gfx::Size container_size(width - taken_width, height); diff --git a/browser/ui/views/frame/vertical_tab_strip_region_view.cc b/browser/ui/views/frame/vertical_tab_strip_region_view.cc index bc10d3ddaced..99b1516e65c1 100644 --- a/browser/ui/views/frame/vertical_tab_strip_region_view.cc +++ b/browser/ui/views/frame/vertical_tab_strip_region_view.cc @@ -260,8 +260,7 @@ void VerticalTabStripRegionView::UpdateLayout() { void VerticalTabStripRegionView::OnThemeChanged() { View::OnThemeChanged(); - auto background_color = - GetColorProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR); + const auto background_color = GetColorProvider()->GetColor(kColorToolbar); SetBackground(views::CreateSolidBackground(background_color)); scroll_view_->SetBackgroundColor(background_color); diff --git a/browser/ui/views/rounded_separator.cc b/browser/ui/views/rounded_separator.cc index d9022207b428..59792a842b44 100644 --- a/browser/ui/views/rounded_separator.cc +++ b/browser/ui/views/rounded_separator.cc @@ -48,8 +48,10 @@ gfx::Size RoundedSeparator::CalculatePreferredSize() const { } void RoundedSeparator::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_SEPARATOR)); + // A valid role must be set in the AXNodeData prior to setting the name + // via AXNodeData::SetName. node_data->role = ax::mojom::Role::kSplitter; + node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_SEPARATOR)); } void RoundedSeparator::OnPaint(gfx::Canvas* canvas) { diff --git a/browser/ui/views/side_panel/brave_side_panel.cc b/browser/ui/views/side_panel/brave_side_panel.cc index 6d721a15580e..465646702f13 100644 --- a/browser/ui/views/side_panel/brave_side_panel.cc +++ b/browser/ui/views/side_panel/brave_side_panel.cc @@ -33,7 +33,7 @@ BraveSidePanel::~BraveSidePanel() { void BraveSidePanel::SetHorizontalAlignment(HorizontalAlignment alignment) {} BraveSidePanel::HorizontalAlignment BraveSidePanel::GetHorizontalAlignment() { - return kAlignLeft; + return kHorizontalAlignLeft; } bool BraveSidePanel::IsRightAligned() { diff --git a/browser/ui/views/side_panel/brave_side_panel.h b/browser/ui/views/side_panel/brave_side_panel.h index c258634d5171..221fbb90eba2 100644 --- a/browser/ui/views/side_panel/brave_side_panel.h +++ b/browser/ui/views/side_panel/brave_side_panel.h @@ -23,13 +23,13 @@ class BraveSidePanel : public views::View, // LTR / RTL conversions are handled in // BrowserViewLayout::LayoutSidePanelView. As such, left will always be on the // left side of the browser regardless of LTR / RTL mode. - enum HorizontalAlignment { kAlignLeft = 0, kAlignRight }; + enum HorizontalAlignment { kHorizontalAlignLeft = 0, kHorizontalAlignRight }; METADATA_HEADER(BraveSidePanel); // Same signature as chromium SidePanel explicit BraveSidePanel(BrowserView* browser_view, HorizontalAlignment horizontal_alignment = - HorizontalAlignment::kAlignLeft); + HorizontalAlignment::kHorizontalAlignLeft); BraveSidePanel(const BraveSidePanel&) = delete; BraveSidePanel& operator=(const BraveSidePanel&) = delete; ~BraveSidePanel() override; diff --git a/browser/ui/views/sidebar/sidebar_container_view.cc b/browser/ui/views/sidebar/sidebar_container_view.cc index 30aa4b92702d..6ed2ec1604eb 100644 --- a/browser/ui/views/sidebar/sidebar_container_view.cc +++ b/browser/ui/views/sidebar/sidebar_container_view.cc @@ -391,7 +391,7 @@ void SidebarContainerView::OnEntryShown(SidePanelEntry* entry) { if (!item.open_in_panel) { continue; } - if (entry->id() == sidebar::SidePanelIdFromSideBarItem(item)) { + if (entry->key().id() == sidebar::SidePanelIdFromSideBarItem(item)) { auto side_bar_index = sidebar_model_->GetIndexOf(item); auto* controller = browser_->sidebar_controller(); controller->ActivateItemAt(side_bar_index); @@ -408,7 +408,7 @@ void SidebarContainerView::OnEntryHidden(SidePanelEntry* entry) { if (!item.open_in_panel) { continue; } - if (entry->id() == sidebar::SidePanelIdFromSideBarItem(item)) { + if (entry->key().id() == sidebar::SidePanelIdFromSideBarItem(item)) { auto side_bar_index = sidebar_model_->GetIndexOf(item); auto* controller = browser_->sidebar_controller(); if (controller->IsActiveIndex(side_bar_index)) { diff --git a/browser/ui/views/speedreader/speedreader_icon_view.cc b/browser/ui/views/speedreader/speedreader_icon_view.cc index 0d7f856f667c..b4696eebc3cc 100644 --- a/browser/ui/views/speedreader/speedreader_icon_view.cc +++ b/browser/ui/views/speedreader/speedreader_icon_view.cc @@ -38,7 +38,8 @@ SpeedreaderIconView::SpeedreaderIconView( : PageActionIconView(command_updater, IDC_SPEEDREADER_ICON_ONCLICK, icon_label_bubble_delegate, - page_action_icon_delegate) { + page_action_icon_delegate, + "SpeedReader") { SetVisible(false); } diff --git a/browser/ui/views/tabs/brave_compound_tab_container.cc b/browser/ui/views/tabs/brave_compound_tab_container.cc new file mode 100644 index 000000000000..7630fe50bbac --- /dev/null +++ b/browser/ui/views/tabs/brave_compound_tab_container.cc @@ -0,0 +1,30 @@ +/* Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/views/tabs/brave_compound_tab_container.h" + +#include + +#include "brave/browser/ui/views/tabs/features.h" +#include "ui/views/layout/flex_layout.h" + +BraveCompoundTabContainer::BraveCompoundTabContainer( + raw_ref controller, + TabHoverCardController* hover_card_controller, + TabDragContextBase* drag_context, + TabSlotController& tab_slot_controller, + views::View* scroll_contents_view) + : CompoundTabContainer(controller, + hover_card_controller, + drag_context, + tab_slot_controller, + scroll_contents_view) { + if (tabs::features::ShouldShowVerticalTabs()) { + SetLayoutManager(std::make_unique()) + ->SetOrientation(views::LayoutOrientation::kVertical); + } +} + +BraveCompoundTabContainer::~BraveCompoundTabContainer() {} diff --git a/browser/ui/views/tabs/brave_compound_tab_container.h b/browser/ui/views/tabs/brave_compound_tab_container.h new file mode 100644 index 000000000000..8bd3209c499b --- /dev/null +++ b/browser/ui/views/tabs/brave_compound_tab_container.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2022 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 http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_COMPOUND_TAB_CONTAINER_H_ +#define BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_COMPOUND_TAB_CONTAINER_H_ + +#include "chrome/browser/ui/views/tabs/compound_tab_container.h" + +class BraveCompoundTabContainer : public CompoundTabContainer { + public: + BraveCompoundTabContainer(raw_ref controller, + TabHoverCardController* hover_card_controller, + TabDragContextBase* drag_context, + TabSlotController& tab_slot_controller, + views::View* scroll_contents_view); + ~BraveCompoundTabContainer() override; +}; + +#endif // BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_COMPOUND_TAB_CONTAINER_H_ diff --git a/browser/ui/views/tabs/brave_tab_container.cc b/browser/ui/views/tabs/brave_tab_container.cc index 9cb9e8299633..fc7f5a65071f 100644 --- a/browser/ui/views/tabs/brave_tab_container.cc +++ b/browser/ui/views/tabs/brave_tab_container.cc @@ -13,7 +13,7 @@ BraveTabContainer::BraveTabContainer( TabContainerController& controller, TabHoverCardController* hover_card_controller, - TabDragContext* drag_context, + TabDragContextBase* drag_context, TabSlotController& tab_slot_controller, views::View* scroll_contents_view) : TabContainerImpl(controller, diff --git a/browser/ui/views/tabs/brave_tab_container.h b/browser/ui/views/tabs/brave_tab_container.h index bf56a7d56805..90beeed0e6a0 100644 --- a/browser/ui/views/tabs/brave_tab_container.h +++ b/browser/ui/views/tabs/brave_tab_container.h @@ -16,7 +16,7 @@ class BraveTabContainer : public TabContainerImpl { BraveTabContainer(TabContainerController& controller, TabHoverCardController* hover_card_controller, - TabDragContext* drag_context, + TabDragContextBase* drag_context, TabSlotController& tab_slot_controller, views::View* scroll_contents_view); ~BraveTabContainer() override; diff --git a/browser/ui/views/toolbar/brave_toolbar_view.cc b/browser/ui/views/toolbar/brave_toolbar_view.cc index 88a70cb2e9f0..e5240069789d 100644 --- a/browser/ui/views/toolbar/brave_toolbar_view.cc +++ b/browser/ui/views/toolbar/brave_toolbar_view.cc @@ -279,9 +279,9 @@ void BraveToolbarView::ShowBookmarkBubble( std::unique_ptr delegate; delegate = std::make_unique(browser()->profile()); - BookmarkBubbleView::ShowBubble(anchor_view, bookmark_, observer, - std::move(delegate), browser_->profile(), url, - already_bookmarked); + BookmarkBubbleView::ShowBubble(anchor_view, GetWebContents(), bookmark_, + observer, std::move(delegate), + browser_->profile(), url, already_bookmarked); } void BraveToolbarView::Layout() { diff --git a/browser/ui/views/toolbar/brave_toolbar_view_browsertest.cc b/browser/ui/views/toolbar/brave_toolbar_view_browsertest.cc index e0781b39eec9..468ed3a53475 100644 --- a/browser/ui/views/toolbar/brave_toolbar_view_browsertest.cc +++ b/browser/ui/views/toolbar/brave_toolbar_view_browsertest.cc @@ -16,6 +16,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profile_test_util.h" #include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/browser.h" @@ -41,15 +42,6 @@ #include "brave/components/brave_vpn/pref_names.h" #endif -// An observer that returns back to test code after a new profile is -// initialized. -void OnUnblockOnProfileCreation(base::RunLoop* run_loop, - Profile* profile, - Profile::CreateStatus status) { - if (status == Profile::CREATE_STATUS_INITIALIZED) - run_loop->Quit(); -} - class BraveToolbarViewTest : public InProcessBrowserTest { public: BraveToolbarViewTest() { @@ -155,12 +147,10 @@ IN_PROC_BROWSER_TEST_F(BraveToolbarViewTest, profile_manager->GetProfileAttributesStorage(); base::FilePath current_profile_path = browser()->profile()->GetPath(); base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath(); - base::RunLoop run_loop; - profile_manager->CreateProfileAsync( - new_path, base::BindRepeating(&OnUnblockOnProfileCreation, &run_loop)); - run_loop.Run(); + Profile* new_profile = + profiles::testing::CreateProfileSync(profile_manager, new_path); + EXPECT_TRUE(new_profile); ASSERT_EQ(2u, storage.GetNumberOfProfiles()); - Profile* new_profile = profile_manager->GetProfileByPath(new_path); // check it's now shown in first profile EXPECT_EQ(true, is_avatar_button_shown()); diff --git a/browser/ui/webui/brave_vpn/vpn_panel_ui.cc b/browser/ui/webui/brave_vpn/vpn_panel_ui.cc index ef45ed80f2ca..2fb649cf5745 100644 --- a/browser/ui/webui/brave_vpn/vpn_panel_ui.cc +++ b/browser/ui/webui/brave_vpn/vpn_panel_ui.cc @@ -54,11 +54,11 @@ VPNPanelUI::VPNPanelUI(content::WebUI* web_ui) source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::StyleSrc, std::string("style-src chrome-untrusted://resources " - "chrome-untrusted://brave-resources 'unsafe-inline';")); + "'unsafe-inline';")); source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::FontSrc, - std::string("font-src chrome-untrusted://brave-resources " + std::string("font-src " "chrome-untrusted://resources;")); content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), diff --git a/browser/ui/webui/brave_wallet/common_handler/wallet_handler.h b/browser/ui/webui/brave_wallet/common_handler/wallet_handler.h index 87f6524a52d1..6a22d35e144d 100644 --- a/browser/ui/webui/brave_wallet/common_handler/wallet_handler.h +++ b/browser/ui/webui/brave_wallet/common_handler/wallet_handler.h @@ -13,6 +13,7 @@ #include "base/memory/weak_ptr.h" #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" class Profile; diff --git a/browser/ui/webui/brave_wallet/market/market_ui.cc b/browser/ui/webui/brave_wallet/market/market_ui.cc index a182eb1c13b9..4fbe510dfeff 100644 --- a/browser/ui/webui/brave_wallet/market/market_ui.cc +++ b/browser/ui/webui/brave_wallet/market/market_ui.cc @@ -43,8 +43,7 @@ UntrustedMarketUI::UntrustedMarketUI(content::WebUI* web_ui) untrusted_source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::ScriptSrc, - std::string("script-src 'self' chrome-untrusted://resources " - "chrome-untrusted://brave-resources;")); + std::string("script-src 'self' chrome-untrusted://resources;")); untrusted_source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::StyleSrc, std::string("style-src 'self' 'unsafe-inline';")); diff --git a/browser/ui/webui/brave_wallet/nft/nft_ui.cc b/browser/ui/webui/brave_wallet/nft/nft_ui.cc index 2c2cf7d02d03..a7f98376768b 100644 --- a/browser/ui/webui/brave_wallet/nft/nft_ui.cc +++ b/browser/ui/webui/brave_wallet/nft/nft_ui.cc @@ -42,8 +42,7 @@ UntrustedNftUI::UntrustedNftUI(content::WebUI* web_ui) IDR_BRAVE_WALLET_NFT_DISPLAY_HTML); untrusted_source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::ScriptSrc, - std::string("script-src 'self' chrome-untrusted://resources " - "chrome-untrusted://brave-resources;")); + std::string("script-src 'self' chrome-untrusted://resources;")); untrusted_source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::StyleSrc, std::string("style-src 'self' 'unsafe-inline';")); diff --git a/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.html b/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.html index e8b232d1a078..e1ff37fc7775 100644 --- a/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.html +++ b/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.html @@ -9,7 +9,7 @@ - + -+ ++ diff --git a/patches/chrome-browser-resources-bookmarks-bookmarks.ts.patch b/patches/chrome-browser-resources-bookmarks-bookmarks.ts.patch index 43fe3def407e..942e5a1b96f1 100644 --- a/patches/chrome-browser-resources-bookmarks-bookmarks.ts.patch +++ b/patches/chrome-browser-resources-bookmarks-bookmarks.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/bookmarks/bookmarks.ts b/chrome/browser/resources/bookmarks/bookmarks.ts -index c37aa314fba3be1e10193c17b56cafac66d19832..0399a5e80b1f778cd652aa78388726f933135f58 100644 +index e18d2f4269c72f8bfb1d46e16d443c4749836ae7..0ac13d17be6e694b3d7bdab6b19fff3397d48126 100644 --- a/chrome/browser/resources/bookmarks/bookmarks.ts +++ b/chrome/browser/resources/bookmarks/bookmarks.ts @@ -2,6 +2,7 @@ diff --git a/patches/chrome-browser-resources-bookmarks-command_manager.ts.patch b/patches/chrome-browser-resources-bookmarks-command_manager.ts.patch index 209fc447ff4b..9e31a57f1ee3 100644 --- a/patches/chrome-browser-resources-bookmarks-command_manager.ts.patch +++ b/patches/chrome-browser-resources-bookmarks-command_manager.ts.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/resources/bookmarks/command_manager.ts b/chrome/browser/resources/bookmarks/command_manager.ts -index f24552cae88663a5f3d57d2e9d2108be94db4d33..c7c05e4237c0314469db3a46af8e267430c39eaf 100644 +index 75c1f82f10c614a959ac43c2354022f1d9150453..eb07ff987e174166a367c3917525d9c9d726d5d9 100644 --- a/chrome/browser/resources/bookmarks/command_manager.ts +++ b/chrome/browser/resources/bookmarks/command_manager.ts -@@ -428,7 +428,7 @@ export class BookmarksCommandManagerElement extends +@@ -427,7 +427,7 @@ export class BookmarksCommandManagerElement extends chrome.bookmarks.export(); break; case Command.HELP_CENTER: diff --git a/patches/chrome-browser-resources-bookmarks-reducers.ts.patch b/patches/chrome-browser-resources-bookmarks-reducers.ts.patch index cdad0f57bb5c..fbbec3b62125 100644 --- a/patches/chrome-browser-resources-bookmarks-reducers.ts.patch +++ b/patches/chrome-browser-resources-bookmarks-reducers.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/bookmarks/reducers.ts b/chrome/browser/resources/bookmarks/reducers.ts -index a0fc02df2a76ac5907b50a8e06df971335e7fcbf..733a3981c6d3c51e8b04ca9e17cfbe002a40ba7d 100644 +index 4a20202914f56bc3073a15b0462411806be12614..c8b3dd6ae17022f093689357f35b7a730387d887 100644 --- a/chrome/browser/resources/bookmarks/reducers.ts +++ b/chrome/browser/resources/bookmarks/reducers.ts @@ -193,6 +193,9 @@ function editBookmark(nodes: NodeMap, action: EditBookmarkAction): NodeMap { diff --git a/patches/chrome-browser-resources-downloads-downloads.html.patch b/patches/chrome-browser-resources-downloads-downloads.html.patch index 0859406f8ec3..e33051b1a2e0 100644 --- a/patches/chrome-browser-resources-downloads-downloads.html.patch +++ b/patches/chrome-browser-resources-downloads-downloads.html.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/resources/downloads/downloads.html b/chrome/browser/resources/downloads/downloads.html -index 61d82b65d9315f9ba29c1ad5358b1555669a2d4f..6a53d31b4959da8a8f10ce6ae5a61ffe763afa6d 100644 +index 61d82b65d9315f9ba29c1ad5358b1555669a2d4f..2370273c52b29c054965ce4193d5aa066b508569 100644 --- a/chrome/browser/resources/downloads/downloads.html +++ b/chrome/browser/resources/downloads/downloads.html @@ -6,6 +6,7 @@ $i18n{title} -+ ++ -+ ++ diff --git a/patches/chrome-browser-resources-extensions-extensions.ts.patch b/patches/chrome-browser-resources-extensions-extensions.ts.patch index b463f9463b91..3c7fae2c2e81 100644 --- a/patches/chrome-browser-resources-extensions-extensions.ts.patch +++ b/patches/chrome-browser-resources-extensions-extensions.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/extensions/extensions.ts b/chrome/browser/resources/extensions/extensions.ts -index 4d1af5fe9061370e94c18a60c1fd3e450138e1c2..b430ebc078244eeacbf716a8a4605ba863297cb6 100644 +index 915b5517fa2e11f9366ef4f6b9c634d3615ff9cd..42ae4c0f261b4362d87bbcec44eddce38e0f1d8d 100644 --- a/chrome/browser/resources/extensions/extensions.ts +++ b/chrome/browser/resources/extensions/extensions.ts @@ -2,6 +2,7 @@ diff --git a/patches/chrome-browser-resources-extensions-item_list.ts.patch b/patches/chrome-browser-resources-extensions-item_list.ts.patch index 0dfefe945a20..711dca9433b8 100644 --- a/patches/chrome-browser-resources-extensions-item_list.ts.patch +++ b/patches/chrome-browser-resources-extensions-item_list.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/extensions/item_list.ts b/chrome/browser/resources/extensions/item_list.ts -index c8943c3e392c431effbd57c5142def9a889a66ce..00a65805a1a6c5486b800b5dd1140ec5c54ae138 100644 +index 821c3bec9f76d32b185fd8bdd8ed132253b9b7d3..c9e319bcb9e2d4df16005a3df1fc52a2e3918b41 100644 --- a/chrome/browser/resources/extensions/item_list.ts +++ b/chrome/browser/resources/extensions/item_list.ts @@ -13,6 +13,7 @@ import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bu diff --git a/patches/chrome-browser-resources-history-BUILD.gn.patch b/patches/chrome-browser-resources-history-BUILD.gn.patch index 9405b5e1260a..71bf445dc52c 100644 --- a/patches/chrome-browser-resources-history-BUILD.gn.patch +++ b/patches/chrome-browser-resources-history-BUILD.gn.patch @@ -1,10 +1,10 @@ diff --git a/chrome/browser/resources/history/BUILD.gn b/chrome/browser/resources/history/BUILD.gn -index cbfe95d9eca7e0c57a1e02ed6c35c4a49a4c2d11..21f18e1f82bee5a96750a814c043fe5a62465e9f 100644 +index 278a88cda47c47382e7793bc9c69bc1bac72ccd5..0795680a37ba23560fb3e094b8287695913771e2 100644 --- a/chrome/browser/resources/history/BUILD.gn +++ b/chrome/browser/resources/history/BUILD.gn @@ -80,4 +80,5 @@ build_webui("build") { "lazy_load.rollup.js|lazy_load.js", ] } -+ extra_build_grd_deps = [ "//brave/browser/resources/history:resources" ] extra_build_ts_in_files = brave_deps_chrome_browser_resources_history_in_files extra_build_ts_extra_deps = brave_deps_chrome_browser_resources_history_extra_deps ++ import("//brave/browser/resources/history/sources.gni") web_component_files += brave_history_web_component_files non_web_component_files += brave_history_non_web_component_files exclude_preprocess_files = brave_history_local_files preprocess_deps = brave_history_preprocess_extra_deps } diff --git a/patches/chrome-browser-resources-history-history.html.patch b/patches/chrome-browser-resources-history-history.html.patch index c247a4ade948..28bd0661e267 100644 --- a/patches/chrome-browser-resources-history-history.html.patch +++ b/patches/chrome-browser-resources-history-history.html.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/resources/history/history.html b/chrome/browser/resources/history/history.html -index 43ddfb1a0c1cb77d9fee7f0f4c5fe18371ae24dc..b2a69f071dedb3ab8b58bde37213698ed9b0c14e 100644 +index 43ddfb1a0c1cb77d9fee7f0f4c5fe18371ae24dc..51022f49680d95884126b6a343191a6d33b424c1 100644 --- a/chrome/browser/resources/history/history.html +++ b/chrome/browser/resources/history/history.html @@ -84,6 +84,7 @@ justify-content: center; } -+ ++ diff --git a/patches/chrome-browser-resources-history-history.ts.patch b/patches/chrome-browser-resources-history-history.ts.patch index 2388b37d976f..0f16f3160b07 100644 --- a/patches/chrome-browser-resources-history-history.ts.patch +++ b/patches/chrome-browser-resources-history-history.ts.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/resources/history/history.ts b/chrome/browser/resources/history/history.ts -index 7f32e0582a7c750f84c32b78d7cbc7f35dcf5167..47da27748609c3f82ebfa49771236f86bace8819 100644 +index c0b28c68e9a75af46aea79e4388355a4df26e879..a1b67fcffd029135bf5de80658f6e6b7bf2ce334 100644 --- a/chrome/browser/resources/history/history.ts +++ b/chrome/browser/resources/history/history.ts @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -+import 'chrome://brave-resources/polymer_overriding.js' ++import 'chrome://resources/polymer_overriding.js' +import './brave_overrides/index.js'; import './app.js'; diff --git a/patches/chrome-browser-resources-history-history_item.ts.patch b/patches/chrome-browser-resources-history-history_item.ts.patch index 2ba03c3292c2..a7569f037cff 100644 --- a/patches/chrome-browser-resources-history-history_item.ts.patch +++ b/patches/chrome-browser-resources-history-history_item.ts.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/resources/history/history_item.ts b/chrome/browser/resources/history/history_item.ts -index e69fd497e3c2940e0e78406425c00e7e6f80a9cb..f2ad216f0704493160fd1338601c0d9b2d2f3735 100644 +index eb219891f50349114b608fde25ef06283e7f69d3..98c843583e22d932e20229126b3aeee50c758572 100644 --- a/chrome/browser/resources/history/history_item.ts +++ b/chrome/browser/resources/history/history_item.ts -@@ -9,6 +9,7 @@ import 'chrome://resources/cr_elements/cr_icons_css.m.js'; - import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +@@ -9,6 +9,7 @@ import 'chrome://resources/cr_elements/cr_icons.css.js'; + import 'chrome://resources/cr_elements/cr_shared_vars.css.js'; import 'chrome://resources/js/icon.js'; import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; -+import 'chrome://brave-resources/page_specific/history/brave_history_item.m.js' ++import './brave_history_item.js' import {CrCheckboxElement} from 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.js'; import {CrIconButtonElement} from 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.js'; diff --git a/patches/chrome-browser-resources-history-shared_style.css.patch b/patches/chrome-browser-resources-history-shared_style.css.patch index b7f9dad6b502..bc6a1dec8b66 100644 --- a/patches/chrome-browser-resources-history-shared_style.css.patch +++ b/patches/chrome-browser-resources-history-shared_style.css.patch @@ -1,11 +1,11 @@ diff --git a/chrome/browser/resources/history/shared_style.css b/chrome/browser/resources/history/shared_style.css -index 3cabafa5881164b3b8f6dbd14010e210fe0f7f8f..50a76e5b381f35ea70fa62e47fd800aaf4aed4fe 100644 +index 12398fbab88c139f6e4a211d18ae8c7119512676..37487dc865a4733aad5e616e98fdfa52c722d0f1 100644 --- a/chrome/browser/resources/history/shared_style.css +++ b/chrome/browser/resources/history/shared_style.css @@ -7,7 +7,7 @@ * #import=./shared_vars.css.js - * #import=chrome://resources/cr_elements/hidden_style_css.m.js - * #import=chrome://resources/cr_elements/shared_vars_css.m.js + * #import=chrome://resources/cr_elements/cr_hidden_style.css.js + * #import=chrome://resources/cr_elements/cr_shared_vars.css.js - * #include=cr-hidden-style + * #include=cr-hidden-style br-shared-style * #css_wrapper_metadata_end */ diff --git a/patches/chrome-browser-resources-settings-BUILD.gn.patch b/patches/chrome-browser-resources-settings-BUILD.gn.patch index 02022878a131..6542b45ac92f 100644 --- a/patches/chrome-browser-resources-settings-BUILD.gn.patch +++ b/patches/chrome-browser-resources-settings-BUILD.gn.patch @@ -1,10 +1,10 @@ diff --git a/chrome/browser/resources/settings/BUILD.gn b/chrome/browser/resources/settings/BUILD.gn -index ab01660acd836acb11a241bd3ff29790201baf60..1e85dc35af61c74d3cc0794ea1798b009aaea207 100644 +index 7c80c698a09d669494b89e3280a4960d7e59fbaa..29e2bbd38e1f677051c9715f35bb7d9ff678eea6 100644 --- a/chrome/browser/resources/settings/BUILD.gn +++ b/chrome/browser/resources/settings/BUILD.gn -@@ -478,4 +478,5 @@ build_webui("build") { +@@ -484,4 +484,5 @@ build_webui("build") { "lazy_load.rollup.js|lazy_load.js", ] } -+ extra_build_ts_in_files = brave_deps_chrome_browser_resources_settings_in_files extra_build_ts_extra_deps = brave_deps_chrome_browser_resources_settings_extra_deps extra_build_grd_deps = [ "//brave/browser/resources/settings:resources" ] ++ import("//brave/browser/resources/settings/sources.gni") web_component_files += brave_settings_web_component_files non_web_component_files += brave_settings_non_web_component_files icons_html_files += brave_settings_icons_html_files exclude_preprocess_files = brave_settings_exclude_preprocess_files preprocess_deps = brave_settings_preprocess_deps ts_extra_deps = brave_settings_ts_extra_deps ts_definitions += brave_settings_ts_definitions if (optimize_webui) { extra_grdp_deps += [ "//brave/browser/resources/settings:resources" ] } } diff --git a/patches/chrome-browser-resources-settings-people_page-sync_controls.ts.patch b/patches/chrome-browser-resources-settings-people_page-sync_controls.ts.patch index 9325cd8446bb..427c5b4e53e0 100644 --- a/patches/chrome-browser-resources-settings-people_page-sync_controls.ts.patch +++ b/patches/chrome-browser-resources-settings-people_page-sync_controls.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/people_page/sync_controls.ts b/chrome/browser/resources/settings/people_page/sync_controls.ts -index 8dac3283d78f6ef50459d5efed93921afb93b9a5..b77a0f94981b23a54d81aecd07582ba7bfad604f 100644 +index f717ebc28617c941ec7436cbe4ffacaef1d28437..069d0e7108ee3f5617d8f92c0a568c6405ca17c3 100644 --- a/chrome/browser/resources/settings/people_page/sync_controls.ts +++ b/chrome/browser/resources/settings/people_page/sync_controls.ts @@ -100,7 +100,7 @@ export class SettingsSyncControlsElement extends diff --git a/patches/chrome-browser-resources-settings-privacy_page-personalization_options.html.patch b/patches/chrome-browser-resources-settings-privacy_page-personalization_options.html.patch index f0c490592d1f..cb28a64a4b90 100644 --- a/patches/chrome-browser-resources-settings-privacy_page-personalization_options.html.patch +++ b/patches/chrome-browser-resources-settings-privacy_page-personalization_options.html.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/privacy_page/personalization_options.html b/chrome/browser/resources/settings/privacy_page/personalization_options.html -index 56fda9d97da5a58cb623f0d375f5a172c9836af4..1a731902a0d3c0e8c67da3ac198b1e0c4a24d91b 100644 +index c01b1dcf517e95faf4f808cf85799ee4319d68a6..034cc3865d3ca51c023ae8e562c711227a46820e 100644 --- a/chrome/browser/resources/settings/privacy_page/personalization_options.html +++ b/chrome/browser/resources/settings/privacy_page/personalization_options.html @@ -13,6 +13,7 @@ @@ -43,7 +43,7 @@ index 56fda9d97da5a58cb623f0d375f5a172c9836af4..1a731902a0d3c0e8c67da3ac198b1e0c @@ -51,7 +51,7 @@ index 56fda9d97da5a58cb623f0d375f5a172c9836af4..1a731902a0d3c0e8c67da3ac198b1e0c diff --git a/patches/chrome-browser-resources-settings-privacy_page-personalization_options.ts.patch b/patches/chrome-browser-resources-settings-privacy_page-personalization_options.ts.patch index 29e13f95326f..4f0c717d1d86 100644 --- a/patches/chrome-browser-resources-settings-privacy_page-personalization_options.ts.patch +++ b/patches/chrome-browser-resources-settings-privacy_page-personalization_options.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/privacy_page/personalization_options.ts b/chrome/browser/resources/settings/privacy_page/personalization_options.ts -index bd223d35037bbd5344b8c56b3f1f963e80987a9d..7483cf5d860fc8ed518ec64defe1cf094573a0a3 100644 +index 1e88b59d3b15e51349011c4db1f989b388997514..aada570acf431fa8b57d43845929917339c07585 100644 --- a/chrome/browser/resources/settings/privacy_page/personalization_options.ts +++ b/chrome/browser/resources/settings/privacy_page/personalization_options.ts @@ -76,7 +76,7 @@ export class SettingsPersonalizationOptionsElement extends @@ -20,7 +20,7 @@ index bd223d35037bbd5344b8c56b3f1f963e80987a9d..7483cf5d860fc8ed518ec64defe1cf09 private metricsReportingPref_: chrome.settingsPrivate.PrefObject; private showRestart_: boolean; // -@@ -159,7 +159,7 @@ export class SettingsPersonalizationOptionsElement extends +@@ -177,7 +177,7 @@ export class SettingsPersonalizationOptionsElement extends override ready() { super.ready(); @@ -29,7 +29,7 @@ index bd223d35037bbd5344b8c56b3f1f963e80987a9d..7483cf5d860fc8ed518ec64defe1cf09 const setMetricsReportingPref = (metricsReporting: MetricsReporting) => this.setMetricsReportingPref_(metricsReporting); this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref); -@@ -193,7 +193,7 @@ export class SettingsPersonalizationOptionsElement extends +@@ -211,7 +211,7 @@ export class SettingsPersonalizationOptionsElement extends } // diff --git a/patches/chrome-browser-resources-settings-privacy_page-privacy_page.html.patch b/patches/chrome-browser-resources-settings-privacy_page-privacy_page.html.patch index 82f02906f0e4..d77db73cfc7e 100644 --- a/patches/chrome-browser-resources-settings-privacy_page-privacy_page.html.patch +++ b/patches/chrome-browser-resources-settings-privacy_page-privacy_page.html.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chrome/browser/resources/settings/privacy_page/privacy_page.html -index bc7b142ab26cd337882074c485bf8bed98890735..80f346d301ac6b2bc044a2685e16586fc316f629 100644 +index 74a2dc418d5f2c22a97ca4246bc441903051a5e4..1ddc06d19c84b17f6eba29cd44e575ea20ee34d6 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_page.html +++ b/chrome/browser/resources/settings/privacy_page/privacy_page.html @@ -40,6 +40,7 @@ diff --git a/patches/chrome-browser-resources-settings-privacy_page-privacy_page.ts.patch b/patches/chrome-browser-resources-settings-privacy_page-privacy_page.ts.patch index a93b50ae4399..f223ac325d5b 100644 --- a/patches/chrome-browser-resources-settings-privacy_page-privacy_page.ts.patch +++ b/patches/chrome-browser-resources-settings-privacy_page-privacy_page.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page.ts b/chrome/browser/resources/settings/privacy_page/privacy_page.ts -index 846b872f9b9019de1f906e91bd86285c04c727e8..260a330b35bfb8e2c84e453e57f0a21741db9dfa 100644 +index 26cea4c3745f6e09f4c36c3e85a8975db283a2b1..be7a2f763a823ea5c9b4ae8860477e71fee00a4a 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_page.ts +++ b/chrome/browser/resources/settings/privacy_page/privacy_page.ts @@ -19,6 +19,7 @@ import '../site_settings/site_data_details_subpage.js'; diff --git a/patches/chrome-browser-resources-settings-privacy_page-privacy_page_browser_proxy.ts.patch b/patches/chrome-browser-resources-settings-privacy_page-privacy_page_browser_proxy.ts.patch index 05b4cd91a779..43b070fb149c 100644 --- a/patches/chrome-browser-resources-settings-privacy_page-privacy_page_browser_proxy.ts.patch +++ b/patches/chrome-browser-resources-settings-privacy_page-privacy_page_browser_proxy.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/privacy_page/privacy_page_browser_proxy.ts b/chrome/browser/resources/settings/privacy_page/privacy_page_browser_proxy.ts -index 79866f2afd1c41df8ba5df07c52e6afe0209accb..978453fdbfa4445dd33c2958f96899f161a44190 100644 +index 6e946be0031b2639e9023459002f188cfd85a135..08b5d26a5818dea5f3ff160e3dc8eb031d4e4ef8 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_page_browser_proxy.ts +++ b/chrome/browser/resources/settings/privacy_page/privacy_page_browser_proxy.ts @@ -46,7 +46,7 @@ export interface SecureDnsSetting { diff --git a/patches/chrome-browser-resources-settings-route.ts.patch b/patches/chrome-browser-resources-settings-route.ts.patch index f79087064351..4d34c4134b15 100644 --- a/patches/chrome-browser-resources-settings-route.ts.patch +++ b/patches/chrome-browser-resources-settings-route.ts.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/settings/route.ts b/chrome/browser/resources/settings/route.ts -index 277f1946c3a6812d1b6378955bafcacae43b4516..52a8b87caf0cf8d6298f0b2f295f2471caee9f93 100644 +index 41a387fa349357c97f866dfebfeec8aafc42cf93..c0f7453fcc962ed6f5c2e3d73ad7ccd7eb4a5232 100644 --- a/chrome/browser/resources/settings/route.ts +++ b/chrome/browser/resources/settings/route.ts @@ -9,6 +9,7 @@ import {pageVisibility} from './page_visibility.js'; @@ -10,8 +10,8 @@ index 277f1946c3a6812d1b6378955bafcacae43b4516..52a8b87caf0cf8d6298f0b2f295f2471 /** * Add all of the child routes that originate from the privacy route, * regardless of whether the privacy section under basic or advanced. -@@ -236,6 +237,7 @@ function createBrowserSettingsRoutes(): Partial { - // +@@ -244,6 +245,7 @@ function createBrowserSettingsRoutes(): Partial { + loadTimeData.getString('performancePageTitle')); } } + addBraveRoutes(r); diff --git a/patches/chrome-browser-resources-settings-settings.html.patch b/patches/chrome-browser-resources-settings-settings.html.patch index 2130164839a8..355240b459f9 100644 --- a/patches/chrome-browser-resources-settings-settings.html.patch +++ b/patches/chrome-browser-resources-settings-settings.html.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/resources/settings/settings.html b/chrome/browser/resources/settings/settings.html -index a76a774208f5869003ec650d8107f6983dc101e6..d8b321a828d70513f96609c30f8d3e1f633a2542 100644 +index a76a774208f5869003ec650d8107f6983dc101e6..0cc6f6abb4bc2cc56afa682620a42f40e7ac56b8 100644 --- a/chrome/browser/resources/settings/settings.html +++ b/chrome/browser/resources/settings/settings.html @@ -5,6 +5,7 @@ $i18n{settings} -+ ++ - - diff --git a/ui/webui/resources/br_elements/shared_vars_css.html b/ui/webui/resources/br_elements/shared_vars_css.html deleted file mode 100644 index 0d2afe281520..000000000000 --- a/ui/webui/resources/br_elements/shared_vars_css.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - diff --git a/ui/webui/resources/br_elements_resources_v3.grdp b/ui/webui/resources/br_elements_resources_v3.grdp index ea1761d74019..4cea25f627e3 100644 --- a/ui/webui/resources/br_elements_resources_v3.grdp +++ b/ui/webui/resources/br_elements_resources_v3.grdp @@ -14,14 +14,14 @@ type="BINDATA" compress="gzip" /> diff --git a/ui/webui/resources/brave_webui_resources.grd b/ui/webui/resources/brave_webui_resources.grd index c03017b35f1b..e4c36c593c3c 100644 --- a/ui/webui/resources/brave_webui_resources.grd +++ b/ui/webui/resources/brave_webui_resources.grd @@ -25,15 +25,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ui/webui/resources/overrides/cr_button.js b/ui/webui/resources/overrides/cr_button.js deleted file mode 100644 index d15fc5fbd2e2..000000000000 --- a/ui/webui/resources/overrides/cr_button.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' - -export default html` - -` diff --git a/ui/webui/resources/overrides/cr_button_override.css b/ui/webui/resources/overrides/cr_button_override.css new file mode 100644 index 000000000000..cedb120ed700 --- /dev/null +++ b/ui/webui/resources/overrides/cr_button_override.css @@ -0,0 +1,50 @@ +/* #css_wrapper_metadata_start + * #type=style + * #scheme=relative + * #css_wrapper_metadata_end */ + +/* Default/light theme button colors */ +:host(:not([style])) { + --brave-text-color: #3b3e4f; /* grey800 */ + --brave-brand-color: #ff7654; /* orange400 */ + --brave-primary-hover: #ff977d; /* orange300 */ + --brave-default-hover: rgba(255, 118, 84, 0.1); /* orange400 */ + --brave-focus-outline: rgba(255, 118, 84, 0.4); /* orange400 */ + --ink-color: var(--brave-brand-color) !important; + --text-color: var(--brave-text-color) !important; + --text-color-action: white !important; + --border-color: #c2c4cf !important; /* grey 400 */ + --active-shadow-rgb: 255,118,84 !important; + --active-shadow-action-rgb: 255,118,84 !important; + --bg-action: var(--brave-brand-color) !important; + /* TODO: Disabled colors: + --disabled-bg-action: var(--google-grey-refresh-100); + --disabled-bg: white; + --disabled-border-color: var(--google-grey-refresh-100); */ + --hover-bg-action: var(--brave-primary-hover) !important; + --hover-bg-color: none !important; + --hover-border-color: var(--brave-brand-color) !important; + --hover-shadow-action-rgb: 255, 118, 84 !important; + --ink-color-action: white !important; + font-family: Poppins, sans-serif !important; + outline: none !important; + border-radius: 100px !important; /* absurdly large to make sure is + rounded at any height */ +} +:host([role='menuitem']) { + border-radius: 0px !important; +} +:host(:not([style]):hover) { + --text-color: var(--brave-brand-color) !important; + --border-color: var(--text-color) !important; +} +/* Dark theme colors */ +@media (prefers-color-scheme: dark) { + :host(:not([style])) { + --brave-text-color: #ffffff; + --border-color: #5e6175 !important; /* grey 700 */ + } +} +:host-context(.focus-outline-visible):host(:not([style]):focus) { + box-shadow: 0 0 0 3px var(--brave-focus-outline) !important; +} diff --git a/ui/webui/resources/overrides/cr_toggle.js b/ui/webui/resources/overrides/cr_toggle.js deleted file mode 100644 index a9cfc312cd3d..000000000000 --- a/ui/webui/resources/overrides/cr_toggle.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. - -import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' - -export default html` - -` diff --git a/ui/webui/resources/overrides/cr_toggle_override.css b/ui/webui/resources/overrides/cr_toggle_override.css new file mode 100644 index 000000000000..f0af9241df88 --- /dev/null +++ b/ui/webui/resources/overrides/cr_toggle_override.css @@ -0,0 +1,10 @@ +/* #css_wrapper_metadata_start + * #type=style + * #scheme=relative + * #css_wrapper_metadata_end */ + +:host { + --cr-toggle-checked-bar-color: var(--cr-link-color) !important; + --cr-toggle-checked-button-color: var(--cr-link-color) !important; + --cr-toggle-checked-ink-color: var(--cr-link-color) !important; +} diff --git a/ui/webui/resources/page_specific.grdp b/ui/webui/resources/page_specific.grdp deleted file mode 100644 index 6a532308f42b..000000000000 --- a/ui/webui/resources/page_specific.grdp +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/ui/webui/resources/page_specific/BUILD.gn b/ui/webui/resources/page_specific/BUILD.gn deleted file mode 100644 index cbdc9237bb34..000000000000 --- a/ui/webui/resources/page_specific/BUILD.gn +++ /dev/null @@ -1,7 +0,0 @@ -import("//tools/polymer/polymer.gni") - -# Targets for auto-generating Polymer 3 JS Modules. - -group("polymer3_elements") { - deps = [ "history:brave_history_item_module" ] -} diff --git a/ui/webui/resources/page_specific/history/BUILD.gn b/ui/webui/resources/page_specific/history/BUILD.gn deleted file mode 100644 index 4200a0e5de91..000000000000 --- a/ui/webui/resources/page_specific/history/BUILD.gn +++ /dev/null @@ -1,9 +0,0 @@ -import("//tools/polymer/polymer.gni") - -# Targets for auto-generating Polymer 3 JS Modules. - -polymer_modulizer("brave_history_item") { - js_file = "brave_history_item.js" - html_file = "brave_history_item.html" - html_type = "dom-module" -} diff --git a/ui/webui/resources/page_specific/history/brave_history_item.html b/ui/webui/resources/page_specific/history/brave_history_item.html deleted file mode 100644 index cf2112e0b37a..000000000000 --- a/ui/webui/resources/page_specific/history/brave_history_item.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/ui/webui/resources/polymer_overriding.js b/ui/webui/resources/polymer_overriding.ts similarity index 78% rename from ui/webui/resources/polymer_overriding.js rename to ui/webui/resources/polymer_overriding.ts index 452772a3b9b0..cd6ec4fe7477 100644 --- a/ui/webui/resources/polymer_overriding.js +++ b/ui/webui/resources/polymer_overriding.ts @@ -3,14 +3,25 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. +// @ts-nocheck TODO(petemill): Define types + import {html as polymerHtml, mixinBehaviors, Polymer, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // Global overrides -import 'chrome://brave-resources/br_elements/br_toolbar/br_toolbar.js'; -import CrButtonStyleTemplate from './overrides/cr_button.js' -import CrToggleStyleTemplate from './overrides/cr_toggle.js' +import 'chrome://resources/br_elements/br_toolbar/br_toolbar.js' +import 'chrome://resources/br_elements/br_shared_style.css.js' +import './overrides/cr_button_override.css.js' +import './overrides/cr_toggle_override.css.js' + +type ModificationsMap = { + [tagName: string]: (DocumentFragment) => unknown +} -const debug = false +type IconOverridesMap = { + [iconName: string]: string // new icon name +} + +const debug = false || document.location.href.includes('brave-overriding-debug') if (debug) { // Useful to diagnose module definition timing for template modification @@ -25,7 +36,7 @@ const ignoredComponents = [ 'cr-toolbar' ] -function addBraveBehaviorsLegacy(moduleName, component) { +function addBraveBehaviorsLegacy(moduleName: string, component: { behaviors: Function[] }) { if (allBehaviorsMap[moduleName]) { component.behaviors = component.behaviors || [] component.behaviors.push(...allBehaviorsMap[moduleName]) @@ -33,7 +44,7 @@ function addBraveBehaviorsLegacy(moduleName, component) { } } -function addBraveProperties(moduleName, component) { +function addBraveProperties(moduleName: string, component: { properties: any }) { if (allPropertiesMap[moduleName]) { component.properties = component.properties || {} component.properties = { @@ -48,14 +59,14 @@ function addBraveProperties(moduleName, component) { const allBraveTemplateModificationsMap = {} -function addBraveTemplateModifications(moduleName, component, modifyFn) { +function addBraveTemplateModifications(moduleName: string, component: PolymerElement, modifyFn: (content: DocumentFragment ) => unknown) { const template = component._template || component.template if (template) { const templateContent = template.content - const t0 = debug && performance.now() + const t0 = debug ? performance.now() : null modifyFn(templateContent) - const t1 = debug && performance.now() - if (debug) + const t1 = debug ? performance.now() : null + if (debug && t0 && t1) console.debug(`Modifying template '${moduleName}' took ${t1 - t0}ms`) } else { console.error(`Source template not found for override of component "${moduleName}"`) @@ -64,7 +75,11 @@ function addBraveTemplateModifications(moduleName, component, modifyFn) { const styleOverridePrefix = 'brave-override-style-' -function addBraveStyleOverride(moduleName, component, template = component._template || component.template) { +function addBraveStyleOverride(moduleName: string, styleOverrideModuleNames: string[], component: PolymerElement, template = component._template || component.template) { + if (!styleOverrideModuleNames.length) { + console.warn(`Asked to add style overrides for ${moduleName} but was provided with an empty array`) + return + } if (!template) { console.error(`No template found for component (${moduleName}) with found style overrides`, component) return @@ -74,13 +89,14 @@ function addBraveStyleOverride(moduleName, component, template = component._temp console.error(`No style element found for component (${moduleName}) with found style overrides`, component) return } - const overrideModuleName = styleOverridePrefix + moduleName styleElement.setAttribute( 'include', - `${styleElement.getAttribute('include')} ${overrideModuleName}` + `${styleElement.getAttribute('include')} ${styleOverrideModuleNames.join(' ')}` ) - if (debug) - console.log(`Brave Style Override added for ${moduleName}`, styleElement) + if (debug) { + console.log(`Brave Style Override added of "${styleOverrideModuleNames.join(' ')}" for ${moduleName}`, styleElement) + // TODO(petemill): Check if we can find each style override module + } } export function RegisterPolymerComponentBehaviors(behaviorsMap) { @@ -102,7 +118,7 @@ export function RegisterPolymerComponentProperties(propertiesMap) { } } -export function RegisterPolymerTemplateModifications(modificationsMap) { +export function RegisterPolymerTemplateModifications(modificationsMap: ModificationsMap) { if (debug) { console.log('RegisterPolymerTemplateModifications', ...Object.keys(modificationsMap)) } @@ -137,9 +153,14 @@ export function RegisterPolymerComponentToIgnore(name) { ignoredComponents.push(name) } -const moduleNamesWithStyleOverrides = [] +const moduleNamesWithStyleOverrides: { [moduleName: string]: string[] } = {} + +export async function RegisterStyleOverrideName(componentName: string, polymerStyleModuleName: string) { + const overrideData = (moduleNamesWithStyleOverrides[componentName] = moduleNamesWithStyleOverrides[componentName] || []) + overrideData.push(polymerStyleModuleName) +} -export async function RegisterStyleOverride(componentName, styleTemplate) { +export async function RegisterStyleOverride(componentName: string, styleTemplate: HTMLTemplateElement) { // Inform polymer of styles by creating a dom-module. // //