diff --git a/.pylintrc b/.pylintrc index c1e19019aada..4a1d6d453d6c 100644 --- a/.pylintrc +++ b/.pylintrc @@ -145,9 +145,11 @@ disable=print-statement, exception-escape, comprehension-escape, missing-function-docstring, - missing-module-docstring, + missing-module-docstring, raise-missing-from, - invalid-name + invalid-name, + duplicate-code, + deprecated-method, # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/.storybook/chrome-resources-mock/js/cr.m.js b/.storybook/chrome-resources-mock/js/cr.m.js new file mode 100644 index 000000000000..1495632ded9b --- /dev/null +++ b/.storybook/chrome-resources-mock/js/cr.m.js @@ -0,0 +1,2 @@ +export function addWebUIListener() {} +export function sendWithPromise() {} diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 41c635136f16..ecc5ccb8f9e2 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -19,6 +19,7 @@ module.exports = async ({ config, mode }) => { }) config.resolve.alias = { ...config.resolve.alias, + 'chrome://resources': path.resolve(__dirname, 'chrome-resources-mock'), 'brave-ui': path.resolve(__dirname, '../node_modules/brave-ui/src'), // Force same styled-components module for brave-core and brave-ui // which ensure both repos code use the same singletons, e.g. ThemeContext. diff --git a/DEPS b/DEPS index 9fd27630b7cc..9b2d8898ba7b 100644 --- a/DEPS +++ b/DEPS @@ -75,6 +75,10 @@ include_rules = [ "-brave/services", "-ios", "-brave/third_party/bitcoin-core", + + # Temporary change for the base::Optional -> absl::optional migration, to be + # removed once this rule is allowed in chromium's src/DEPS file. + "+third_party/abseil-cpp/absl/types/optional.h", ] # Temporary workaround for massive nummber of incorrect test includes diff --git a/android/brave_java_resources.gni b/android/brave_java_resources.gni index 4ba9f293409d..8e372374efb5 100644 --- a/android/brave_java_resources.gni +++ b/android/brave_java_resources.gni @@ -822,8 +822,6 @@ brave_java_resources = [ "java/res/layout/user_wallet_activity.xml", "java/res/layout/verify_wallet_activity.xml", "java/res/layout/wallet_coin_list_item.xml", - "java/res/layout/web_notification_big_brave_ads.xml", - "java/res/layout/web_notification_brave_ads.xml", "java/res/layout/web_notification_icon_frame_brave.xml", "java/res/menu/exit_settings_menu.xml", "java/res/menu/navigation.xml", diff --git a/android/brave_java_sources.gni b/android/brave_java_sources.gni index 2491d35b2c8a..47ee1520dfdb 100644 --- a/android/brave_java_sources.gni +++ b/android/brave_java_sources.gni @@ -83,12 +83,10 @@ brave_java_sources = [ "../../brave/android/java/org/chromium/chrome/browser/local_database/TopSiteTable.java", "../../brave/android/java/org/chromium/chrome/browser/night_mode/settings/BraveRadioButtonGroupThemePreference.java", "../../brave/android/java/org/chromium/chrome/browser/night_mode/settings/BraveThemePreferences.java", - "../../brave/android/java/org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/BraveNotificationPlatformBridge.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/BraveNotificationSettingsBridge.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/BraveOnboardingNotification.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/BraveSetDefaultBrowserNotificationService.java", - "../../brave/android/java/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotification.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotificationPublisher.java", "../../brave/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotificationUtil.java", @@ -115,6 +113,7 @@ brave_java_sources = [ "../../brave/android/java/org/chromium/chrome/browser/ntp_background_images/util/NTPUtil.java", "../../brave/android/java/org/chromium/chrome/browser/ntp_background_images/util/NewTabPageListener.java", "../../brave/android/java/org/chromium/chrome/browser/ntp_background_images/util/SponsoredImageUtil.java", + "../../brave/android/java/org/chromium/chrome/browser/omnibox/status/BraveStatusMediator.java", "../../brave/android/java/org/chromium/chrome/browser/omnibox/suggestions/editurl/BraveEditUrlSuggestionProcessor.java", "../../brave/android/java/org/chromium/chrome/browser/onboarding/BraveRewardsOnboardingFragment.java", "../../brave/android/java/org/chromium/chrome/browser/onboarding/OnViewPagerAction.java", diff --git a/android/features/tab_ui/BUILD.gn b/android/features/tab_ui/BUILD.gn index 0358af23db09..3c3d0ac77a31 100644 --- a/android/features/tab_ui/BUILD.gn +++ b/android/features/tab_ui/BUILD.gn @@ -15,10 +15,15 @@ android_library("java") { "//base:base_java", "//chrome/android:chrome_java", "//chrome/android/features/tab_ui:java", + "//chrome/browser/android/lifecycle:java", "//chrome/browser/flags:java", "//chrome/browser/preferences:java", + "//chrome/browser/tabmodel:java", "//chrome/browser/ui/android/theme:java", + "//chrome/browser/ui/messages/android:java", + "//components/browser_ui/bottomsheet/android:java", "//components/browser_ui/widget/android:java", + "//third_party/androidx:androidx_annotation_annotation_java", "//ui/android:ui_no_recycler_view_java", ] diff --git a/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabGroupUiCoordinator.java b/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabGroupUiCoordinator.java index e5e63a46dab6..5b0094440c23 100644 --- a/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabGroupUiCoordinator.java +++ b/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabGroupUiCoordinator.java @@ -7,24 +7,53 @@ import static org.chromium.chrome.browser.tasks.tab_management.TabManagementModuleProvider.SYNTHETIC_TRIAL_POSTFIX; +import android.app.Activity; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; + import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.supplier.ObservableSupplier; +import org.chromium.base.supplier.OneshotSupplier; +import org.chromium.base.supplier.Supplier; +import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; +import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; +import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; +import org.chromium.chrome.browser.share.ShareDelegate; +import org.chromium.chrome.browser.tabmodel.TabCreatorManager; +import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.theme.ThemeColorProvider; +import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; import org.chromium.chrome.tab_ui.R; +import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator; +import org.chromium.ui.resources.dynamics.DynamicResourceLoader; import org.chromium.ui.widget.ChromeImageView; public class BraveTabGroupUiCoordinator extends TabGroupUiCoordinator { // To delete in bytecode, members from parent class will be used instead. private TabGroupUiToolbarView mToolbarView; - public BraveTabGroupUiCoordinator(ViewGroup parentView, ThemeColorProvider themeColorProvider, - ScrimCoordinator scrimCoordinator, - ObservableSupplier omniboxFocusStateSupplier) { - super(parentView, themeColorProvider, scrimCoordinator, omniboxFocusStateSupplier); + public BraveTabGroupUiCoordinator(@NonNull Activity activity, @NonNull ViewGroup parentView, + @NonNull ThemeColorProvider themeColorProvider, + @NonNull ScrimCoordinator scrimCoordinator, + @NonNull ObservableSupplier omniboxFocusStateSupplier, + @NonNull BottomSheetController bottomSheetController, + @NonNull ActivityLifecycleDispatcher activityLifecycleDispatcher, + @NonNull Supplier isWarmOnResumeSupplier, + @NonNull TabModelSelector tabModelSelector, + @NonNull TabContentManager tabContentManager, @NonNull ViewGroup rootView, + @NonNull Supplier dynamicResourceLoaderSupplier, + @NonNull TabCreatorManager tabCreatorManager, + @NonNull Supplier shareDelegateSupplier, + @NonNull OneshotSupplier overviewModeBehaviorSupplier, + @NonNull SnackbarManager snackbarManager) { + super(activity, parentView, themeColorProvider, scrimCoordinator, omniboxFocusStateSupplier, + bottomSheetController, activityLifecycleDispatcher, isWarmOnResumeSupplier, + tabModelSelector, tabContentManager, rootView, dynamicResourceLoaderSupplier, + tabCreatorManager, shareDelegateSupplier, overviewModeBehaviorSupplier, + snackbarManager); assert mToolbarView != null : "Make sure mToolbarView is properly patched in bytecode."; mToolbarView.setBackgroundColor(ApiCompatibilityUtils.getColor( diff --git a/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabUiFeatureUtilities.java b/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabUiFeatureUtilities.java index 45bd471404a4..d89417fadb21 100644 --- a/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabUiFeatureUtilities.java +++ b/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/BraveTabUiFeatureUtilities.java @@ -5,6 +5,8 @@ package org.chromium.chrome.browser.tasks.tab_management; +import android.content.Context; + import org.chromium.chrome.browser.flags.CachedFeatureFlags; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.preferences.BravePreferenceKeys; @@ -14,17 +16,17 @@ public class BraveTabUiFeatureUtilities { /** * @return Whether the Grid Tab Switcher UI is enabled and available for use. */ - public static boolean isGridTabSwitcherEnabled() { - if (!isTabGroupsAndroidEnabled()) { + public static boolean isGridTabSwitcherEnabled(Context context) { + if (!isTabGroupsAndroidEnabled(context)) { return false; } - return TabUiFeatureUtilities.isGridTabSwitcherEnabled(); + return TabUiFeatureUtilities.isGridTabSwitcherEnabled(context); } /** * @return Whether the tab group feature is enabled and available for use. */ - public static boolean isTabGroupsAndroidEnabled() { + public static boolean isTabGroupsAndroidEnabled(Context context) { // For backward compatibility we take value of Tab Grid feature if BRAVE_TAB_GROUPS_ENABLED // setting hasn't been created. We don't want to rely on Tab Grid feature itself since it // can be removed in the upstream going forward. @@ -40,6 +42,6 @@ public static boolean isTabGroupsAndroidEnabled() { return false; } - return TabUiFeatureUtilities.isTabGroupsAndroidEnabled(); + return TabUiFeatureUtilities.isTabGroupsAndroidEnabled(context); } } diff --git a/android/feed/core/java/src/org/chromium/chrome/browser/feed/BraveFeedSurfaceCoordinator.java b/android/feed/core/java/src/org/chromium/chrome/browser/feed/BraveFeedSurfaceCoordinator.java index ca17da3defd5..b47dffbaab78 100644 --- a/android/feed/core/java/src/org/chromium/chrome/browser/feed/BraveFeedSurfaceCoordinator.java +++ b/android/feed/core/java/src/org/chromium/chrome/browser/feed/BraveFeedSurfaceCoordinator.java @@ -17,6 +17,7 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.feed.shared.FeedSurfaceDelegate; import org.chromium.chrome.browser.native_page.NativePageNavigationDelegate; +import org.chromium.chrome.browser.ntp.NewTabPageLaunchOrigin; import org.chromium.chrome.browser.ntp.ScrollableContainerDelegate; import org.chromium.chrome.browser.ntp.SnapScrollHelper; import org.chromium.chrome.browser.ntp.snippets.SectionHeaderView; @@ -42,11 +43,12 @@ public BraveFeedSurfaceCoordinator(Activity activity, SnackbarManager snackbarMa @Nullable NativePageNavigationDelegate pageNavigationDelegate, Profile profile, boolean isPlaceholderShownInitially, BottomSheetController bottomSheetController, Supplier shareDelegateSupplier, - @Nullable ScrollableContainerDelegate externalScrollableContainerDelegate) { + @Nullable ScrollableContainerDelegate externalScrollableContainerDelegate, + TabModelSelector tabModelSelector, @NewTabPageLaunchOrigin int launchOrigin) { super(activity, snackbarManager, windowAndroid, snapScrollHelper, ntpHeader, sectionHeaderView, showDarkBackground, delegate, pageNavigationDelegate, profile, isPlaceholderShownInitially, bottomSheetController, shareDelegateSupplier, - externalScrollableContainerDelegate); + externalScrollableContainerDelegate, tabModelSelector, launchOrigin); } @Override diff --git a/android/java/apk_for_test.flags b/android/java/apk_for_test.flags index d00e6d825ab0..c8d2d5f6f87b 100644 --- a/android/java/apk_for_test.flags +++ b/android/java/apk_for_test.flags @@ -49,10 +49,15 @@ } -keep class org.chromium.chrome.browser.ntp.NewTabPage { + public (...); *** mNewTabPageLayout; *** mFeedSurfaceProvider; } +-keep class org.chromium.chrome.browser.ntp.BraveNewTabPage { + public (...); +} + -keep class org.chromium.chrome.browser.omnibox.suggestions.editurl.EditUrlSuggestionProcessor { *** mHasClearedOmniboxForFocus; } @@ -111,6 +116,13 @@ *** mIncognitoStateProvider; *** mTabCountProvider; *** mTabGroupUi; + *** mBottomSheetController; + *** mActivityLifecycleDispatcher; + *** mIsWarmOnResumeSupplier; + *** mTabContentManager; + *** mTabCreatorManager; + *** mOverviewModeBehaviorSupplier; + *** mSnackbarManager; *** onOrientationChange(...); *** updateButtonStatus(...); *** updateBookmarkButtonStatus(...); @@ -132,8 +144,10 @@ *** mToggleTabStackButton; *** mMenuButton; *** mShouldShowNewTabVariation; + *** mIsIncognito; *** updateNewTabButtonVisibility(...); *** shouldShowIncognitoToggle(...); + *** getToolbarColorForCurrentState(...); } -keep class org.chromium.chrome.browser.download.MimeUtils { @@ -141,7 +155,7 @@ } -keep class org.chromium.chrome.browser.app.ChromeActivity { - *** mTabModelProfileSupplier; + *** mBrowserControlsManagerSupplier; } -keep class org.chromium.chrome.browser.tabbed_mode.TabbedRootUiCoordinator { @@ -292,3 +306,19 @@ *** isGridTabSwitcherEnabled(...); *** isTabGroupsAndroidEnabled(...); } + +-keep class org.chromium.components.browser_ui.notifications.NotificationManagerProxyImpl { + public (...); +} + +-keep class org.chromium.chrome.browser.notifications.BraveNotificationManagerProxyImpl { + public (...); +} + +-keep class org.chromium.chrome.browser.omnibox.status.StatusMediator { + public (...); +} + +-keep class org.chromium.chrome.browser.omnibox.status.BraveStatusMediator { + public (...); +} \ No newline at end of file diff --git a/android/java/org/chromium/chrome/browser/BraveUphold.java b/android/java/org/chromium/chrome/browser/BraveUphold.java index 51fd4c886352..2c4fce883127 100644 --- a/android/java/org/chromium/chrome/browser/BraveUphold.java +++ b/android/java/org/chromium/chrome/browser/BraveUphold.java @@ -50,7 +50,7 @@ public void CompleteUpholdVerification(ExternalNavigationParams params, mBraveExternalNavigationHandler = handler; rewardsNativeProxy = BraveRewardsNativeWorker.getInstance(); - Uri uri = Uri.parse(params.getUrl()); + Uri uri = Uri.parse(params.getUrl().getSpec()); rewardsNativeProxy.AddObserver(this); String path = uri.getPath(); String query = uri.getQuery(); diff --git a/android/java/org/chromium/chrome/browser/app/BraveActivity.java b/android/java/org/chromium/chrome/browser/app/BraveActivity.java index 6bf74e5160d5..ce8f86bf2984 100644 --- a/android/java/org/chromium/chrome/browser/app/BraveActivity.java +++ b/android/java/org/chromium/chrome/browser/app/BraveActivity.java @@ -41,6 +41,7 @@ import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.NativeMethods; import org.chromium.base.supplier.ObservableSupplier; +import org.chromium.base.supplier.UnownedUserDataSupplier; import org.chromium.base.task.PostTask; import org.chromium.base.task.TaskTraits; import org.chromium.chrome.R; @@ -69,6 +70,7 @@ import org.chromium.chrome.browser.crypto_wallet.CryptoWalletActivity; import org.chromium.chrome.browser.dependency_injection.ChromeActivityComponent; import org.chromium.chrome.browser.flags.ChromeSwitches; +import org.chromium.chrome.browser.fullscreen.BrowserControlsManager; import org.chromium.chrome.browser.informers.BraveAndroidSyncDisabledInformer; import org.chromium.chrome.browser.notifications.BraveSetDefaultBrowserNotificationService; import org.chromium.chrome.browser.notifications.retention.RetentionNotificationUtil; @@ -88,7 +90,7 @@ import org.chromium.chrome.browser.settings.BraveRewardsPreferences; import org.chromium.chrome.browser.settings.BraveSearchEngineUtils; import org.chromium.chrome.browser.share.ShareDelegate; -import org.chromium.chrome.browser.share.ShareDelegateImpl.ShareOrigin; +import org.chromium.chrome.browser.share.ShareDelegate.ShareOrigin; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabLaunchType; @@ -158,7 +160,7 @@ public abstract class BraveActivity // Explicitly declare this variable to avoid build errors. // It will be removed in asm and parent variable will be used instead. - protected ObservableSupplier mTabModelProfileSupplier; + private UnownedUserDataSupplier mBrowserControlsManagerSupplier; private static final List yandexRegions = Arrays.asList("AM", "AZ", "BY", "KG", "KZ", "MD", "RU", "TJ", "TM", "UZ"); @@ -843,6 +845,10 @@ public void hideOverview(LayoutManagerChrome layoutManager) { } } + public ObservableSupplier getBrowserControlsManagerSupplier() { + return mBrowserControlsManagerSupplier; + } + @NativeMethods interface Natives { void restartStatsUpdater(); diff --git a/android/java/org/chromium/chrome/browser/appmenu/BraveTabbedAppMenuPropertiesDelegate.java b/android/java/org/chromium/chrome/browser/appmenu/BraveTabbedAppMenuPropertiesDelegate.java index 1fcbc3a2a02f..94840d4fac71 100644 --- a/android/java/org/chromium/chrome/browser/appmenu/BraveTabbedAppMenuPropertiesDelegate.java +++ b/android/java/org/chromium/chrome/browser/appmenu/BraveTabbedAppMenuPropertiesDelegate.java @@ -24,6 +24,7 @@ import org.chromium.chrome.browser.bookmarks.BookmarkBridge; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge; +import org.chromium.chrome.browser.feed.webfeed.WebFeedSnackbarController; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher; import org.chromium.chrome.browser.notifications.BraveSetDefaultBrowserNotificationService; @@ -50,10 +51,13 @@ public BraveTabbedAppMenuPropertiesDelegate(Context context, AppMenuDelegate appMenuDelegate, OneshotSupplier overviewModeBehaviorSupplier, ObservableSupplier bookmarkBridgeSupplier, - SnackbarManager snackbarManager, WebFeedBridge webFeedBridge) { + WebFeedSnackbarController.FeedLauncher feedLauncher, + ModalDialogManager modalDialogManager, SnackbarManager snackbarManager, + WebFeedBridge webFeedBridge) { super(context, activityTabProvider, multiWindowModeStateDispatcher, tabModelSelector, toolbarManager, decorView, appMenuDelegate, overviewModeBehaviorSupplier, - bookmarkBridgeSupplier, snackbarManager, webFeedBridge); + bookmarkBridgeSupplier, feedLauncher, modalDialogManager, snackbarManager, + webFeedBridge); mAppMenuDelegate = appMenuDelegate; } diff --git a/android/java/org/chromium/chrome/browser/compositor/layouts/BraveLayoutManagerChrome.java b/android/java/org/chromium/chrome/browser/compositor/layouts/BraveLayoutManagerChrome.java index 93a8ef445b7b..85bcc743b34d 100644 --- a/android/java/org/chromium/chrome/browser/compositor/layouts/BraveLayoutManagerChrome.java +++ b/android/java/org/chromium/chrome/browser/compositor/layouts/BraveLayoutManagerChrome.java @@ -13,6 +13,7 @@ import org.chromium.base.supplier.ObservableSupplier; import org.chromium.base.supplier.OneshotSupplierImpl; import org.chromium.base.supplier.Supplier; +import org.chromium.chrome.browser.app.BraveActivity; import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider; import org.chromium.chrome.browser.compositor.LayerTitleCache; import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; @@ -39,28 +40,28 @@ public BraveLayoutManagerChrome(LayoutManagerHost host, ViewGroup contentContain ObservableSupplier tabContentManagerSupplier, Supplier layerTitleCacheSupplier, OneshotSupplierImpl overviewModeBehaviorSupplier, - OneshotSupplierImpl layoutStateProviderOneshotSupplier, Supplier topUiThemeColorProvider) { super(host, contentContainer, createOverviewLayout, startSurface, tabContentManagerSupplier, - layerTitleCacheSupplier, overviewModeBehaviorSupplier, - layoutStateProviderOneshotSupplier, topUiThemeColorProvider); + layerTitleCacheSupplier, overviewModeBehaviorSupplier, topUiThemeColorProvider); mCreateOverviewLayout = createOverviewLayout && startSurface == null; } @Override public void init(TabModelSelector selector, TabCreatorManager creator, - ControlContainer controlContainer, DynamicResourceLoader dynamicResourceLoader) { + ControlContainer controlContainer, DynamicResourceLoader dynamicResourceLoader, + TopUiThemeColorProvider topUiColorProvider) { if (mCreateOverviewLayout) { Context context = mHost.getContext(); LayoutRenderHost renderHost = mHost.getLayoutRenderHost(); final ObservableSupplier - browserControlsSupplier = mHost.getBrowserControlsManagerSupplier(); + browserControlsSupplier = + BraveActivity.getBraveActivity().getBrowserControlsManagerSupplier(); mOverviewLayout = new StackLayout(context, this, renderHost, (ObservableSupplier) browserControlsSupplier); } - super.init(selector, creator, controlContainer, dynamicResourceLoader); + super.init(selector, creator, controlContainer, dynamicResourceLoader, topUiColorProvider); } @Override diff --git a/android/java/org/chromium/chrome/browser/externalnav/BraveExternalNavigationHandler.java b/android/java/org/chromium/chrome/browser/externalnav/BraveExternalNavigationHandler.java index 916e8d3e0d41..21d2cbad6ed9 100644 --- a/android/java/org/chromium/chrome/browser/externalnav/BraveExternalNavigationHandler.java +++ b/android/java/org/chromium/chrome/browser/externalnav/BraveExternalNavigationHandler.java @@ -5,11 +5,12 @@ package org.chromium.chrome.browser.externalnav; +import org.chromium.chrome.browser.BraveUphold; import org.chromium.components.external_intents.ExternalNavigationDelegate; import org.chromium.components.external_intents.ExternalNavigationHandler; -import org.chromium.components.external_intents.ExternalNavigationParams; import org.chromium.components.external_intents.ExternalNavigationHandler.OverrideUrlLoadingResult; -import org.chromium.chrome.browser.BraveUphold; +import org.chromium.components.external_intents.ExternalNavigationParams; +import org.chromium.url.GURL; public class BraveExternalNavigationHandler extends ExternalNavigationHandler { private BraveUphold mBraveUphold; @@ -28,7 +29,7 @@ public OverrideUrlLoadingResult shouldOverrideUrlLoading(ExternalNavigationParam } private boolean isUpholdOverride(ExternalNavigationParams params) { - if (!params.getUrl().startsWith(BraveUphold.UPHOLD_REDIRECT_URL)) return false; + if (!params.getUrl().getSpec().startsWith(BraveUphold.UPHOLD_REDIRECT_URL)) return false; return true; } @@ -49,6 +50,7 @@ public OverrideUrlLoadingResult clobberCurrentTabWithFallbackUrl( if (params.getRedirectHandler() != null) { params.getRedirectHandler().setShouldNotOverrideUrlLoadingOnCurrentRedirectChain(); } - return clobberCurrentTab(browserFallbackUrl, params.getReferrerUrl()); + GURL browserFallbackGURL = new GURL(browserFallbackUrl); + return clobberCurrentTab(browserFallbackGURL, params.getReferrerUrl()); } } \ No newline at end of file diff --git a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPage.java b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPage.java index 3300eeb4d70b..4e2097debdda 100644 --- a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPage.java +++ b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPage.java @@ -35,11 +35,12 @@ public BraveNewTabPage(Activity activity, Supplier activityTabProvider, SnackbarManager snackbarManager, ActivityLifecycleDispatcher lifecycleDispatcher, TabModelSelector tabModelSelector, boolean isTablet, NewTabPageUma uma, boolean isInNightMode, - NativePageHost nativePageHost, Tab tab, BottomSheetController bottomSheetController, + NativePageHost nativePageHost, Tab tab, String url, + BottomSheetController bottomSheetController, ObservableSupplier shareDelegateSupplier, WindowAndroid windowAndroid) { super(activity, browserControlsStateProvider, activityTabProvider, snackbarManager, lifecycleDispatcher, tabModelSelector, isTablet, uma, isInNightMode, nativePageHost, - tab, bottomSheetController, shareDelegateSupplier, windowAndroid); + tab, url, bottomSheetController, shareDelegateSupplier, windowAndroid); assert mNewTabPageLayout instanceof BraveNewTabPageLayout; if (mNewTabPageLayout instanceof BraveNewTabPageLayout) { @@ -51,9 +52,10 @@ public BraveNewTabPage(Activity activity, protected void initializeMainView(Activity activity, WindowAndroid windowAndroid, SnackbarManager snackbarManager, NewTabPageUma uma, boolean isInNightMode, BottomSheetController bottomSheetController, - ObservableSupplier shareDelegateSupplier) { + ObservableSupplier shareDelegateSupplier, + TabModelSelector tabModelSelector, String url) { super.initializeMainView(activity, windowAndroid, snackbarManager, uma, isInNightMode, - bottomSheetController, shareDelegateSupplier); + bottomSheetController, shareDelegateSupplier, tabModelSelector, url); // Override surface provider Profile profile = Profile.fromWebContents(mTab.getWebContents()); @@ -63,6 +65,7 @@ windowAndroid, new SnapScrollHelper(mNewTabPageManager, mNewTabPageLayout), mNewTabPageLayout, null, isInNightMode, this, mNewTabPageManager.getNavigationDelegate(), profile, /* isPlaceholderShownInitially= */ false, bottomSheetController, - shareDelegateSupplier, /* externalScrollableContainerDelegate= */ null); + shareDelegateSupplier, /* externalScrollableContainerDelegate= */ null, + tabModelSelector, NewTabPageUtils.decodeOriginFromNtpUrl(url)); } } diff --git a/android/java/org/chromium/chrome/browser/omnibox/status/BraveStatusMediator.java b/android/java/org/chromium/chrome/browser/omnibox/status/BraveStatusMediator.java new file mode 100644 index 000000000000..5a6345793021 --- /dev/null +++ b/android/java/org/chromium/chrome/browser/omnibox/status/BraveStatusMediator.java @@ -0,0 +1,43 @@ +/* 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/. */ + +package org.chromium.chrome.browser.omnibox.status; + +import android.content.Context; +import android.content.res.Resources; + +import org.chromium.base.supplier.OneshotSupplier; +import org.chromium.base.supplier.Supplier; +import org.chromium.chrome.browser.omnibox.LocationBarDataProvider; +import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils; +import org.chromium.chrome.browser.omnibox.UrlBarEditingTextStateProvider; +import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.components.permissions.PermissionDialogController; +import org.chromium.components.search_engines.TemplateUrlService; +import org.chromium.ui.base.WindowAndroid; +import org.chromium.ui.modelutil.PropertyModel; + +public class BraveStatusMediator extends StatusMediator { + // To delete in bytecode, members from parent class will be used instead. + private boolean mUrlHasFocus; + + public BraveStatusMediator(PropertyModel model, Resources resources, Context context, + UrlBarEditingTextStateProvider urlBarEditingTextStateProvider, boolean isTablet, + LocationBarDataProvider locationBarDataProvider, + PermissionDialogController permissionDialogController, + SearchEngineLogoUtils searchEngineLogoUtils, + OneshotSupplier templateUrlServiceSupplier, + Supplier profileSupplier, PageInfoIPHController pageInfoIPHController, + WindowAndroid windowAndroid) { + super(model, resources, context, urlBarEditingTextStateProvider, isTablet, + locationBarDataProvider, permissionDialogController, searchEngineLogoUtils, + templateUrlServiceSupplier, profileSupplier, pageInfoIPHController, windowAndroid); + } + + @Override + boolean shouldDisplaySearchEngineIcon() { + return super.shouldDisplaySearchEngineIcon() && mUrlHasFocus; + } +} diff --git a/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java b/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java index 551b75868bb9..01572b061dca 100644 --- a/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java +++ b/android/java/org/chromium/chrome/browser/settings/AppearancePreferences.java @@ -104,7 +104,7 @@ public void onActivityCreated(Bundle savedInstanceState) { enableTabGroups.setOnPreferenceChangeListener(this); if (enableTabGroups instanceof ChromeSwitchPreference) { ((ChromeSwitchPreference) enableTabGroups) - .setChecked(TabUiFeatureUtilities.isTabGroupsAndroidEnabled()); + .setChecked(TabUiFeatureUtilities.isTabGroupsAndroidEnabled(getActivity())); } } diff --git a/android/java/org/chromium/chrome/browser/signin/BraveSigninManager.java b/android/java/org/chromium/chrome/browser/signin/BraveSigninManager.java index 65d3f752013c..4d0387042216 100644 --- a/android/java/org/chromium/chrome/browser/signin/BraveSigninManager.java +++ b/android/java/org/chromium/chrome/browser/signin/BraveSigninManager.java @@ -14,9 +14,9 @@ import org.chromium.base.annotations.CalledByNative; import org.chromium.chrome.browser.AppHooks; import org.chromium.chrome.browser.signin.services.SigninManager; -import org.chromium.components.signin.AccountTrackerService; import org.chromium.components.signin.base.CoreAccountInfo; import org.chromium.components.signin.identitymanager.AccountInfoService; +import org.chromium.components.signin.identitymanager.AccountTrackerService; import org.chromium.components.signin.identitymanager.IdentityManager; import org.chromium.components.signin.identitymanager.IdentityMutator; import org.chromium.components.signin.metrics.SigninAccessPoint; @@ -106,7 +106,7 @@ public String extractDomainName(String accountEmail) { static SigninManager create(long nativeSigninManagerAndroid, AccountTrackerService accountTrackerService, IdentityManager identityManager, IdentityMutator identityMutator) { - AccountInfoService.init(identityManager); + AccountInfoService.init(identityManager, accountTrackerService); return new BraveSigninManager(identityManager); } diff --git a/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java b/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java index 1faa721fbd22..0dd421a85c63 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java +++ b/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java @@ -30,6 +30,8 @@ import org.chromium.chrome.browser.compositor.CompositorViewHolder; import org.chromium.chrome.browser.compositor.Invalidator; import org.chromium.chrome.browser.compositor.layouts.LayoutManagerImpl; +import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; +import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; import org.chromium.chrome.browser.findinpage.FindToolbarManager; import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.homepage.HomepageManager; @@ -43,6 +45,7 @@ import org.chromium.chrome.browser.tab.SadTab; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider; +import org.chromium.chrome.browser.tabmodel.TabCreatorManager; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tasks.tab_management.TabGroupUi; import org.chromium.chrome.browser.tasks.tab_management.TabManagementModuleProvider; @@ -65,8 +68,10 @@ 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; import org.chromium.chrome.browser.ui.system.StatusBarColorController; import org.chromium.chrome.features.start_surface.StartSurface; +import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.modaldialog.ModalDialogManager; @@ -81,7 +86,7 @@ public class BraveToolbarManager extends ToolbarManager { private FullscreenManager mFullscreenManager; private ActivityTabProvider mActivityTabProvider; private AppThemeColorProvider mAppThemeColorProvider; - private ObservableSupplier mShareDelegateSupplier; + private Supplier mShareDelegateSupplier; private ScrimCoordinator mScrimCoordinator; private Supplier mShowStartSurfaceSupplier; private MenuButtonCoordinator mMenuButtonCoordinator; @@ -97,6 +102,13 @@ public class BraveToolbarManager extends ToolbarManager { private IncognitoStateProvider mIncognitoStateProvider; private TabCountProvider mTabCountProvider; private TabGroupUi mTabGroupUi; + private BottomSheetController mBottomSheetController; + private ActivityLifecycleDispatcher mActivityLifecycleDispatcher; + private Supplier mIsWarmOnResumeSupplier; + private TabContentManager mTabContentManager; + private TabCreatorManager mTabCreatorManager; + private OneshotSupplier mOverviewModeBehaviorSupplier; + private SnackbarManager mSnackbarManager; // Own members. private boolean mIsBottomToolbarVisible; @@ -134,7 +146,13 @@ public BraveToolbarManager(AppCompatActivity activity, BrowserControlsSizer cont Supplier modalDialogManagerSupplier, StatusBarColorController statusBarColorController, AppMenuDelegate appMenuDelegate, ActivityLifecycleDispatcher activityLifecycleDispatcher, - @NonNull Supplier startSurfaceParentTabSupplier) { + @NonNull Supplier startSurfaceParentTabSupplier, + @NonNull BottomSheetController bottomSheetController, + @NonNull Supplier isWarmOnResumeSupplier, + @NonNull TabContentManager tabContentManager, + @NonNull TabCreatorManager tabCreatorManager, + @NonNull OneshotSupplier overviewModeBehaviorSupplier, + @NonNull SnackbarManager snackbarManager) { super(activity, controlsSizer, fullscreenManager, controlContainer, compositorViewHolder, urlFocusChangedCallback, topUiThemeColorProvider, tabObscuringHandler, shareDelegateSupplier, identityDiscController, buttonDataProviders, tabProvider, @@ -144,7 +162,9 @@ public BraveToolbarManager(AppCompatActivity activity, BrowserControlsSizer cont tabModelSelectorSupplier, startSurfaceSupplier, omniboxFocusStateSupplier, intentMetadataOneshotSupplier, promoShownOneshotSupplier, windowAndroid, isInOverviewModeSupplier, modalDialogManagerSupplier, statusBarColorController, - appMenuDelegate, activityLifecycleDispatcher, startSurfaceParentTabSupplier); + appMenuDelegate, activityLifecycleDispatcher, startSurfaceParentTabSupplier, + bottomSheetController, isWarmOnResumeSupplier, tabContentManager, tabCreatorManager, + overviewModeBehaviorSupplier, snackbarManager); mOmniboxFocusStateSupplier = omniboxFocusStateSupplier; mLayoutStateProviderSupplier = layoutStateProviderSupplier; mActivity = activity; @@ -182,11 +202,16 @@ public void enableBottomControls() { (ViewStub) mActivity.findViewById(R.id.bottom_controls_stub); mBottomControls = (BraveScrollingBottomViewResourceFrameLayout) bottomControlsStub.inflate(); - if (TabUiFeatureUtilities.isTabGroupsAndroidEnabled() + if (TabUiFeatureUtilities.isTabGroupsAndroidEnabled(mActivity) || TabUiFeatureUtilities.isConditionalTabStripEnabled()) { - mTabGroupUi = TabManagementModuleProvider.getDelegate().createTabGroupUi( + mTabGroupUi = TabManagementModuleProvider.getDelegate().createTabGroupUi(mActivity, mBottomControls.findViewById(R.id.bottom_container_slot), - mAppThemeColorProvider, mScrimCoordinator, mOmniboxFocusStateSupplier); + mAppThemeColorProvider, mScrimCoordinator, mOmniboxFocusStateSupplier, + mBottomSheetController, mActivityLifecycleDispatcher, + mIsWarmOnResumeSupplier, mTabModelSelector, mTabContentManager, + mCompositorViewHolder, mCompositorViewHolder::getDynamicResourceLoader, + mTabCreatorManager, mShareDelegateSupplier, mOverviewModeBehaviorSupplier, + mSnackbarManager); } mBottomControlsCoordinatorSupplier.set(new BraveBottomControlsCoordinator( mLayoutStateProviderSupplier, diff --git a/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java index a302255586f3..562752d0a01e 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java @@ -37,6 +37,7 @@ import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider; import org.chromium.chrome.browser.tasks.ReturnToChromeExperimentsUtil; +import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; import org.chromium.chrome.browser.theme.ThemeColorProvider; import org.chromium.chrome.browser.toolbar.HomeButton; import org.chromium.chrome.browser.toolbar.TabCountProvider; @@ -157,9 +158,11 @@ void initializeWithNative(OnClickListener tabSwitcherListener, topToolbarRoot, incognitoStateProvider, mThemeColorProvider, newTabClickListener, closeTabsClickListener, mMenuButtonHelperSupplier, tabCountProvider); + ChromeActivity activity = BraveActivity.getBraveActivity(); // Do not change bottom bar if StartSurface Single Pane is enabled and HomePage is not // customized. - if (!ReturnToChromeExperimentsUtil.shouldShowStartSurfaceAsTheHomePage() + if (!ReturnToChromeExperimentsUtil.shouldShowStartSurfaceAsTheHomePage( + activity != null ? activity : mContext) && BottomToolbarVariationManager.shouldBottomToolbarBeVisibleInOverviewMode()) { mLayoutStateObserver = new LayoutStateProvider.LayoutStateObserver() { @Override @@ -252,7 +255,6 @@ public void onStartedHiding( mNewTabButton.setOnLongClickListener(this); } - ChromeActivity activity = BraveActivity.getBraveActivity(); if (mScrollingBottomView != null && activity != null) { mScrollingBottomView.setSwipeDetector( activity.getCompositorViewHolder().getLayoutManager().getToolbarSwipeHandler()); @@ -264,7 +266,10 @@ public void onStartedHiding( */ void setBottomToolbarVisible(boolean isVisible) { if (mTabSwitcherModeCoordinator != null) { - mTabSwitcherModeCoordinator.showToolbarOnTop(!isVisible); + ChromeActivity activity = BraveActivity.getBraveActivity(); + mTabSwitcherModeCoordinator.showToolbarOnTop(!isVisible, + TabUiFeatureUtilities.isGridTabSwitcherEnabled( + activity != null ? activity : mContext)); } mBrowsingModeCoordinator.onVisibilityChanged(isVisible); } diff --git a/android/java/org/chromium/chrome/browser/toolbar/bottom/BrowsingModeBottomToolbarCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/bottom/BrowsingModeBottomToolbarCoordinator.java index b594499bc040..df3dcc90cc23 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/BrowsingModeBottomToolbarCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/BrowsingModeBottomToolbarCoordinator.java @@ -16,7 +16,6 @@ import org.chromium.base.supplier.OneshotSupplier; import org.chromium.chrome.R; import org.chromium.chrome.browser.ActivityTabProvider; -import org.chromium.chrome.browser.ActivityTabProvider.HintlessActivityTabObserver; import org.chromium.chrome.browser.app.BraveActivity; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; diff --git a/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarCoordinator.java index 8e0c419fb254..4dfb3c410f27 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarCoordinator.java @@ -95,8 +95,8 @@ public class TabSwitcherBottomToolbarCoordinator { /** * @param showOnTop Whether to show the tab switcher bottom toolbar on the top of the screen. */ - void showToolbarOnTop(boolean showOnTop) { - mMediator.showToolbarOnTop(showOnTop); + void showToolbarOnTop(boolean showOnTop, boolean isGridTabSwitcherEnabled) { + mMediator.showToolbarOnTop(showOnTop, isGridTabSwitcherEnabled); } /** diff --git a/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarMediator.java b/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarMediator.java index 9dd9a7fdb630..79f6be1dab3a 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarMediator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/TabSwitcherBottomToolbarMediator.java @@ -5,7 +5,6 @@ package org.chromium.chrome.browser.toolbar.bottom; -import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; import org.chromium.chrome.browser.theme.ThemeColorProvider; import org.chromium.chrome.browser.theme.ThemeColorProvider.ThemeColorObserver; @@ -38,13 +37,13 @@ class TabSwitcherBottomToolbarMediator implements ThemeColorObserver { /** * @param showOnTop Whether to show the tab switcher bottom toolbar on the top of the screen. */ - void showToolbarOnTop(boolean showOnTop) { + void showToolbarOnTop(boolean showOnTop, boolean isGridTabSwitcherEnabled) { // TODO(crbug.com/1012014): Resolve how to manage the toolbar position in tab switcher in // landscape mode. Probably remove code about showing bottom toolbar on top. // When GridTabSwitcher is enabled, show the original top toolbar instead of showing the // bottom toolbar on top. - mModel.set(TabSwitcherBottomToolbarModel.SHOW_ON_TOP, - showOnTop && !TabUiFeatureUtilities.isGridTabSwitcherEnabled()); + mModel.set( + TabSwitcherBottomToolbarModel.SHOW_ON_TOP, showOnTop && !isGridTabSwitcherEnabled); } /** diff --git a/android/java/org/chromium/chrome/browser/toolbar/top/BraveTabSwitcherModeTTPhone.java b/android/java/org/chromium/chrome/browser/toolbar/top/BraveTabSwitcherModeTTPhone.java index 979354e5cd88..e009ca6f9416 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/top/BraveTabSwitcherModeTTPhone.java +++ b/android/java/org/chromium/chrome/browser/toolbar/top/BraveTabSwitcherModeTTPhone.java @@ -14,13 +14,17 @@ import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration; import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarVariationManager; import org.chromium.chrome.browser.toolbar.menu_button.MenuButton; +import org.chromium.components.browser_ui.styles.ChromeColors; public class BraveTabSwitcherModeTTPhone extends TabSwitcherModeTTPhone { + // To delete in bytecode, members from parent class will be used instead. private View mNewTabViewButton; private NewTabButton mNewTabImageButton; private ToggleTabStackButton mToggleTabStackButton; private boolean mShouldShowNewTabVariation; + private boolean mIsIncognito; + // Own members. private boolean mShouldShowNewTabButton; public BraveTabSwitcherModeTTPhone(Context context, AttributeSet attrs) { @@ -53,4 +57,10 @@ void onBottomToolbarVisibilityChanged(boolean isVisible) { mToggleTabStackButton.setVisibility(isVisible ? GONE : VISIBLE); } } + + public int getToolbarColorForCurrentState() { + // Return primary background color regardless of GridTabSwitcher state. Otherwise toolbar of + // browsing mode is still visible in tab switching mode with stack layout. + return ChromeColors.getPrimaryBackgroundColor(getResources(), mIsIncognito); + } } diff --git a/android/javatests/org/chromium/chrome/browser/BytecodeTest.java b/android/javatests/org/chromium/chrome/browser/BytecodeTest.java index eed0cac19f37..b42c3ce32a96 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.res.Resources; import android.support.test.filters.SmallTest; import android.view.View; import android.view.ViewGroup; @@ -24,17 +25,26 @@ import org.chromium.base.supplier.Supplier; import org.chromium.chrome.browser.app.ChromeActivity; import org.chromium.chrome.browser.browser_controls.BrowserControlsSizer; +import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider; import org.chromium.chrome.browser.compositor.CompositorViewHolder; +import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge; +import org.chromium.chrome.browser.feed.webfeed.WebFeedSnackbarController; import org.chromium.chrome.browser.findinpage.FindToolbarManager; import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.identity_disc.IdentityDiscController; import org.chromium.chrome.browser.init.StartupTabPreloader; import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher; +import org.chromium.chrome.browser.ntp.NewTabPageUma; +import org.chromium.chrome.browser.omnibox.LocationBarDataProvider; +import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils; +import org.chromium.chrome.browser.omnibox.UrlBarEditingTextStateProvider; +import org.chromium.chrome.browser.omnibox.status.PageInfoIPHController; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; import org.chromium.chrome.browser.tabmodel.ChromeTabCreator; +import org.chromium.chrome.browser.tabmodel.TabCreatorManager; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.theme.ThemeColorProvider; import org.chromium.chrome.browser.theme.TopUiThemeColorProvider; @@ -44,10 +54,13 @@ 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; import org.chromium.chrome.browser.ui.system.StatusBarColorController; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator; import org.chromium.components.embedder_support.browser_context.BrowserContextHandle; +import org.chromium.components.permissions.PermissionDialogController; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modelutil.PropertyModel; @@ -74,6 +87,7 @@ public void testClassesExist() throws Exception { Assert.assertTrue(classExists("org/chromium/chrome/browser/ntp/NewTabPageLayout")); Assert.assertTrue(classExists("org/chromium/chrome/browser/feed/FeedSurfaceCoordinator")); Assert.assertTrue(classExists("org/chromium/chrome/browser/ntp/NewTabPage")); + Assert.assertTrue(classExists("org/chromium/chrome/browser/ntp/BraveNewTabPage")); Assert.assertTrue(classExists( "org/chromium/chrome/browser/omnibox/suggestions/editurl/EditUrlSuggestionProcessor")); Assert.assertTrue( @@ -158,6 +172,9 @@ public void testClassesExist() throws Exception { "org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities")); Assert.assertTrue(classExists( "org/chromium/chrome/browser/tasks/tab_management/BraveTabUiFeatureUtilities")); + Assert.assertTrue(classExists("org/chromium/chrome/browser/omnibox/status/StatusMediator")); + Assert.assertTrue( + classExists("org/chromium/chrome/browser/omnibox/status/BraveStatusMediator")); } @Test @@ -210,6 +227,9 @@ public void testMethodsExist() throws Exception { Assert.assertTrue( methodExists("org/chromium/chrome/browser/toolbar/top/TabSwitcherModeTTPhone", "updateNewTabButtonVisibility", false, null)); + Assert.assertTrue( + methodExists("org/chromium/chrome/browser/toolbar/top/TabSwitcherModeTTPhone", + "getToolbarColorForCurrentState", false, null)); Assert.assertTrue( methodExists("org/chromium/chrome/browser/toolbar/top/TabSwitcherModeTTPhone", "shouldShowIncognitoToggle", false, null)); @@ -262,8 +282,9 @@ public void testConstructorsExistAndMatch() throws Exception { "org/chromium/chrome/browser/appmenu/BraveTabbedAppMenuPropertiesDelegate", Context.class, ActivityTabProvider.class, MultiWindowModeStateDispatcher.class, TabModelSelector.class, ToolbarManager.class, View.class, AppMenuDelegate.class, - OneshotSupplier.class, ObservableSupplier.class, SnackbarManager.class, - WebFeedBridge.class)); + OneshotSupplier.class, ObservableSupplier.class, + WebFeedSnackbarController.FeedLauncher.class, ModalDialogManager.class, + SnackbarManager.class, WebFeedBridge.class)); Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/tabmodel/ChromeTabCreator", "org/chromium/chrome/browser/tabmodel/BraveTabCreator", Activity.class, WindowAndroid.class, StartupTabPreloader.class, Supplier.class, boolean.class, @@ -281,7 +302,9 @@ public void testConstructorsExistAndMatch() throws Exception { OneshotSupplier.class, ObservableSupplier.class, OneshotSupplier.class, OneshotSupplier.class, WindowAndroid.class, Supplier.class, Supplier.class, StatusBarColorController.class, AppMenuDelegate.class, - ActivityLifecycleDispatcher.class, Supplier.class)); + ActivityLifecycleDispatcher.class, Supplier.class, BottomSheetController.class, + Supplier.class, TabContentManager.class, TabCreatorManager.class, + OneshotSupplier.class, SnackbarManager.class)); Assert.assertTrue(constructorsMatch( "org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator", "org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsMediator", @@ -299,12 +322,33 @@ public void testConstructorsExistAndMatch() throws Exception { Assert.assertTrue(constructorsMatch( "org/chromium/chrome/browser/tasks/tab_management/TabGroupUiCoordinator", "org/chromium/chrome/browser/tasks/tab_management/BraveTabGroupUiCoordinator", - ViewGroup.class, ThemeColorProvider.class, ScrimCoordinator.class, - ObservableSupplier.class)); + Activity.class, ViewGroup.class, ThemeColorProvider.class, ScrimCoordinator.class, + ObservableSupplier.class, BottomSheetController.class, + ActivityLifecycleDispatcher.class, Supplier.class, TabModelSelector.class, + TabContentManager.class, ViewGroup.class, Supplier.class, TabCreatorManager.class, + Supplier.class, OneshotSupplier.class, SnackbarManager.class)); Assert.assertTrue(constructorsMatch( "org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate", "org/chromium/chrome/browser/site_settings/BraveSiteSettingsDelegate", Context.class, BrowserContextHandle.class)); + Assert.assertTrue(constructorsMatch( + "org/chromium/components/browser_ui/notifications/NotificationManagerProxyImpl", + "org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl", + Context.class)); + Assert.assertTrue( + constructorsMatch("org/chromium/chrome/browser/omnibox/status/StatusMediator", + "org/chromium/chrome/browser/omnibox/status/BraveStatusMediator", + PropertyModel.class, Resources.class, Context.class, + UrlBarEditingTextStateProvider.class, boolean.class, + LocationBarDataProvider.class, PermissionDialogController.class, + SearchEngineLogoUtils.class, OneshotSupplier.class, Supplier.class, + PageInfoIPHController.class, WindowAndroid.class)); + Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/ntp/NewTabPage", + "org/chromium/chrome/browser/ntp/BraveNewTabPage", Activity.class, + BrowserControlsStateProvider.class, Supplier.class, SnackbarManager.class, + ActivityLifecycleDispatcher.class, TabModelSelector.class, boolean.class, + NewTabPageUma.class, boolean.class, NativePageHost.class, Tab.class, String.class, + BottomSheetController.class, ObservableSupplier.class, WindowAndroid.class)); } @Test @@ -390,6 +434,20 @@ public void testFieldsExist() throws Exception { "org/chromium/chrome/browser/toolbar/ToolbarManager", "mTabCountProvider")); Assert.assertTrue( fieldExists("org/chromium/chrome/browser/toolbar/ToolbarManager", "mTabGroupUi")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mBottomSheetController")); + Assert.assertTrue(fieldExists("org/chromium/chrome/browser/toolbar/ToolbarManager", + "mActivityLifecycleDispatcher")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mIsWarmOnResumeSupplier")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mTabContentManager")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mTabCreatorManager")); + Assert.assertTrue(fieldExists("org/chromium/chrome/browser/toolbar/ToolbarManager", + "mOverviewModeBehaviorSupplier")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mSnackbarManager")); Assert.assertTrue( fieldExists("org/chromium/chrome/browser/toolbar/top/TopToolbarCoordinator", "mTabSwitcherModeCoordinatorPhone")); @@ -412,7 +470,9 @@ public void testFieldsExist() throws Exception { fieldExists("org/chromium/chrome/browser/toolbar/top/TabSwitcherModeTTPhone", "mShouldShowNewTabVariation")); Assert.assertTrue(fieldExists( - "org/chromium/chrome/browser/app/ChromeActivity", "mTabModelProfileSupplier")); + "org/chromium/chrome/browser/toolbar/top/TabSwitcherModeTTPhone", "mIsIncognito")); + Assert.assertTrue(fieldExists("org/chromium/chrome/browser/app/ChromeActivity", + "mBrowserControlsManagerSupplier")); Assert.assertTrue( fieldExists("org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator", "mBottomControlsHeight")); diff --git a/android/javatests/org/chromium/chrome/browser/privacy/settings/BravePrivacySettingsTest.java b/android/javatests/org/chromium/chrome/browser/privacy/settings/BravePrivacySettingsTest.java index 380a43bf959c..6cb9b400ff28 100644 --- a/android/javatests/org/chromium/chrome/browser/privacy/settings/BravePrivacySettingsTest.java +++ b/android/javatests/org/chromium/chrome/browser/privacy/settings/BravePrivacySettingsTest.java @@ -78,7 +78,6 @@ public void testExactSameItemsAreThere() { assertNotEquals(null, mFragment.findPreference(PREF_SAFE_BROWSING)); assertNotEquals(null, mFragment.findPreference(PREF_SYNC_AND_SERVICES_LINK)); assertNotEquals(null, mFragment.findPreference(PREF_CLEAR_BROWSING_DATA)); - assertEquals(null, mFragment.findPreference(PREF_PRIVACY_SANDBOX)); } @Test diff --git a/app/bookmarks_strings.grdp b/app/bookmarks_strings.grdp index 0fef7db2cb6c..9b28ac159de5 100644 --- a/app/bookmarks_strings.grdp +++ b/app/bookmarks_strings.grdp @@ -80,11 +80,11 @@ =1 {Open in &new window} other {Open all ({COUNT}) in &new window}} - + {COUNT, plural, - =0 {Open all in &private window} - =1 {Open in &private window} - other {Open all ({COUNT}) in &private window}} + =0 {Open all in &Private window} + =1 {Open in &Private window} + other {Open all ({COUNT}) in &Private window}} &Open in new tab @@ -92,8 +92,8 @@ Open in &new window - - Open in &private window + + Open in &Private window &Edit... @@ -132,7 +132,7 @@ =1 {Open in &New Window} other {Open All ({COUNT}) in &New Window}} - + {COUNT, plural, =0 {Open All in &Private Window} =1 {Open in &Private Window} @@ -144,7 +144,7 @@ Open in &New Window - + Open in &Private Window @@ -392,11 +392,11 @@ Open all ($15) in new window - - Open all in private window + + Open all in Private window - - Open all ($15) in private window + + Open all ($15) in Private window Open in new tab @@ -404,8 +404,8 @@ Open in new window - - Open in private window + + Open in Private window Rename diff --git a/app/bookmarks_strings_override.grdp b/app/bookmarks_strings_override.grdp index 9f9d0372e6cf..8fe316236330 100644 --- a/app/bookmarks_strings_override.grdp +++ b/app/bookmarks_strings_override.grdp @@ -11,14 +11,14 @@ - + {COUNT, plural, - =0 {Open all in &private window} - =1 {Open in &private window} - other {Open all ({COUNT}) in &private window}} + =0 {Open all in &Private window} + =1 {Open in &Private window} + other {Open all ({COUNT}) in &Private window}} - - Open in &private window + + Open in &Private window @@ -27,13 +27,13 @@ - + {COUNT, plural, =0 {Open All in &Private Window} =1 {Open in &Private Window} other {Open All ({COUNT}) in &Private Window}} - + Open in &Private Window @@ -58,14 +58,14 @@ - - Open all in private window + + Open all in Private window - - Open all ($15) in private window + + Open all ($15) in Private window - - Open in private window + + Open in Private window diff --git a/app/brave_main_delegate.cc b/app/brave_main_delegate.cc index 00847ffa8653..626399b91490 100644 --- a/app/brave_main_delegate.cc +++ b/app/brave_main_delegate.cc @@ -221,6 +221,7 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) { features::kIdleDetection.name, features::kLangClientHintHeader.name, features::kNotificationTriggers.name, + features::kPrivacySandboxSettings.name, features::kSignedExchangePrefetchCacheForNavigations.name, features::kSignedExchangeSubresourcePrefetch.name, features::kSubresourceWebBundles.name, @@ -231,6 +232,7 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) { net::features::kFirstPartySets.name, network::features::kTrustTokens.name, network_time::kNetworkTimeServiceQuerying.name, + password_manager::features::kEnablePasswordsAccountStorage.name, #if defined(OS_ANDROID) features::kWebNfc.name, feed::kInterestFeedContentSuggestions.name, diff --git a/app/brave_main_delegate_browsertest.cc b/app/brave_main_delegate_browsertest.cc index 8d8080198eb0..e7c34758332c 100644 --- a/app/brave_main_delegate_browsertest.cc +++ b/app/brave_main_delegate_browsertest.cc @@ -78,6 +78,7 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) { &features::kIdleDetection, &features::kLangClientHintHeader, &features::kNotificationTriggers, + &features::kPrivacySandboxSettings, &features::kSignedExchangePrefetchCacheForNavigations, &features::kSignedExchangeSubresourcePrefetch, &features::kSubresourceWebBundles, @@ -89,6 +90,7 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) { &net::features::kFirstPartySets, &network::features::kTrustTokens, &network_time::kNetworkTimeServiceQuerying, + &password_manager::features::kEnablePasswordsAccountStorage, }; for (const auto* feature : disabled_features) diff --git a/app/brave_strings.grd b/app/brave_strings.grd index 43a7cc85c803..996abf0dee38 100644 --- a/app/brave_strings.grd +++ b/app/brave_strings.grd @@ -206,6 +206,11 @@ If you update this file, be sure also to update google_chrome_strings.grd. --> Welcome to Brave; new browser window opened + + + Welcome to Brave + + Chrome OS @@ -289,7 +294,7 @@ If you update this file, be sure also to update google_chrome_strings.grd. --> Chrome OS is made possible by additional <a target="_blank" rel="noopener noreferrer" href="$1">open source software</a>. - Chrome OS is made possible by additional <a target="_blank" rel="noopener noreferrer" href="$1">open source software</a>, as is <a target="_blank" rel="noopener noreferrer" href="$2">Linux development environment (Beta)</a>. + Chrome OS is made possible by additional <a target="_blank" rel="noopener noreferrer" href="$1">open source software</a>, as is <a target="_blank" rel="noopener noreferrer" href="$2">Linux development environment</a>. Not used in Brave. Placeholder to keep resource maps in sync. @@ -530,6 +535,10 @@ Brave is unable to recover your settings. This file may be dangerous, so Brave has blocked it. + + Brave recommends that you don't download or open this file. + + @@ -567,8 +576,8 @@ Brave is unable to recover your settings. - - Warning: Brave cannot prevent extensions from recording your browsing history. To disable this extension in private mode, unselect this option. + + Warning: Brave cannot prevent extensions from recording your browsing history. To disable this extension in Private mode, unselect this option. Remove from Brave... @@ -610,6 +619,9 @@ Brave is unable to recover your settings. Update &Brave + + Relaunch to Update &Brave + @@ -618,6 +630,9 @@ Brave is unable to recover your settings. Update &Brave + + Relaunch to update &Brave + @@ -626,6 +641,9 @@ Brave is unable to recover your settings. Update &Chrome OS + + Relaunch to update &Chrome OS + @@ -920,7 +938,7 @@ Brave is unable to recover your settings. Open link in new Brave &tab - + Open link in Brave &private window @@ -928,7 +946,7 @@ Brave is unable to recover your settings. Open Link in New Brave &tab - + Open Link in Brave &Private Window @@ -939,7 +957,7 @@ Brave is unable to recover your settings. Relaunch Brave - + {COUNT, plural, =0 {A new update for Brave is available and will be applied as soon as you relaunch.} =1 {A new update for Brave is available and will be applied as soon as you relaunch. Your Private window won't reopen.} @@ -1069,6 +1087,13 @@ Brave is unable to recover your settings. Chrome OS terms + + Install Chrome OS + + + + Install Chrome OS + diff --git a/app/brave_strings_override.grd b/app/brave_strings_override.grd index 924e324a1983..b2b51a5428a7 100644 --- a/app/brave_strings_override.grd +++ b/app/brave_strings_override.grd @@ -92,6 +92,8 @@ If you update this file, be sure also to update google_chrome_strings.grd. --> + + @@ -150,8 +152,8 @@ If you update this file, be sure also to update google_chrome_strings.grd. --> - - Warning: Brave cannot prevent extensions from recording your browsing history. To disable this extension in private mode, unselect this option. + + Warning: Brave cannot prevent extensions from recording your browsing history. To disable this extension in Private mode, unselect this option. @@ -222,19 +224,19 @@ If you update this file, be sure also to update google_chrome_strings.grd. --> - + Open link in Brave &private window - + Open Link in Brave &Private Window - + {COUNT, plural, =0 {A new update for Brave is available and will be applied as soon as you relaunch.} =1 {A new update for Brave is available and will be applied as soon as you relaunch. Your Private window won't reopen.} diff --git a/app/extensions_strings.grdp b/app/extensions_strings.grdp index fb28d52f0a46..aaee31b28418 100644 --- a/app/extensions_strings.grdp +++ b/app/extensions_strings.grdp @@ -62,7 +62,7 @@ (Inactive) - + (Private) @@ -200,8 +200,8 @@ No active views - - Allow in private + + Allow in Private The following extensions depend on this extension: diff --git a/app/extensions_strings_override.grdp b/app/extensions_strings_override.grdp index bab37ac8a0e1..cde1493ae1e7 100644 --- a/app/extensions_strings_override.grdp +++ b/app/extensions_strings_override.grdp @@ -1,11 +1,11 @@ - + (Private) - - Allow in private + + Allow in Private View in Web Store diff --git a/app/generated_resources.grd b/app/generated_resources.grd index 7a4f244e8249..11c0c930d4dc 100644 --- a/app/generated_resources.grd +++ b/app/generated_resources.grd @@ -290,6 +290,11 @@ are declared in tools/grit/grit_rule.gni. + + + + + @@ -574,7 +579,7 @@ are declared in tools/grit/grit_rule.gni. Open link in new &window - + Open link in &private window @@ -803,7 +808,7 @@ are declared in tools/grit/grit_rule.gni. Open Link in New &Window - + Open Link in &Private Window @@ -1038,8 +1043,8 @@ are declared in tools/grit/grit_rule.gni. &New window - - New &private window + + New &Private window Pin this page to Start screen... @@ -1118,7 +1123,7 @@ are declared in tools/grit/grit_rule.gni. &New Window - + New &Private Window @@ -1194,12 +1199,6 @@ are declared in tools/grit/grit_rule.gni. Move window to $1User name ($2john@google.com) - - Move window to desk - - - All desks - @@ -1234,6 +1233,9 @@ are declared in tools/grit/grit_rule.gni. T&ake screenshot + + R&estore all tabs + R&eopen closed tab @@ -1272,6 +1274,9 @@ are declared in tools/grit/grit_rule.gni. T&ake Screenshot + + R&estore All Tabs + R&eopen Closed Tab @@ -1690,6 +1695,9 @@ are declared in tools/grit/grit_rule.gni. Extensions, apps, and themes can harm your computer. Are you sure you want to continue? + + $1bla.exe could let attackers steal your personal information. + $1bla.exe is not commonly downloaded and may be dangerous. @@ -1753,6 +1761,9 @@ are declared in tools/grit/grit_rule.gni. This file is being scanned. + + This file could let attackers steal your personal information. + Security checks are done @@ -1799,6 +1810,9 @@ are declared in tools/grit/grit_rule.gni. Keep file? + + This file is dangerous + This file may be harmful for your computer. @@ -2153,39 +2167,39 @@ are declared in tools/grit/grit_rule.gni. - + {NUM_DOWNLOAD, plural, =1 {Download is in progress} other {Downloads are in progress}} - + Continue downloading - + Continue Downloading - - Exit private mode anyway? + + Exit Private mode anyway? Exit guest mode anyway? - + Exit - - Quit private mode anyway? + + Quit Private mode anyway? Exit guest mode anyway? - + Quit @@ -3226,11 +3240,6 @@ are declared in tools/grit/grit_rule.gni. Empty Cache and Hard Reload - - - Exit full screen - - Sharing this tab to $1meet.google.com @@ -3428,19 +3437,19 @@ are declared in tools/grit/grit_rule.gni. Extension: $1Sample Extension - + Private Extension: $1Sample Extension App: $1Sample App - + Private App: $1Sample App Tab: $1Brave - + Private Tab: $1Brave @@ -3494,13 +3503,13 @@ are declared in tools/grit/grit_rule.gni. Subframe: $1https://youtube.com/ - + Private Subframe: $1https://youtube.com/ Portal: $1https://youtube.com/ - + Private Portal: $1https://youtube.com/ @@ -3719,10 +3728,10 @@ are declared in tools/grit/grit_rule.gni. - + $1http://www.google.com wants to communicate with the app "$2Gmail" - + $1http://www.google.com wants to communicate with the extension "$2Gmail Checker" @@ -4084,6 +4093,9 @@ are declared in tools/grit/grit_rule.gni. Perform security-related tasks for your organization, such as managing certificates and keys stored on the device + + Read information about your browser, OS, and device + @@ -4996,8 +5008,20 @@ Keep your key file in a safe place. You will need it to create new versions of y - - Lacros is an experimental Browser. Please report issues with: Help > "Report an issue..." The standard browser can be found by typing "Brave" into Launcher. + + Lacros is an experimental Browser. Please report issues with: Help > "Report an issue...". + + + + The standard browser can be found by typing "Brave" into Launcher. + + + + For more information, contact your administrator. + + + + Learn More @@ -5178,7 +5202,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Clear input - + Search or type web address @@ -5517,8 +5541,17 @@ Keep your key file in a safe place. You will need it to create new versions of y your carts + Google Drive files + + Drive files + + Files + + + these files + this module @@ -5529,7 +5562,13 @@ Keep your key file in a safe place. You will need it to create new versions of y Even Better Module - From Google Drive + From your Google Drive + + + You’re seeing your recent and suggested documents based on your previous activity using Google Drive. + <br> + <br> + Learn about the data Google Drive collects and why <a href="https://support.google.com/drive/answer/2450387" target="_blank" rel="noopener noreferrer">here</a>. Top picks for you @@ -5537,11 +5576,11 @@ Keep your key file in a safe place. You will need it to create new versions of y Why am I seeing this? - - You're seeing this item based on your previous activity using Brave services. You can see your data, delete it, and change your settings at <a href="$1" target="_blank" rel="noopener noreferrer">myactivity.google.com</a>. - - - Learn about the data Brave collects and why at <a href="$1" target="_blank" rel="noopener noreferrer">policies.google.com</a>. + + You're seeing this item based on your previous activity using Brave services. You can see your data, delete it, and change your settings at <a href="https://myactivity.google.com/" target="_blank" rel="noopener noreferrer">myactivity.google.com</a>. + <br> + <br> + Learn about the data Brave collects and why at <a href="https://policies.google.com/" target="_blank" rel="noopener noreferrer">policies.google.com</a>. Close @@ -5574,7 +5613,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Up to $115% off - Ask Brave to find discounts on what you’ve added to your carts? + Allow Brave to find discounts on what you add to your carts? Get discounts @@ -5678,6 +5717,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Enable featured experiments + + Toggle left aligned side panel + Select experiment state for $1Tab Scrolling @@ -5773,7 +5815,7 @@ Keep your key file in a safe place. You will need it to create new versions of y - + $1 (Private) @@ -5812,6 +5854,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Experiments + + Left aligned side panel + Enterprise policy changed. Experiments button added to toolbar. Click the button to open a dialog to enable experiments. @@ -5892,22 +5937,16 @@ Keep your key file in a safe place. You will need it to create new versions of y New! Control your music, videos, and more. - You can browse privately using a private window + You can browse privately using a Private window - Use the web without saving your browsing history with a private window + Use the web without saving your browsing history with a Private window - Using a shared computer? Try opening a private window. + Using a shared computer? Try opening a Private window. - To browse privately, click the dots icon menu to open a private window - - - Get captions for your audio and video - - - Get captions for your audio and video by enabling Live Caption in settings + To browse privately, click the dots icon menu to open a Private window Open a new tab with one click @@ -5922,7 +5961,7 @@ Keep your key file in a safe place. You will need it to create new versions of y When you're ready, find your reading list here - Add this page to reading list + To add this page to your reading list, click the Bookmark icon Reopen a tab if you accidentally closed it @@ -5930,6 +5969,9 @@ Keep your key file in a safe place. You will need it to create new versions of y To get back here quickly, install $1Brave Maps by clicking the install button + + Your connection is always secure unless Brave tells you otherwise + $1CTRL+SHIFT+T can reopen accidentally closed tabs @@ -6034,10 +6076,10 @@ Keep your key file in a safe place. You will need it to create new versions of y No thanks - + Username - + Password @@ -6145,7 +6187,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Never - + Update @@ -6172,10 +6214,10 @@ Keep your key file in a safe place. You will need it to create new versions of y Suggest strong password - + Update password for %1$sexample.com - + Passwords are saved in your Brave sync chain (%1$suser@gmail.com) so you can use them on any device @@ -6797,6 +6839,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Found $12 Tabs For '$2google' + + Open Tab + + + Recently Closed Tab + Open Tabs @@ -6990,16 +7038,13 @@ Keep your key file in a safe place. You will need it to create new versions of y - + Automatically send crash reports to Brave - - Welcome to $1Brave - $1Brave is ready to complete your installation @@ -7326,6 +7371,23 @@ Keep your key file in a safe place. You will need it to create new versions of y Can't create QR code + + + Share + + + Share this page + + + Copy link + + + Save page as... + + + Cast... + + Clipboard @@ -7347,12 +7409,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Press $1Ctrl+V to paste - - Preparing download - - - Processing image - Tap the notification on $1Jimmy's Pixel to verify your phone number @@ -7926,7 +7982,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Continue - Not your device? Use <a href="#" target="_blank" rel="noopener noreferrer">Guest mode</a>. + Not your device? Use <a is="action-link" target="_blank" rel="noopener noreferrer">Guest mode</a>. This will separate your browsing from $1bob@example.com @@ -8214,9 +8270,6 @@ Please help our engineers fix this problem. Tell us what happened right before y - - Signed in as $1foo@gmail.com. - On - sync everything @@ -8258,9 +8311,6 @@ Please help our engineers fix this problem. Tell us what happened right before y Verify it's you - - Sign in again - Sign out @@ -8403,23 +8453,6 @@ Please help our engineers fix this problem. Tell us what happened right before y Data was encrypted with your sync passphrase on $1Sept 1, 2012. This doesn't include payment methods and addresses from Brave Pay. - - Data was encrypted with your Brave password as of - $1Sept 1, 2012. This doesn't include payment methods and addresses from Brave Pay. - - - - - - Not signed in to $1Brave - - - (You're missing out—$1sign in) - - - sign in - - @@ -8563,7 +8596,7 @@ Please help our engineers fix this problem. Tell us what happened right before y Close - + More @@ -8716,7 +8749,7 @@ Please help our engineers fix this problem. Tell us what happened right before y New Window - + New Private Window @@ -8903,6 +8936,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Restore All Tabs + + History isn’t saved in Private + Minimize @@ -9368,9 +9404,6 @@ Please help our engineers fix this problem. Tell us what happened right before y Press |$1Esc| to show your cursor - - Press and hold |$1Esc| to exit full screen - @@ -9474,38 +9507,11 @@ Please help our engineers fix this problem. Tell us what happened right before y - - Live Caption - - - Turn off Live Caption for now - - - Show more lines - - - Show fewer lines - - - Live Caption is not available right now - - - - Live Caption visible, press Ctrl + Back or Ctrl + Forward to cycle focus - - - - - Live Caption visible, press ⌘ + Option + Up arrow or Down arrow to cycle focus - - - - - Live Caption visible, press F6 to cycle focus + + Get captions for your audio and video - - - Moved caption bubble to $120% across, $280% down + + Get captions for your audio and video by enabling Live Caption in settings @@ -9630,8 +9636,8 @@ Please help our engineers fix this problem. Tell us what happened right before y New window - - New private window + + New Private window OEM folder @@ -9680,9 +9686,6 @@ Please help our engineers fix this problem. Tell us what happened right before y {SCREEN_INDEX, plural, =1{Screen #} other{Screen #}} - - Presenter Tools - This Tab @@ -10052,15 +10055,9 @@ Please help our engineers fix this problem. Tell us what happened right before y - - $1www.google.com wants to pair - "$1Brave Extension Name" wants to pair - - No compatible devices found. - $1Turn on Bluetooth to allow pairing @@ -10076,15 +10073,6 @@ Please help our engineers fix this problem. Tell us what happened right before y Re-scan Bluetooth devices - - Scanning... - - - Scanning for Bluetooth devices... - - - Pair - Get help$1 while scanning for devices... @@ -10098,33 +10086,15 @@ Please help our engineers fix this problem. Tell us what happened right before y $1device name - Paired - - $1www.google.com wants to connect - "$1Brave Extension Name" wants to connect $1device name ($2device id) - - No compatible devices found. - Compatible devices - - Connect - - - Finding devices... - - - Finding USB devices... - - - Cancel - @@ -10152,19 +10122,19 @@ Please help our engineers fix this problem. Tell us what happened right before y - + Unknown product $1123 from $2Brave - + Unknown product $1123 from vendor $2123 - + Devices from vendor $1123 - + Devices from $1Brave - + Devices from any vendor @@ -10191,6 +10161,21 @@ Please help our engineers fix this problem. Tell us what happened right before y Finding serial devices... + + USB device from $2Brave (product $10x12AB) + + + USB device ($212AB:$112AB) + + + USB devices from vendor $112AB + + + USB devices from $1Brave + + + Any serial port + @@ -10211,6 +10196,16 @@ Please help our engineers fix this problem. Tell us what happened right before y + + + + Open $1.txt, .csv, .md files + + + , ''' + + + @@ -10517,9 +10512,6 @@ Please help our engineers fix this problem. Tell us what happened right before y USB security key - - NFC security key - This device @@ -10589,9 +10581,6 @@ Please help our engineers fix this problem. Tell us what happened right before y Pair with new phone - - Verify via NFC - Use this device @@ -10608,10 +10597,10 @@ Please help our engineers fix this problem. Tell us what happened right before y A notification was sent to your phone to confirm it's you. - - accounts.google.com$1 sent a notification to your phone. Tap Yes to confirm it's you. Didn't get it?$2 + + accounts.google.com$1 sent a notification to your phone. To confirm it's you, follow the steps there. - + Didn't get it? @@ -10623,6 +10612,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Security key request + + accounts.google.com$1 sent a notification to your phone. To confirm it's you, tap the “Verify with this phone$2” notification and follow the steps. + Unlock your phone and confirm it's you @@ -10773,8 +10765,19 @@ Please help our engineers fix this problem. Tell us what happened right before y + + + + Verify with this phone + + + + Verify your identity + + + - + Private @@ -10783,13 +10786,13 @@ Please help our engineers fix this problem. Tell us what happened right before y other {# open windows} } - + Create shortcut - + Exit Private - + Close Private diff --git a/app/generated_resources_override.grd b/app/generated_resources_override.grd index f016f0bc9713..cbead8d64125 100644 --- a/app/generated_resources_override.grd +++ b/app/generated_resources_override.grd @@ -94,6 +94,9 @@ are declared in tools/grit/grit_rule.gni. + + + @@ -147,7 +150,7 @@ are declared in tools/grit/grit_rule.gni. - + Open link in &private window @@ -156,7 +159,7 @@ are declared in tools/grit/grit_rule.gni. - + Open Link in &Private Window @@ -182,12 +185,12 @@ are declared in tools/grit/grit_rule.gni. - - New &private window + + New &Private window - + New &Private Window @@ -300,13 +303,13 @@ are declared in tools/grit/grit_rule.gni. - - Exit private mode anyway? + + Exit Private mode anyway? - - Quit private mode anyway? + + Quit Private mode anyway? @@ -368,19 +371,19 @@ are declared in tools/grit/grit_rule.gni. - + Private Extension: $1Sample Extension - + Private App: $1Sample App - + Private Tab: $1Brave - + Private Subframe: $1https://youtube.com/ - + Private Portal: $1https://youtube.com/ @@ -498,20 +501,20 @@ are declared in tools/grit/grit_rule.gni. - + $1 (Private) - You can browse privately using a private window + You can browse privately using a Private window - Use the web without saving your browsing history with a private window + Use the web without saving your browsing history with a Private window - Using a shared computer? Try opening a private window. + Using a shared computer? Try opening a Private window. - To browse privately, click the dots icon menu to open a private window + To browse privately, click the dots icon menu to open a Private window @@ -754,9 +757,7 @@ are declared in tools/grit/grit_rule.gni. - - - + @@ -778,12 +779,15 @@ are declared in tools/grit/grit_rule.gni. - + New Private Window Always Show Bookmarks + + History isn’t saved in Private + @@ -814,12 +818,6 @@ are declared in tools/grit/grit_rule.gni. - - - - - - @@ -837,8 +835,8 @@ are declared in tools/grit/grit_rule.gni. - - New private window + + New Private window @@ -874,6 +872,9 @@ are declared in tools/grit/grit_rule.gni. + + + @@ -905,13 +906,16 @@ are declared in tools/grit/grit_rule.gni. - + + + + Private - + Exit Private - + Close Private diff --git a/app/media_router_strings.grdp b/app/media_router_strings.grdp index 556c00c02f03..353e2dab7e97 100644 --- a/app/media_router_strings.grdp +++ b/app/media_router_strings.grdp @@ -111,6 +111,15 @@ Available for specific video sites + + Casting desktop + + + Casting tab + + + Presenting ($1example.com) + @@ -146,10 +155,208 @@ - - Presenting ($1example.com) - Display $11 + + + + Brave Cast Feedback + + + N/A + + + Your feedback helps us to improve Brave Cast and is appreciated. + For help troubleshooting issues with cast, please refer to the + <a href="$1" target="_blank" rel="noopener noreferrer"> + help center</a>. + + + Tell us what's happening with Brave Cast. + + + Your answer + + + Required + + + What kind of feedback are you providing? + + + Please enter your feedback here: + + + Mirroring Quality Details + + + Video Smoothness + + + Video Quality + + + Audio Quality + + + What content/URL were you casting? + + + Additional comments: + + + Email (optional): + + + Send Feedback + + + Do you want to discard the feedback? + + + + + Bug or Error + + + Feature Request + + + Tab/Desktop Projection Quality + + + Device Discovery + + + Other + + + + + Freezes + + + Jerky + + + Occasional Stutter + + + Smooth + + + Perfect + + + + + Unwatchable + + + Poor + + + Acceptable + + + Good - DVD + + + Great - HD + + + + + Unintelligible + + + Poor + + + Acceptable - FM + + + Good + + + Perfect + + + + + Sending feedback... + + + Unable to send feedback. Please try again later. + + + Thank you for sending feedback. + + + Failed to send feedback. Retrying... + + + + + Cast and Device Logs + + + Warning - Detailed logging is enabled; logs below may include URLs or other sensitive information. Please review and ensure that you are comfortable submitting this information. + + + Send <a href=""> + debug logs</a> (recommended) + + + Send debug logs (recommended) + + + Your Brave version, operating system version, Cast settings, + mirroring performance stats, and communication channel diagnostic + logs will be submitted in addition to any information you choose + to include above. This feedback is used to diagnose problems and + help improve the feature. Any personal information you submit, + whether explicitly or incidentally, will be protected in + accordance with our privacy policies. By submitting this feedback, + you agree that Brave may use feedback that you provide to improve + any Brave product or service. + + + + + Are you able to see your Bravecast in the + <a href="$1" target="_blank" rel="noopener noreferrer"> + Brave Home app</a>? + + + Yes + + + No + + + Did not try + + + Do you have any special VPN, proxy, firewall, or NAS software + installed? + + + Not sure + + + Which of the following best describes your network? + + + PC and Bravecast on the same Wi-Fi network + + + PC and Bravecast on different Wi-Fi networks (e.g. 2.4GHz + vs. 5GHz) + + + PC is wired and Bravecast is on Wi-Fi + + diff --git a/app/nearby_share_strings.grdp b/app/nearby_share_strings.grdp index be5d1a3e868b..0c110847dee9 100644 --- a/app/nearby_share_strings.grdp +++ b/app/nearby_share_strings.grdp @@ -111,6 +111,9 @@ Confirm + + Decline + Next @@ -295,6 +298,9 @@ Open + + Accept + {COUNT, plural, =1 {$1Ted's Pixel 2 is sharing $21 item with you.} @@ -312,9 +318,6 @@ Device nearby is sharing - - Receive - {COUNT, plural, =1 {Failed to receive $11 item from $2Ted's Pixel 2} @@ -342,15 +345,12 @@ {COUNT, plural, - =1 {$11 item successfully sent to $2Ted's Pixel 2} - other {$13 items successfully sent to $2Ted's Pixel 2}} + =1 {$11 item sent to $2Ted's Pixel 2} + other {$13 items sent to $2Ted's Pixel 2}} Nearby Share - - $1Ted's Pixel 2 did not accept the file - $1Ted's Pixel 2 cancelled the transfer diff --git a/app/os_settings_search_tag_strings.grdp b/app/os_settings_search_tag_strings.grdp index a349d0ce1e6e..01c04b508fb9 100644 --- a/app/os_settings_search_tag_strings.grdp +++ b/app/os_settings_search_tag_strings.grdp @@ -87,14 +87,14 @@ Disable Cellular - - Add Cellular + + Add eSIM profile - - Activate physical SIM + + Install eSIM profile - - Set up eSIM + + Download eSIM profile Turn on Cellular network @@ -717,6 +717,18 @@ Preferred search engine + + Quick Answers + + + Look up + + + Quick search + + + Right click card + Brave Assistant @@ -940,9 +952,6 @@ - - Languages and inputs - Languages @@ -967,9 +976,6 @@ Customize spell check - - Manage input methods - Show input options in the shelf diff --git a/app/os_settings_strings.grdp b/app/os_settings_strings.grdp index 4db24bc51011..3ea50407aa2e 100644 --- a/app/os_settings_strings.grdp +++ b/app/os_settings_strings.grdp @@ -14,6 +14,9 @@ On + + Dismiss + @@ -169,6 +172,15 @@ Name can use letters, numbers, and hyphens (-) + + Couldn't update your Bravebook. Please try again later. + + + Couldn't download the update. Please try again later. + + + Updates are blocked by your administrator + Your $1Bravebook is up to date @@ -289,6 +301,9 @@ Inputs + + Inputs and keyboards + Device language @@ -319,21 +334,48 @@ Web content available in multiple languages will use the first supported language from this list. These preferences are synced with your browser settings. <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> + + Website languages + + + Add and rank your preferred languages. Websites will show in your preferred languages, when possible. These preferences are synced with your browser settings. <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> + Language used when translating pages Offer to translate pages in this language + + Brave sync chain language + + + Brave sites like Gmail, Drive, and YouTube use your Brave sync chain language unless you’ve changed the individual product language + + + Manage Brave sync chain language + Translation suggestion Offer to translate websites in other languages + + Offer Brave Translate for websites in other languages + Input methods + + Keyboard shortcut available + + + To switch to the last used input method, press <kbd><kbd>Ctrl</kbd>+<kbd>Space</kbd></kbd> + + + To switch to the next input method, press <kbd><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Space</kbd></kbd> + Open settings page for $1US keyboard @@ -367,13 +409,22 @@ Languages for spell check are based on your language preference - + Add spell check languages - - Your administrator doesn't allow this spell check language + + Search languages + + + Suggested + + + All languages + + + Your administrator doesn't allow this language - + Remove $1English (United States) @@ -406,46 +457,18 @@ Saved custom words will appear here - - Languages - - - Add languages or reorder list. <a>Learn more</a></a> - - - Input method - Enabled - - Show input options - Your administrator has limited the available input methods. - - Manage input methods - - - Manage input methods - Input method options Show input options in the shelf - - Restart device to show system text in $1English - - - Show system text in this language - - - - System text is shown in this language - @@ -725,6 +748,17 @@ Search and Assistant + + + Search + + + Quick Answers + + + With a right-click or long press, show related info for your text selection + + Files @@ -835,6 +869,9 @@ Open BraveVox settings + + Open BraveVox tutorial + Enable fullscreen magnifier @@ -950,6 +987,15 @@ and Ctrl+Alt+Brightness down to zoom out. Enable dictation (speak to type) + + Speech files downloaded + + + Downloading speech recognition files... $117% + + + Can't download speech files. Dictation will continue to work by sending your voice to Brave. + Enable on-screen keyboard @@ -1116,6 +1162,24 @@ Press an assigned switch to remove assignment. To get started, please make sure your USB or Bluetooth switch is connected to your Bravebook. You can also use keyboard keys. + + Do you want to assign additional switches? + + + I only use one switch + + + Assign one more switch + + + Assign this switch to "Next" to move to the next item on the page + + + Assign two more switches + + + Assign them to "Next" and "Previous" to move between items on the page + Pair Bluetooth switch @@ -1396,7 +1460,7 @@ Press an assigned switch to remove assignment. Developers - Linux development environment (Beta) + Linux development environment Shared folders are available in Linux at $1/mnt/chromeos. @@ -2206,8 +2270,8 @@ Press an assigned switch to remove assignment. Initializing - - Busy + + Applying changes... Join $1WiFi network @@ -2264,17 +2328,35 @@ Press an assigned switch to remove assignment. Allow mobile data roaming - On, not roaming + Not currently roaming - On, roaming + Currently roaming - Roaming off + Off + + + VPN Preferences Always connect through this VPN + + Always-on VPN + + + Automatically connects when you log in + + + Block traffic without VPN + + + Brave browser and Android traffic will be blocked unless a VPN is connected + + + VPN service + Automatically connect to this network @@ -2288,10 +2370,10 @@ Press an assigned switch to remove assignment. Automatically connect to cellular network - Remove profile + Remove Profile - Rename + Rename Profile Set up new network @@ -2317,9 +2399,30 @@ Press an assigned switch to remove assignment. Cancel + + New profile name + + + Name can use letters, numbers, and special characters + + + $115/$220 + + + Rename profile to $1Verizon + + + Name can use letters, numbers, and special characters, and must be $120 characters or fewer + + + Profile could not be renamed. Please try again or contact your carrier for technical support. + Remove "$1Profile 1"? + + You may not be able to reinstall this profile + Cancel @@ -2329,23 +2432,29 @@ Press an assigned switch to remove assignment. Okay - - This may cause a brief cellular network disconnection. + + Cancel removal of eSIM profile named $1Verizon + + + Remove eSIM profile named $1Verizon + + + This may cause your mobile network to briefly disconnect - - Installing profile. This may take up to 30 seconds. + + Adding profile. This may take a few minutes. - - Removing profile. This may take up to 30 seconds. + + Removing profile. This may take a few minutes. - - Renaming profile. This may take up to 30 seconds. + + Renaming profile. This may take a few minutes. - - Connecting to profile. This may take up to 30 seconds. + + Connecting to profile. This may take a few minutes. - - Refreshing profile list. This may take up to 30 seconds. + + Refreshing profile list. This may take a few minutes. Profile could not be removed. Please try again or contact your carrier for technical support. @@ -2408,13 +2517,13 @@ Press an assigned switch to remove assignment. Show proxy settings - Other users of this device can use this network. + Other users of this device can use this network - You are sharing this network with other users of this device. + You are sharing this network with other users of this device - This network is shared with you. + This network is shared with you This network is not synced to your account. <a target="_blank" rel="noopener noreferrer" href="$1https://google.com/">Learn more</a> @@ -2504,19 +2613,25 @@ Press an assigned switch to remove assignment. Instant Tethering - No available eSIM profiles. Download a new profile <a href="#" id="cellularEsimLink">here.</a> + No available eSIM profiles. Download a new <a href="#" id="cellularEsimLink">profile.</a> No SIM card inserted - No device detected <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> + No device detected. <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> Show device EID and QR code popup - Establish an internet connection first + Connect to Wi-Fi or Ethernet to set up eSIM + + + Enable mobile data to install an eSIM profile + + + You can install up to $15 eSIM profiles on this device. To add another profile, first remove an existing profile. @@ -3019,12 +3134,30 @@ Press an assigned switch to remove assignment. A restart is required before your device can be reset with Powerwash. <a>Learn more</a> + + Remove eSIM profiles before Powerwash + + + Powerwashing your device won't remove your eSIM profiles. Go to <a href="#">Mobile Settings</a> to manually remove these profiles. + + + Active profiles + + + $1My Verizon eSIM - <span id="providerName">$2Verizon Wireless</span> + + + I understand that installed eSIM profiles will not be removed by Powerwash + Reset Reset Button + + Continue + @@ -3586,7 +3719,7 @@ Press an assigned switch to remove assignment. Disabling can make your peripherals perform better, but may expose your personal data through unauthorized usage. - Your displays and peripherals may reset briefly. This may take a few seconds to take effect. + Your displays and peripherals may reset briefly. For this change to take effect, unplug and replug your peripherals. Cancel diff --git a/app/printing_strings.grdp b/app/printing_strings.grdp index 22790f1df156..af76d66ea696 100644 --- a/app/printing_strings.grdp +++ b/app/printing_strings.grdp @@ -51,6 +51,12 @@ All + + Odd pages only + + + Even pages only + Custom @@ -286,7 +292,7 @@ These settings are enforced by your administrator - + Save to Google Drive @@ -359,7 +365,7 @@ other {Exceeds limit of {COUNT} sheets of paper}} - + Print using system dialog... $1(Shift+Ctrl+P) diff --git a/app/profiles_strings.grdp b/app/profiles_strings.grdp index 442b9dd97e3e..373e2608259d 100644 --- a/app/profiles_strings.grdp +++ b/app/profiles_strings.grdp @@ -9,9 +9,6 @@ This is an account for kids managed by $1John.Doe@gmail.com and $2Jane.Doe@gmail.com. - - Current user - {0, plural, =1 {Guest} @@ -27,20 +24,20 @@ other {# open guest windows} } - + {0, plural, =1 {Private} - other {# open private windows} + other {# open Private windows} } - + {0, plural, =1 {Private} other {Private (#)} } - - This is a private window + + You're Private Error @@ -621,7 +618,7 @@ Edit - + Private diff --git a/app/profiles_strings_override.grdp b/app/profiles_strings_override.grdp index 684432c304fb..fc1cb7b05a4e 100644 --- a/app/profiles_strings_override.grdp +++ b/app/profiles_strings_override.grdp @@ -1,20 +1,20 @@ - + {0, plural, =1 {Private} - other {# open private windows} + other {# open Private windows} } - + {0, plural, =1 {Private} other {Private (#)} } - - This is a private window + + You're Private Profiles @@ -73,7 +73,7 @@ - + Private diff --git a/app/protocol_handler_intent_picker_strings.grdp b/app/protocol_handler_intent_picker_strings.grdp new file mode 100644 index 000000000000..5fd342718df5 --- /dev/null +++ b/app/protocol_handler_intent_picker_strings.grdp @@ -0,0 +1,17 @@ + + + + + + Do you want to use this application? + + + Allow + + + Cancel + + + Publisher: $1google.com + + diff --git a/app/settings_brave_strings.grdp b/app/settings_brave_strings.grdp index 4b8280b2277c..e4c9cf2d1c48 100644 --- a/app/settings_brave_strings.grdp +++ b/app/settings_brave_strings.grdp @@ -38,11 +38,6 @@ - - - Clear cookies and site data when you quit Brave - - Brave Pay (copied to Brave) @@ -143,9 +138,6 @@ Safe Browsing is off. Brave recommends turning it on. - - Brave can't check your extensions. Try again later. - @@ -189,8 +181,7 @@ - - + This language is used to display the Brave UI diff --git a/app/settings_brave_strings_override.grdp b/app/settings_brave_strings_override.grdp index e0b4ba2691a9..6fbf34099968 100644 --- a/app/settings_brave_strings_override.grdp +++ b/app/settings_brave_strings_override.grdp @@ -20,7 +20,7 @@ - + diff --git a/app/settings_strings.grdp b/app/settings_strings.grdp index 5d94ec35fbb7..90c0789fcb3a 100644 --- a/app/settings_strings.grdp +++ b/app/settings_strings.grdp @@ -689,6 +689,14 @@ More actions, saved account for $1example@gmail.com on $2www.google.com + + + Trusted vault + + + + Opt in to trusted vault + @@ -957,14 +965,20 @@ Signs you out of most sites. You'll stay signed in to your Brave sync chain so your synced data can be cleared. - Clears history and autocompletions in the address bar. + Clears history and autocompletions in the search box - Clears history and autocompletions in the address bar. Your Brave sync chain may have other forms of browsing history at <a target='_blank' href='$1'>myactivity.google.com</a></a>. + Clears history and autocompletions in the search box. Your Brave sync chain may have other forms of browsing history at <a target='_blank' href='$1'>myactivity.google.com</a></a>. + + + Clears history from all synced devices Clears history from all signed-in devices. Your Brave sync chain may have other forms of browsing history at <a target='_blank' href='$1'>myactivity.google.com</a></a>. + + To clear <a target="_blank" rel="noopener noreferrer" href="$1">search</a> or other forms of history, visit <a target="_blank" rel="noopener noreferrer" href="$2">My Brave sync chain</a> + Download history @@ -1133,6 +1147,15 @@ Enabled languages + + No languages added + + + Automatically translate these languages + + + Don’t offer to translate these languages + Spell check @@ -1217,6 +1240,12 @@ Privacy Sandbox is still in active development and is available in selected regions. For now, sites may try out Privacy Sandbox while continuing to use current web technologies like third-party cookies. <a href="$1" target="_blank" rel="noopener noreferrer">Learn more</a> + + With <a href="$1" target="_blank" rel="noopener noreferrer">Privacy Sandbox</a>, Brave is developing new technologies to safeguard you from cross-site tracking while preserving the open web. + + + Privacy Sandbox trials are still in active development and are available in selected regions. For now, sites may try out Privacy Sandbox while continuing to use current web technologies like third-party cookies. + Privacy Sandbox trials @@ -1229,6 +1258,15 @@ Advertisers can study the effectiveness of ads in a way that does not track you across sites. + + When on, sites may use the privacy-preserving techniques shown here to provide their content and services. These include alternatives to cross-site tracking. More trials may be added over time. + + + Advertisers and publishers can use FLoC, described later on this page. + + + Advertisers and publishers can study the effectiveness of ads in a way that does not track you across sites. + Details @@ -1238,6 +1276,28 @@ Trial features are off + + FLoC + + + When on and the status is active, Brave uses your browsing history over 7 days to determine a group, or “cohort”, that you’re in. Advertisers can select ads for the group. Your browsing history is kept private on your device. This trial is active only in + <a href="$1" target="_blank" rel="noopener noreferrer">some regions</a>. + + + This trial is active only in <a target="_blank" rel="noopener noreferrer" href="$1">some regions</a>. + + + Status + + + Group number + + + Next update + + + Reset group + Learn about and control new technologies that aim to replace third-party cookies @@ -1430,7 +1490,7 @@ Uses cookies to remember your preferences, even if you don’t visit those pages - Pre-fetches information from pages, including pages you have not yet visited. Information fetched may include cookies, if you allow cookies. + Preloads pages that Brave thinks you might visit. To do this, Brave may use cookies, if you allow cookies, and may encrypt and send pages through Brave to hide your identity from sites. Google Safe Browsing (protects you and your device from dangerous sites) @@ -1724,6 +1784,19 @@ Manage + + Keyboard shortcuts for search keywords + + + In the address bar, enter the keyword for the website you want to search. Then, use a keyboard shortcut to continue. + + + Space or Tab + + + Tab + + @@ -1778,7 +1851,7 @@ All sites can show any ads to you - Block ads on sites that show intrusive or misleading ads (recommended) + Block ads on sites that show intrusive or misleading ads Allowed to show any ads @@ -1805,7 +1878,7 @@ Sites might automatically download related files together to save you time - Sites can ask to automatically download multiple files (recommended) + Sites can ask to automatically download multiple files Don't allow sites to automatically download multiple files @@ -1820,11 +1893,14 @@ After you leave a site, it can keep syncing to finish tasks, like uploading photos or sending a chat message - Recently closed sites can finish sending and receiving data (recommended) + Recently closed sites can finish sending and receiving data Don't allow closed sites to finish sending or receiving data + + After closing a page, tasks you started might not finish + Allowed to finish sending and receiving data @@ -1844,7 +1920,7 @@ Sites usually use your video camera for communication features like video chatting - Sites can ask to use your camera (recommended) + Sites can ask to use your camera Don't allow sites to use your camera @@ -1907,7 +1983,7 @@ Sites usually access files and folders on your device for features like automatically saving your work - Sites can ask to edit files and folders on your device (recommended) + Sites can ask to edit files and folders on your device Don't allow sites to edit files or folders on your device @@ -1943,11 +2019,14 @@ Sites usually show images to provide illustration, like photos for online stores or news articles - Sites can show images (recommended) + Sites can show images Don't allow sites to show images + + Features that need images won't work + Allowed to show images @@ -1967,7 +2046,7 @@ Sites usually use Javascript to display interactive features, like video games or web forms - Sites can use Javascript (recommended) + Sites can use Javascript Don't allow sites to use Javascript @@ -1982,7 +2061,7 @@ Sites usually use your location for relevant features or info, like local news or nearby shops - Sites can ask for your location (recommended) + Sites can ask for your location Don't allow sites to see your location @@ -2000,7 +2079,7 @@ Sites usually use your microphone for communication features like video chatting - Sites can ask to use your microphone (recommended) + Sites can ask to use your microphone Don't allow sites to use your microphone @@ -2075,7 +2154,7 @@ Sites usually install payment handlers for shopping features like easier checkout - Sites can install payment handlers (recommended) + Sites can install payment handlers Don't allow sites to install payment handlers @@ -2099,7 +2178,7 @@ Sites can send pop-ups and use redirects - Don't allow sites to send pop-ups or use redirects (recommended) + Don't allow sites to send pop-ups or use redirects Allowed to send pop-ups and use redirects @@ -2111,11 +2190,14 @@ When a site plays content protected by copyright, it might ask to recognize your device - Sites can ask to play protected content (recommended) + Sites can ask to play protected content Don't allow sites to play protected content + + Media with a copyright might not play + Allowed to play protected content @@ -2147,11 +2229,14 @@ Sites might play sound to provide audio for music, videos, and other media - Sites can play sound (recommended) + Sites can play sound Don't allow sites to play sound + + Features that need sound won't work + Allowed to play sound @@ -2257,14 +2342,14 @@ Sites can use cookies to see your browsing activity across different sites, for example, to personalize ads - + Block third-party cookies in Private - + Sites can use cookies to improve your browsing experience, for example, to keep you signed in or to remember items in your shopping cart - - While in private, sites can't use your cookies to see your browsing activity across different sites, for example, to personalize ads. Features on some sites may break. + + While in Private, sites can't use your cookies to see your browsing activity across different sites, for example, to personalize ads. Features on some sites may break. Block third-party cookies @@ -2601,7 +2686,7 @@ Third-party cookies are blocked - + Third-party cookies are blocked in Private mode @@ -2791,9 +2876,6 @@ Additional content settings - - To change this setting, first <a target="_blank" rel="noopener noreferrer" href="$1">turn on identifiers</a> - Allowlisted internally @@ -2959,10 +3041,10 @@ Remove - - Current private session only + + Current Private session only - + This custom setting will be removed when you close all your Private windows @@ -3642,6 +3724,9 @@ Name + + Try a shorter name + Your security key has no fingerprints stored @@ -3669,6 +3754,9 @@ Your security key is not protected with a PIN. To manage fingerprints, first create a PIN. + + Your security key can't store any more fingerprints. To add a new one, first delete an existing fingerprint. + To continue, insert and touch your security key diff --git a/app/settings_strings_override.grdp b/app/settings_strings_override.grdp index 3a2dc584f361..67f0101d7e60 100644 --- a/app/settings_strings_override.grdp +++ b/app/settings_strings_override.grdp @@ -68,21 +68,21 @@ - + Block third-party cookies in Private - - While in private, sites can't use your cookies to see your browsing activity across different sites, for example, to personalize ads. Features on some sites may break. + + While in Private, sites can't use your cookies to see your browsing activity across different sites, for example, to personalize ads. Features on some sites may break. - + Third-party cookies are blocked in Private mode - - Current private session only + + Current Private session only - + This custom setting will be removed when you close all your Private windows diff --git a/app/shared_settings_strings.grdp b/app/shared_settings_strings.grdp index 23d8e8ea9333..273efe393c9a 100644 --- a/app/shared_settings_strings.grdp +++ b/app/shared_settings_strings.grdp @@ -17,8 +17,8 @@ Caption preferences - - Customize caption size and style for apps and sites that support this setting + + Customize caption size and style for Live Caption. Some apps and sites will also use this setting. Text size @@ -104,7 +104,7 @@ Device name - Device Name + Change device name New device name @@ -115,6 +115,9 @@ Current device name is $1Michael's Bravebook + + Rename + Manage contacts @@ -125,7 +128,7 @@ Edit - Done + Save Data usage @@ -169,6 +172,9 @@ Device visibility + + Save + Share files with profiles around you. <a>Learn more</a> diff --git a/app/sharesheet_strings.grdp b/app/sharesheet_strings.grdp index 6f06480e86fa..c64457d3ff8c 100644 --- a/app/sharesheet_strings.grdp +++ b/app/sharesheet_strings.grdp @@ -15,7 +15,15 @@ Fewer apps - - No apps available + + No apps available for this content + + + Visit the Play Store to find more apps + + + {COUNT, plural, + =1 {{COUNT} file} + other {{COUNT} files}} diff --git a/app/theme/default_100_percent/common/save_address.png b/app/theme/default_100_percent/common/save_address.png new file mode 100644 index 000000000000..d884b8a87b72 Binary files /dev/null and b/app/theme/default_100_percent/common/save_address.png differ diff --git a/app/theme/default_100_percent/common/save_address_dark.png b/app/theme/default_100_percent/common/save_address_dark.png new file mode 100644 index 000000000000..d884b8a87b72 Binary files /dev/null and b/app/theme/default_100_percent/common/save_address_dark.png differ diff --git a/app/theme/default_100_percent/common/save_card.png b/app/theme/default_100_percent/common/save_card.png new file mode 100644 index 000000000000..d884b8a87b72 Binary files /dev/null and b/app/theme/default_100_percent/common/save_card.png differ diff --git a/app/theme/default_100_percent/common/save_card_dark.png b/app/theme/default_100_percent/common/save_card_dark.png new file mode 100644 index 000000000000..d884b8a87b72 Binary files /dev/null and b/app/theme/default_100_percent/common/save_card_dark.png differ diff --git a/app/theme/default_100_percent/common/save_password.png b/app/theme/default_100_percent/common/save_password.png new file mode 100644 index 000000000000..d884b8a87b72 Binary files /dev/null and b/app/theme/default_100_percent/common/save_password.png differ diff --git a/app/theme/default_100_percent/common/save_password_dark.png b/app/theme/default_100_percent/common/save_password_dark.png new file mode 100644 index 000000000000..d884b8a87b72 Binary files /dev/null and b/app/theme/default_100_percent/common/save_password_dark.png differ diff --git a/app/theme/default_200_percent/common/save_address.png b/app/theme/default_200_percent/common/save_address.png new file mode 100644 index 000000000000..23793861206b Binary files /dev/null and b/app/theme/default_200_percent/common/save_address.png differ diff --git a/app/theme/default_200_percent/common/save_address_dark.png b/app/theme/default_200_percent/common/save_address_dark.png new file mode 100644 index 000000000000..23793861206b Binary files /dev/null and b/app/theme/default_200_percent/common/save_address_dark.png differ diff --git a/app/theme/default_200_percent/common/save_card.png b/app/theme/default_200_percent/common/save_card.png new file mode 100644 index 000000000000..23793861206b Binary files /dev/null and b/app/theme/default_200_percent/common/save_card.png differ diff --git a/app/theme/default_200_percent/common/save_card_dark.png b/app/theme/default_200_percent/common/save_card_dark.png new file mode 100644 index 000000000000..23793861206b Binary files /dev/null and b/app/theme/default_200_percent/common/save_card_dark.png differ diff --git a/app/theme/default_200_percent/common/save_password.png b/app/theme/default_200_percent/common/save_password.png new file mode 100644 index 000000000000..23793861206b Binary files /dev/null and b/app/theme/default_200_percent/common/save_password.png differ diff --git a/app/theme/default_200_percent/common/save_password_dark.png b/app/theme/default_200_percent/common/save_password_dark.png new file mode 100644 index 000000000000..23793861206b Binary files /dev/null and b/app/theme/default_200_percent/common/save_password_dark.png differ diff --git a/app/vr_strings.grdp b/app/vr_strings.grdp index 353e8953e0db..780bba463659 100644 --- a/app/vr_strings.grdp +++ b/app/vr_strings.grdp @@ -143,19 +143,19 @@ Finish - - New private tab + + New Private tab - + Settings - - Close private tabs + + Close Private tabs Tabs - + Private diff --git a/app/vr_strings_override.grdp b/app/vr_strings_override.grdp index 29539ebb5bab..911219c38f47 100644 --- a/app/vr_strings_override.grdp +++ b/app/vr_strings_override.grdp @@ -18,13 +18,13 @@ - - New private tab + + New Private tab - - Close private tabs + + Close Private tabs - + Private diff --git a/browser/android/brave_sync_worker.cc b/browser/android/brave_sync_worker.cc index a4a22cdccc7f..d40b62fe4123 100644 --- a/browser/android/brave_sync_worker.cc +++ b/browser/android/brave_sync_worker.cc @@ -226,8 +226,8 @@ void BraveSyncWorker::SetEncryptionPassphrase(syncer::SyncService* service) { syncer::SyncUserSettings* sync_user_settings = service->GetUserSettings(); DCHECK(!sync_user_settings->IsPassphraseRequired()); - if (sync_user_settings->IsEncryptEverythingAllowed() && - !sync_user_settings->IsUsingSecondaryPassphrase() && + if (sync_user_settings->IsCustomPassphraseAllowed() && + !sync_user_settings->IsUsingExplicitPassphrase() && !sync_user_settings->IsTrustedVaultKeyRequired()) { sync_user_settings->SetEncryptionPassphrase(this->passphrase_); ProfileMetrics::LogProfileSyncInfo( diff --git a/browser/android/preferences/background_video_playback_tab_helper.cc b/browser/android/preferences/background_video_playback_tab_helper.cc index 655799b4fd29..c40d7019baff 100644 --- a/browser/android/preferences/background_video_playback_tab_helper.cc +++ b/browser/android/preferences/background_video_playback_tab_helper.cc @@ -16,14 +16,14 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" -#include "content/public/browser/web_contents.h" #include "content/public/browser/navigation_handle.h" +#include "content/public/browser/web_contents.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "url/gurl.h" namespace { -const char k_youtube_background_playback_script[] = - "(function() {" +const char16_t k_youtube_background_playback_script[] = + u"(function() {" " if (document._addEventListener === undefined) {" " document._addEventListener = document.addEventListener;" " document.addEventListener = function(a,b,c) {" @@ -58,11 +58,9 @@ bool IsBackgroundVideoPlaybackEnabled(content::WebContents* contents) { BackgroundVideoPlaybackTabHelper::BackgroundVideoPlaybackTabHelper( content::WebContents* contents) - : WebContentsObserver(contents) { -} + : WebContentsObserver(contents) {} -BackgroundVideoPlaybackTabHelper::~BackgroundVideoPlaybackTabHelper() { -} +BackgroundVideoPlaybackTabHelper::~BackgroundVideoPlaybackTabHelper() {} void BackgroundVideoPlaybackTabHelper::DidFinishNavigation( content::NavigationHandle* navigation_handle) { @@ -72,8 +70,7 @@ void BackgroundVideoPlaybackTabHelper::DidFinishNavigation( } if (IsBackgroundVideoPlaybackEnabled(web_contents())) { web_contents()->GetMainFrame()->ExecuteJavaScript( - base::UTF8ToUTF16(k_youtube_background_playback_script), - base::NullCallback()); + k_youtube_background_playback_script, base::NullCallback()); } } diff --git a/browser/autoplay/autoplay_browsertest.cc b/browser/autoplay/autoplay_browsertest.cc index cff827291e3f..b21132eb7d18 100644 --- a/browser/autoplay/autoplay_browsertest.cc +++ b/browser/autoplay/autoplay_browsertest.cc @@ -102,11 +102,11 @@ class AutoplayBrowserTest : public InProcessBrowserTest { void GotoAutoplayByAttr(bool muted) { if (muted) { - ASSERT_EQ(true, EvalJsWithManualReply(contents(), - "clickAutoplayByAttrMuted()")); + ASSERT_EQ(true, EvalJs(contents(), "clickAutoplayByAttrMuted()", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)); } else { - ASSERT_EQ(true, - EvalJsWithManualReply(contents(), "clickAutoplayByAttr()")); + ASSERT_EQ(true, EvalJs(contents(), "clickAutoplayByAttr()", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)); } ASSERT_TRUE(WaitForLoadStop(contents())); WaitForCanPlay(); @@ -114,19 +114,19 @@ class AutoplayBrowserTest : public InProcessBrowserTest { void GotoAutoplayByMethod(bool muted) { if (muted) { - ASSERT_EQ(true, EvalJsWithManualReply(contents(), - "clickAutoplayByMethodMuted()")); + ASSERT_EQ(true, EvalJs(contents(), "clickAutoplayByMethodMuted()", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)); } else { - ASSERT_EQ(true, - EvalJsWithManualReply(contents(), "clickAutoplayByMethod()")); + ASSERT_EQ(true, EvalJs(contents(), "clickAutoplayByMethod()", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)); } ASSERT_TRUE(WaitForLoadStop(contents())); WaitForCanPlay(); } void WaitForCanPlay() { - ASSERT_EQ("CANPLAY", - EvalJsWithManualReply(contents(), "notifyWhenCanPlay()")); + ASSERT_EQ("CANPLAY", EvalJs(contents(), "notifyWhenCanPlay()", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)); } private: diff --git a/browser/binance/binance_protocol_handler.cc b/browser/binance/binance_protocol_handler.cc index c278eba01a10..3d12c4db5367 100644 --- a/browser/binance/binance_protocol_handler.cc +++ b/browser/binance/binance_protocol_handler.cc @@ -21,15 +21,15 @@ #include "content/public/browser/browser_thread.h" #include "net/base/escape.h" #include "net/base/url_util.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace { -void LoadNewTabURL( - const GURL& url, - content::WebContents::OnceGetter web_contents_getter, - ui::PageTransition page_transition, - bool has_user_gesture, - const base::Optional& initiating_origin) { +void LoadNewTabURL(const GURL& url, + content::WebContents::OnceGetter web_contents_getter, + ui::PageTransition page_transition, + bool has_user_gesture, + const absl::optional& initiating_origin) { content::WebContents* web_contents = std::move(web_contents_getter).Run(); if (!web_contents) { return; @@ -74,7 +74,7 @@ void HandleBinanceProtocol(const GURL& url, content::WebContents::OnceGetter web_contents_getter, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiator) { + const absl::optional& initiator) { DCHECK(IsBinanceProtocol(url)); base::PostTask( FROM_HERE, {content::BrowserThread::UI}, diff --git a/browser/binance/binance_protocol_handler.h b/browser/binance/binance_protocol_handler.h index ed01adf521d6..1258f96d4d7b 100644 --- a/browser/binance/binance_protocol_handler.h +++ b/browser/binance/binance_protocol_handler.h @@ -16,7 +16,7 @@ void HandleBinanceProtocol(const GURL& url, content::WebContents::OnceGetter web_contents_getter, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiator); + const absl::optional& initiator); bool IsBinanceProtocol(const GURL& url); diff --git a/browser/brave_ads/android/java_sources.gni b/browser/brave_ads/android/java_sources.gni index 58c5e461eb95..f93bfcb4521b 100644 --- a/browser/brave_ads/android/java_sources.gni +++ b/browser/brave_ads/android/java_sources.gni @@ -1,8 +1,7 @@ brave_ads_java_sources = [ "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/BraveAdsNativeHelper.java", - "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/dialogs/BraveAdsSignupDialog.java", "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/dialogs/BraveAdsNotificationDialog.java", + "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/dialogs/BraveAdsSignupDialog.java", "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/notifications/BraveAds.java", - "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java", "../../brave/browser/brave_ads/android/java/org/chromium/chrome/browser/onboarding/BraveAdsOnboardingFragment.java", ] diff --git a/browser/brave_browser_main_parts.cc b/browser/brave_browser_main_parts.cc index 2d9838d6cb25..3e602b5b6d92 100644 --- a/browser/brave_browser_main_parts.cc +++ b/browser/brave_browser_main_parts.cc @@ -5,6 +5,8 @@ #include "brave/browser/brave_browser_main_parts.h" +#include + #include "base/command_line.h" #include "brave/browser/browsing_data/brave_clear_browsing_data.h" #include "brave/browser/ethereum_remote_client/buildflags/buildflags.h" @@ -25,6 +27,7 @@ #include "base/files/file_util.h" #include "brave/components/tor/tor_constants.h" #include "chrome/browser/browser_process_impl.h" +#include "chrome/browser/profiles/profile_attributes_init_params.h" #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_metrics.h" @@ -34,9 +37,9 @@ #if !defined(OS_ANDROID) #include "brave/browser/infobars/brave_confirm_p3a_infobar_delegate.h" #include "brave/browser/infobars/crypto_wallets_infobar_delegate.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" +#include "components/infobars/content/content_infobar_manager.h" #include "content/public/browser/web_contents.h" #endif @@ -76,10 +79,9 @@ void BraveBrowserMainParts::PostBrowserStart() { ProfileAttributesEntry* entry = storage.GetProfileAttributesWithPath(tor_legacy_path); if (!entry) { - storage.AddProfile(tor_legacy_path, std::u16string(), std::string(), - std::u16string(), - /* is_consented_primary_account*/ false, 0, - std::string(), EmptyAccountId()); + ProfileAttributesInitParams params; + params.profile_path = tor_legacy_path; + storage.AddProfile(std::move(params)); } profile_manager->MaybeScheduleProfileForDeletion( @@ -107,12 +109,12 @@ void BraveBrowserMainParts::PostBrowserStart() { active_web_contents = browser->tab_strip_model()->GetActiveWebContents(); if (active_web_contents) { - InfoBarService* infobar_service = - InfoBarService::FromWebContents(active_web_contents); + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(active_web_contents); - if (infobar_service) { + if (infobar_manager) { BraveConfirmP3AInfoBarDelegate::Create( - infobar_service, g_browser_process->local_state()); + infobar_manager, g_browser_process->local_state()); #if BUILDFLAG(ENABLE_BRAVE_SYNC) auto* sync_service = ProfileSyncServiceFactory::IsSyncAllowed(profile()) @@ -121,7 +123,7 @@ void BraveBrowserMainParts::PostBrowserStart() { const bool is_v2_user = sync_service && sync_service->GetUserSettings()->IsFirstSetupComplete(); - SyncV2MigrateInfoBarDelegate::Create(infobar_service, is_v2_user, + SyncV2MigrateInfoBarDelegate::Create(infobar_manager, is_v2_user, profile(), browser); #endif // BUILDFLAG(ENABLE_BRAVE_SYNC) } diff --git a/browser/brave_browser_main_parts_mac.h b/browser/brave_browser_main_parts_mac.h index 48104a28ad25..f963b0b78445 100644 --- a/browser/brave_browser_main_parts_mac.h +++ b/browser/brave_browser_main_parts_mac.h @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* 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/. */ @@ -14,7 +15,7 @@ class BraveBrowserMainPartsMac : public ChromeBrowserMainPartsMac { private: // ChromeBrowserMainPartsMac overrides: - void PreMainMessageLoopStart() override; + void PreCreateMainMessageLoop() override; }; #endif // BRAVE_BROWSER_BRAVE_BROWSER_MAIN_PARTS_MAC_H_ diff --git a/browser/brave_browser_main_parts_mac.mm b/browser/brave_browser_main_parts_mac.mm index 94bbf6d466a5..71aca55122d2 100644 --- a/browser/brave_browser_main_parts_mac.mm +++ b/browser/brave_browser_main_parts_mac.mm @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* 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/. */ @@ -10,8 +11,8 @@ #import "brave/browser/mac/sparkle_glue.h" #endif -void BraveBrowserMainPartsMac::PreMainMessageLoopStart() { - ChromeBrowserMainPartsMac::PreMainMessageLoopStart(); +void BraveBrowserMainPartsMac::PreCreateMainMessageLoop() { + ChromeBrowserMainPartsMac::PreCreateMainMessageLoop(); #if BUILDFLAG(ENABLE_SPARKLE) // It would be no-op if udpate is disabled. diff --git a/browser/brave_browser_process_impl.cc b/browser/brave_browser_process_impl.cc index fec67e76fe47..61973002d4a3 100644 --- a/browser/brave_browser_process_impl.cc +++ b/browser/brave_browser_process_impl.cc @@ -32,9 +32,9 @@ #include "brave/components/brave_sync/network_time_helper.h" #include "brave/components/ntp_background_images/browser/features.h" #include "brave/components/ntp_background_images/browser/ntp_background_images_service.h" -#include "brave/components/p3a/brave_histogram_rewrite.h" #include "brave/components/p3a/brave_p3a_service.h" #include "brave/components/p3a/buildflags.h" +#include "brave/components/p3a/histograms_braveizer.h" #include "brave/services/network/public/cpp/system_request_handler.h" #include "chrome/browser/component_updater/component_updater_utils.h" #include "chrome/browser/net/system_network_context_manager.h" @@ -128,7 +128,7 @@ BraveBrowserProcessImpl::BraveBrowserProcessImpl(StartupData* startup_data) // Create P3A Service early to catch more histograms. The full initialization // should be started once browser process impl is ready. brave_p3a_service(); - brave::SetupHistogramsBraveization(); + histogram_braveizer_ = brave::HistogramsBraveizer::Create(); #endif // BUILDFLAG(BRAVE_P3A_ENABLED) } diff --git a/browser/brave_browser_process_impl.h b/browser/brave_browser_process_impl.h index dcee3cde5aeb..45c4e2ab1eb4 100644 --- a/browser/brave_browser_process_impl.h +++ b/browser/brave_browser_process_impl.h @@ -23,6 +23,7 @@ namespace brave { class BraveReferralsService; class BraveP3AService; +class HistogramsBraveizer; class BraveFederatedLearningService; } // namespace brave @@ -166,6 +167,7 @@ class BraveBrowserProcessImpl : public BraveBrowserProcess, std::unique_ptr brave_federated_learning_service_; scoped_refptr brave_p3a_service_; + scoped_refptr histogram_braveizer_; std::unique_ptr ntp_background_images_service_; diff --git a/browser/brave_content_browser_client.cc b/browser/brave_content_browser_client.cc index a9027ba0b7d3..a63d99317d78 100644 --- a/browser/brave_content_browser_client.cc +++ b/browser/brave_content_browser_client.cc @@ -242,7 +242,7 @@ void BindBraveSearchFallbackHost( content::BrowserContext* context = render_process_host->GetBrowserContext(); mojo::MakeSelfOwnedReceiver( std::make_unique( - content::BrowserContext::GetDefaultStoragePartition(context) + context->GetDefaultStoragePartition() ->GetURLLoaderFactoryForBrowserProcess()), std::move(receiver)); } @@ -365,7 +365,7 @@ bool BraveContentBrowserClient::HandleExternalProtocol( bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiating_origin, + const absl::optional& initiating_origin, mojo::PendingRemote* out_factory) { #if BUILDFLAG(ENABLE_BRAVE_WEBTORRENT) if (webtorrent::IsMagnetProtocol(url)) { @@ -477,7 +477,7 @@ bool BraveContentBrowserClient::WillCreateURLLoaderFactory( int render_process_id, URLLoaderFactoryType type, const url::Origin& request_initiator, - base::Optional navigation_id, + absl::optional navigation_id, ukm::SourceIdObj ukm_source_id, mojo::PendingReceiver* factory_receiver, mojo::PendingRemote* @@ -510,7 +510,7 @@ void BraveContentBrowserClient::CreateWebSocket( content::ContentBrowserClient::WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const base::Optional& user_agent, + const absl::optional& user_agent, mojo::PendingRemote handshake_client) { auto* proxy = BraveProxyingWebSocket::ProxyWebSocket( diff --git a/browser/brave_content_browser_client.h b/browser/brave_content_browser_client.h index d9ad87ebc496..66272575ebe0 100644 --- a/browser/brave_content_browser_client.h +++ b/browser/brave_content_browser_client.h @@ -10,12 +10,12 @@ #include #include -#include "base/optional.h" #include "chrome/browser/chrome_content_browser_client.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "services/metrics/public/cpp/ukm_source_id.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/loader/referrer.mojom.h" class PrefChangeRegistrar; @@ -52,7 +52,7 @@ class BraveContentBrowserClient : public ChromeContentBrowserClient { bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiating_origin, + const absl::optional& initiating_origin, mojo::PendingRemote* out_factory) override; @@ -82,7 +82,7 @@ class BraveContentBrowserClient : public ChromeContentBrowserClient { int render_process_id, URLLoaderFactoryType type, const url::Origin& request_initiator, - base::Optional navigation_id, + absl::optional navigation_id, ukm::SourceIdObj ukm_source_id, mojo::PendingReceiver* factory_receiver, mojo::PendingRemote* @@ -97,7 +97,7 @@ class BraveContentBrowserClient : public ChromeContentBrowserClient { content::ContentBrowserClient::WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const base::Optional& user_agent, + const absl::optional& user_agent, mojo::PendingRemote handshake_client) override; diff --git a/browser/brave_content_browser_client_browsertest.cc b/browser/brave_content_browser_client_browsertest.cc index 6050a37eb217..7605673481d3 100644 --- a/browser/brave_content_browser_client_browsertest.cc +++ b/browser/brave_content_browser_client_browsertest.cc @@ -25,6 +25,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings_types.h" +#include "components/omnibox/browser/location_bar_model.h" #include "components/prefs/pref_service.h" #include "content/public/browser/navigation_entry.h" #include "content/public/test/browser_test.h" diff --git a/browser/brave_drm_tab_helper.cc b/browser/brave_drm_tab_helper.cc index 3ed249bffbe0..086f62900b79 100644 --- a/browser/brave_drm_tab_helper.cc +++ b/browser/brave_drm_tab_helper.cc @@ -12,6 +12,7 @@ #include "brave/common/pref_names.h" #include "chrome/browser/browser_process_impl.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "components/prefs/pref_service.h" diff --git a/browser/brave_rewards/extension_rewards_notification_service_observer.cc b/browser/brave_rewards/extension_rewards_notification_service_observer.cc index b47833eb788a..8e06501b0d8b 100644 --- a/browser/brave_rewards/extension_rewards_notification_service_observer.cc +++ b/browser/brave_rewards/extension_rewards_notification_service_observer.cc @@ -34,15 +34,12 @@ void ExtensionRewardsNotificationServiceObserver::OnNotificationAdded( return; } - std::unique_ptr args( - extensions::api::rewards_notifications::OnNotificationAdded::Create( - rewards_notification.id_, rewards_notification.type_, - rewards_notification.timestamp_, rewards_notification.args_) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_REWARDS_NOTIFICATION_ADDED, extensions::api::rewards_notifications::OnNotificationAdded::kEventName, - std::move(args))); + extensions::api::rewards_notifications::OnNotificationAdded::Create( + rewards_notification.id_, rewards_notification.type_, + rewards_notification.timestamp_, rewards_notification.args_))); event_router->BroadcastEvent(std::move(event)); } @@ -56,15 +53,12 @@ void ExtensionRewardsNotificationServiceObserver::OnNotificationDeleted( return; } - std::unique_ptr args( - extensions::api::rewards_notifications::OnNotificationDeleted::Create( - rewards_notification.id_, rewards_notification.type_, - rewards_notification.timestamp_) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_REWARDS_NOTIFICATION_DELETED, extensions::api::rewards_notifications::OnNotificationDeleted::kEventName, - std::move(args))); + extensions::api::rewards_notifications::OnNotificationDeleted::Create( + rewards_notification.id_, rewards_notification.type_, + rewards_notification.timestamp_))); event_router->BroadcastEvent(std::move(event)); } @@ -77,14 +71,12 @@ void ExtensionRewardsNotificationServiceObserver:: return; } - std::unique_ptr args( - extensions::api::rewards_notifications::OnAllNotificationsDeleted::Create() - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_REWARDS_ALL_NOTIFICATIONS_DELETED, extensions::api::rewards_notifications::OnAllNotificationsDeleted:: kEventName, - std::move(args))); + extensions::api::rewards_notifications::OnAllNotificationsDeleted:: + Create())); event_router->BroadcastEvent(std::move(event)); } @@ -98,15 +90,12 @@ void ExtensionRewardsNotificationServiceObserver::OnGetNotification( return; } - std::unique_ptr args( - extensions::api::rewards_notifications::OnGetNotification::Create( - rewards_notification.id_, rewards_notification.type_, - rewards_notification.timestamp_, rewards_notification.args_) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_REWARDS_GET_NOTIFICATION, extensions::api::rewards_notifications::OnGetNotification::kEventName, - std::move(args))); + extensions::api::rewards_notifications::OnGetNotification::Create( + rewards_notification.id_, rewards_notification.type_, + rewards_notification.timestamp_, rewards_notification.args_))); event_router->BroadcastEvent(std::move(event)); } @@ -134,14 +123,12 @@ void ExtensionRewardsNotificationServiceObserver::OnGetAllNotifications( notifications_type.timestamp = item.timestamp_; notifications_type.args = item.args_; } - std::unique_ptr args( - extensions::api::rewards_notifications::OnGetAllNotifications::Create( - notifications_list) - .release()); + std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_REWARDS_GET_ALL_NOTIFICATIONS, extensions::api::rewards_notifications::OnGetAllNotifications::kEventName, - std::move(args))); + extensions::api::rewards_notifications::OnGetAllNotifications::Create( + notifications_list))); event_router->BroadcastEvent(std::move(event)); } diff --git a/browser/brave_rewards/extension_rewards_service_observer.cc b/browser/brave_rewards/extension_rewards_service_observer.cc index 4a77700b5601..6c10322fc630 100644 --- a/browser/brave_rewards/extension_rewards_service_observer.cc +++ b/browser/brave_rewards/extension_rewards_service_observer.cc @@ -32,13 +32,10 @@ void ExtensionRewardsServiceObserver::OnRewardsInitialized( return; } - std::unique_ptr args( - extensions::api::brave_rewards::Initialized::Create(0).release()); - std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::Initialized::kEventName, - std::move(args))); + extensions::api::brave_rewards::Initialized::Create(0))); event_router->BroadcastEvent(std::move(event)); } @@ -63,15 +60,12 @@ void ExtensionRewardsServiceObserver::OnPanelPublisherInfo( publisher.provider = info->provider; publisher.fav_icon_url = info->favicon_url; publisher.publisher_key = info->id; - std::unique_ptr args( - extensions::api::brave_rewards::OnPublisherData::Create(windowId, - publisher) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_ON_PUBLISHER_DATA, extensions::api::brave_rewards::OnPublisherData::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnPublisherData::Create(windowId, + publisher))); event_router->BroadcastEvent(std::move(event)); } @@ -100,14 +94,11 @@ void ExtensionRewardsServiceObserver::OnFetchPromotions( promotion.amount = item->approximate_value; } - std::unique_ptr args( - extensions::api::brave_rewards::OnPromotions::Create( - static_cast(result), promotions) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnPromotions::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnPromotions::Create( + static_cast(result), promotions))); event_router->BroadcastEvent(std::move(event)); } @@ -129,13 +120,11 @@ void ExtensionRewardsServiceObserver::OnPromotionFinished( promotion_api.expires_at = promotion->expires_at; promotion_api.amount = promotion->approximate_value; - std::unique_ptr args( - extensions::api::brave_rewards::OnPromotionFinish::Create - (static_cast(result), promotion_api).release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnPromotionFinish::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnPromotionFinish::Create( + static_cast(result), promotion_api))); event_router->BroadcastEvent(std::move(event)); } @@ -147,13 +136,10 @@ void ExtensionRewardsServiceObserver::OnAdsEnabled( return; } - std::unique_ptr args( - extensions::api::brave_rewards::OnAdsEnabled::Create( - ads_enabled).release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnAdsEnabled::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnAdsEnabled::Create(ads_enabled))); event_router->BroadcastEvent(std::move(event)); } @@ -165,13 +151,11 @@ void ExtensionRewardsServiceObserver::OnPendingContributionSaved( return; } - std::unique_ptr args( - extensions::api::brave_rewards::OnPendingContributionSaved::Create( - static_cast(result)).release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnPendingContributionSaved::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnPendingContributionSaved::Create( + static_cast(result)))); event_router->BroadcastEvent(std::move(event)); } @@ -198,15 +182,11 @@ void ExtensionRewardsServiceObserver::OnPublisherListNormalized( publisher.status = static_cast(item->status); } - std::unique_ptr args( - extensions::api::brave_rewards:: - OnPublisherListNormalized::Create(publishers) - .release()); - std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnPublisherListNormalized::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnPublisherListNormalized::Create( + publishers))); event_router->BroadcastEvent(std::move(event)); } @@ -223,13 +203,10 @@ void ExtensionRewardsServiceObserver::OnExcludedSitesChanged( result.publisher_key = publisher_key; result.excluded = excluded; - std::unique_ptr args( - extensions::api::brave_rewards::OnExcludedSitesChanged::Create(result) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnExcludedSitesChanged::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnExcludedSitesChanged::Create(result))); event_router->BroadcastEvent(std::move(event)); } @@ -241,13 +218,10 @@ void ExtensionRewardsServiceObserver::OnRecurringTipSaved( return; } - std::unique_ptr args( - extensions::api::brave_rewards::OnRecurringTipSaved::Create( - success).release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnRecurringTipSaved::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnRecurringTipSaved::Create(success))); event_router->BroadcastEvent(std::move(event)); } @@ -259,13 +233,10 @@ void ExtensionRewardsServiceObserver::OnRecurringTipRemoved( return; } - std::unique_ptr args( - extensions::api::brave_rewards::OnRecurringTipRemoved::Create( - success).release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnRecurringTipRemoved::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnRecurringTipRemoved::Create(success))); event_router->BroadcastEvent(std::move(event)); } @@ -278,13 +249,11 @@ void ExtensionRewardsServiceObserver::OnPendingContributionRemoved( return; } - std::unique_ptr args( - extensions::api::brave_rewards::OnPendingContributionRemoved::Create( - static_cast(result)).release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnPendingContributionRemoved::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnPendingContributionRemoved::Create( + static_cast(result)))); event_router->BroadcastEvent(std::move(event)); } @@ -304,13 +273,10 @@ void ExtensionRewardsServiceObserver::OnReconcileComplete( properties.result = static_cast(result); properties.type = static_cast(type); - std::unique_ptr args( - extensions::api::brave_rewards::OnReconcileComplete::Create(properties) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnReconcileComplete::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnReconcileComplete::Create(properties))); event_router->BroadcastEvent(std::move(event)); } @@ -327,13 +293,10 @@ void ExtensionRewardsServiceObserver::OnDisconnectWallet( properties.result = static_cast(result); properties.wallet_type = wallet_type; - std::unique_ptr args( - extensions::api::brave_rewards::OnDisconnectWallet::Create(properties) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnDisconnectWallet::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnDisconnectWallet::Create(properties))); event_router->BroadcastEvent(std::move(event)); } @@ -344,11 +307,10 @@ void ExtensionRewardsServiceObserver::OnUnblindedTokensReady( return; } - auto args = std::make_unique(); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnUnblindedTokensReady::kEventName, - std::move(args))); + std::vector())); event_router->BroadcastEvent(std::move(event)); } @@ -361,13 +323,10 @@ void ExtensionRewardsServiceObserver::OnCompleteReset(const bool success) { extensions::api::brave_rewards::OnCompleteReset::Properties properties; properties.success = success; - std::unique_ptr args( - extensions::api::brave_rewards::OnCompleteReset::Create(properties) - .release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_rewards::OnCompleteReset::kEventName, - std::move(args))); + extensions::api::brave_rewards::OnCompleteReset::Create(properties))); event_router->BroadcastEvent(std::move(event)); } diff --git a/browser/brave_scheme_load_browsertest.cc b/browser/brave_scheme_load_browsertest.cc index ff22475cc50c..1dc2b4618f8e 100644 --- a/browser/brave_scheme_load_browsertest.cc +++ b/browser/brave_scheme_load_browsertest.cc @@ -9,9 +9,12 @@ #include "brave/common/brave_paths.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_navigator.h" +#include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/omnibox/browser/location_bar_model.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/common/url_constants.h" diff --git a/browser/brave_search/brave_search_browsertest.cc b/browser/brave_search/brave_search_browsertest.cc index d3cb1dc89143..60619db8635d 100644 --- a/browser/brave_search/brave_search_browsertest.cc +++ b/browser/brave_search/brave_search_browsertest.cc @@ -4,6 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "base/path_service.h" +#include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "base/test/scoped_feature_list.h" #include "base/test/thread_test_helper.h" @@ -154,8 +155,8 @@ IN_PROC_BROWSER_TEST_F(BraveSearchTest, CheckForAFunction) { browser()->tab_strip_model()->GetActiveWebContents(); WaitForLoadStop(contents); - auto result_first = - EvalJsWithManualReply(contents, GetChromeFetchBackupResultsAvailScript()); + auto result_first = EvalJs(contents, GetChromeFetchBackupResultsAvailScript(), + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); EXPECT_EQ(base::Value(true), result_first.value); } @@ -166,8 +167,8 @@ IN_PROC_BROWSER_TEST_F(BraveSearchTest, CheckForAFunctionDev) { browser()->tab_strip_model()->GetActiveWebContents(); WaitForLoadStop(contents); - auto result_first = - EvalJsWithManualReply(contents, GetChromeFetchBackupResultsAvailScript()); + auto result_first = EvalJs(contents, GetChromeFetchBackupResultsAvailScript(), + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); EXPECT_EQ(base::Value(true), result_first.value); } @@ -178,8 +179,8 @@ IN_PROC_BROWSER_TEST_F(BraveSearchTest, CheckForAnUndefinedFunction) { browser()->tab_strip_model()->GetActiveWebContents(); WaitForLoadStop(contents); - auto result_first = - EvalJsWithManualReply(contents, GetChromeFetchBackupResultsAvailScript()); + auto result_first = EvalJs(contents, GetChromeFetchBackupResultsAvailScript(), + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); EXPECT_EQ(base::Value(false), result_first.value); } diff --git a/browser/brave_shields/ad_block_service_browsertest.cc b/browser/brave_shields/ad_block_service_browsertest.cc index d5325fbfcd4f..094638b36857 100644 --- a/browser/brave_shields/ad_block_service_browsertest.cc +++ b/browser/brave_shields/ad_block_service_browsertest.cc @@ -11,6 +11,7 @@ #include "base/base64.h" #include "base/path_service.h" +#include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "base/test/thread_test_helper.h" #include "brave/browser/brave_browser_process.h" @@ -1228,39 +1229,42 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringSimple) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result_first = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_first = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('#ad-banner', 'display', 'none')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_first.error.empty()); EXPECT_EQ(base::Value(true), result_first.value); - auto result_second = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_second = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.ad-banner', 'display', 'block')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_second.error.empty()); EXPECT_EQ(base::Value(true), result_second.value); - auto result_third = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_third = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.ad', 'display', 'none')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_third.error.empty()); EXPECT_EQ(base::Value(true), result_third.value); } @@ -1299,15 +1303,16 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringHide1pContent) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.fpsponsored', 'display', 'none')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result.error.empty()); EXPECT_EQ(base::Value(true), result.value); } @@ -1325,27 +1330,29 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringDynamic) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result_first = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_first = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.blockme', 'display', 'none')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_first.error.empty()); EXPECT_EQ(base::Value(true), result_first.value); - auto result_second = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_second = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.dontblockme', 'display', 'block')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_second.error.empty()); EXPECT_EQ(base::Value(true), result_second.value); } @@ -1391,15 +1398,16 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringCustomStyle) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.ad', 'padding-bottom', '10px')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result.error.empty()); EXPECT_EQ(base::Value(true), result.value); } @@ -1421,27 +1429,29 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringUnhide) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result_first = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_first = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.ad', 'display', 'block')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_first.error.empty()); EXPECT_EQ(base::Value(true), result_first.value); - auto result_second = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result_second = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('#ad-banner', 'display', 'none')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result_second.error.empty()); EXPECT_EQ(base::Value(true), result_second.value); } @@ -1478,15 +1488,16 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringWindowScriptlet) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result = EvalJsWithManualReply(contents, - R"(function waitCSSSelector() { + auto result = EvalJs(contents, + R"(function waitCSSSelector() { if (checkSelector('.ad', 'color', 'Impossible value')) { window.domAutomationController.send(true); } else { console.log('still waiting for css selector'); setTimeout(waitCSSSelector, 200); } - } waitCSSSelector())"); + } waitCSSSelector())", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result.error.empty()); EXPECT_EQ(base::Value(true), result.value); } diff --git a/browser/brave_shields/brave_shields_web_contents_observer.cc b/browser/brave_shields/brave_shields_web_contents_observer.cc index 3a913ad27c1c..8a167a1b1483 100644 --- a/browser/brave_shields/brave_shields_web_contents_observer.cc +++ b/browser/brave_shields/brave_shields_web_contents_observer.cc @@ -184,12 +184,10 @@ void BraveShieldsWebContentsObserver::DispatchBlockedEventForWebContents( details.tab_id = extensions::ExtensionTabUtil::GetTabId(web_contents); details.block_type = block_type; details.subresource = subresource; - std::unique_ptr args( - extensions::api::brave_shields::OnBlocked::Create(details).release()); std::unique_ptr event( new Event(extensions::events::BRAVE_AD_BLOCKED, extensions::api::brave_shields::OnBlocked::kEventName, - std::move(args))); + extensions::api::brave_shields::OnBlocked::Create(details))); event_router->BroadcastEvent(std::move(event)); } #endif diff --git a/browser/brave_wallet/brave_wallet_event_emitter_browsertest.cc b/browser/brave_wallet/brave_wallet_event_emitter_browsertest.cc index 4c7fa4b2bab8..1261b986cd97 100644 --- a/browser/brave_wallet/brave_wallet_event_emitter_browsertest.cc +++ b/browser/brave_wallet/brave_wallet_event_emitter_browsertest.cc @@ -120,8 +120,9 @@ IN_PROC_BROWSER_TEST_F(BraveWalletEventEmitterTest, CheckForAConnectEvent) { browser()->tab_strip_model()->GetActiveWebContents(); WaitForLoadStop(contents); - auto result_first = EvalJsWithManualReply( - contents, CheckForEventScript("received_connect_event")); + auto result_first = + EvalJs(contents, CheckForEventScript("received_connect_event"), + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); EXPECT_EQ(base::Value(true), result_first.value); } @@ -136,7 +137,8 @@ IN_PROC_BROWSER_TEST_F(BraveWalletEventEmitterTest, auto* controller = GetEthJsonRpcController(); controller->SetNetwork(brave_wallet::Network::kGoerli); - auto result_first = EvalJsWithManualReply( - contents, CheckForEventScript("received_chain_changed_event")); + auto result_first = + EvalJs(contents, CheckForEventScript("received_chain_changed_event"), + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); EXPECT_EQ(base::Value(true), result_first.value); } diff --git a/browser/brave_wallet/brave_wallet_service_factory.cc b/browser/brave_wallet/brave_wallet_service_factory.cc index 21dcb486dd60..cceff200a379 100644 --- a/browser/brave_wallet/brave_wallet_service_factory.cc +++ b/browser/brave_wallet/brave_wallet_service_factory.cc @@ -37,8 +37,7 @@ BraveWalletServiceFactory::~BraveWalletServiceFactory() {} KeyedService* BraveWalletServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { - auto* default_storage_partition = - content::BrowserContext::GetDefaultStoragePartition(context); + auto* default_storage_partition = context->GetDefaultStoragePartition(); auto shared_url_loader_factory = default_storage_partition->GetURLLoaderFactoryForBrowserProcess(); return new BraveWalletService(user_prefs::UserPrefs::Get(context), diff --git a/browser/browsing_data/brave_browsing_data_remover_delegate.cc b/browser/browsing_data/brave_browsing_data_remover_delegate.cc index bc43f30119a1..2fe00b7de00d 100644 --- a/browser/browsing_data/brave_browsing_data_remover_delegate.cc +++ b/browser/browsing_data/brave_browsing_data_remover_delegate.cc @@ -72,12 +72,10 @@ void BraveBrowsingDataRemoverDelegate::RemoveEmbedderData( if (remove_mask & chrome_browsing_data_remover::DATA_TYPE_HISTORY) { auto* event_router = extensions::EventRouter::Get(profile_); if (event_router) { - std::unique_ptr args( - extensions::api::brave_today::OnClearHistory::Create().release()); std::unique_ptr event(new extensions::Event( extensions::events::BRAVE_START, extensions::api::brave_today::OnClearHistory::kEventName, - std::move(args))); + extensions::api::brave_today::OnClearHistory::Create())); event_router->BroadcastEvent(std::move(event)); } } diff --git a/browser/browsing_data/brave_clear_browsing_data.cc b/browser/browsing_data/brave_clear_browsing_data.cc index b3947d9a3c38..1a443e79a6a0 100644 --- a/browser/browsing_data/brave_clear_browsing_data.cc +++ b/browser/browsing_data/brave_clear_browsing_data.cc @@ -135,8 +135,7 @@ void BrowsingDataRemovalWatcher::ClearBrowsingDataForLoadedProfiles( &origin_mask)) continue; ++num_profiles_to_clear_; - content::BrowsingDataRemover* remover = - content::BrowserContext::GetBrowsingDataRemover(profile); + content::BrowsingDataRemover* remover = profile->GetBrowsingDataRemover(); observer_.AddObservation(remover); if (testing_callback) testing_callback->BeforeClearOnExitRemoveData(remover, remove_mask, diff --git a/browser/browsing_data/brave_clear_browsing_data_browsertest.cc b/browser/browsing_data/brave_clear_browsing_data_browsertest.cc index 50631f769479..5bde2d73f511 100644 --- a/browser/browsing_data/brave_clear_browsing_data_browsertest.cc +++ b/browser/browsing_data/brave_clear_browsing_data_browsertest.cc @@ -318,8 +318,8 @@ IN_PROC_BROWSER_TEST_F(BraveClearDataOnExitTwoBrowsersTest, OneOTR) { SetExepectedRemoveDataCallCount(1); // Open a second browser window with OTR profile. - Browser* second_window = - NewBrowserWindow(browser()->profile()->GetPrimaryOTRProfile()); + Browser* second_window = NewBrowserWindow( + browser()->profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true)); // Close second browser window CloseBrowserWindow(second_window); EXPECT_EQ(0, remove_data_call_count()); @@ -335,8 +335,8 @@ IN_PROC_BROWSER_TEST_F(BraveClearDataOnExitTwoBrowsersTest, OneOTRExitsLast) { SetExepectedRemoveDataCallCount(1); // Open a second browser window with OTR profile. - Browser* second_window = - NewBrowserWindow(browser()->profile()->GetPrimaryOTRProfile()); + Browser* second_window = NewBrowserWindow( + browser()->profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true)); // Close regular profile window. CloseBrowserWindow(browser()); diff --git a/browser/decentralized_dns/test/decentralized_dns_navigation_throttle_unittest.cc b/browser/decentralized_dns/test/decentralized_dns_navigation_throttle_unittest.cc index f4a04035e9cc..00e8886aa96c 100644 --- a/browser/decentralized_dns/test/decentralized_dns_navigation_throttle_unittest.cc +++ b/browser/decentralized_dns/test/decentralized_dns_navigation_throttle_unittest.cc @@ -51,7 +51,8 @@ class DecentralizedDnsNavigationThrottleTest : public testing::Test { // Helper that creates simple test guest profile. Profile* CreateGuestProfile() { - return profile_manager_.CreateGuestProfile()->GetPrimaryOTRProfile(); + return profile_manager_.CreateGuestProfile()->GetPrimaryOTRProfile( + /*create_if_needed=*/true); } TestingProfile* profile() { return profile_; } @@ -77,7 +78,7 @@ TEST_F(DecentralizedDnsNavigationThrottleTest, Instantiation) { // Disable in OTR profile. auto otr_web_contents = content::WebContentsTester::CreateTestWebContents( - profile()->GetPrimaryOTRProfile(), nullptr); + profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true), nullptr); content::MockNavigationHandle otr_test_handle(otr_web_contents.get()); auto throttle_in_otr = DecentralizedDnsNavigationThrottle::MaybeCreateThrottleFor( diff --git a/browser/ephemeral_storage/ephemeral_storage_browsertest.cc b/browser/ephemeral_storage/ephemeral_storage_browsertest.cc index c20722c21a28..e5481d7a6263 100644 --- a/browser/ephemeral_storage/ephemeral_storage_browsertest.cc +++ b/browser/ephemeral_storage/ephemeral_storage_browsertest.cc @@ -6,6 +6,7 @@ #include #include "base/path_service.h" +#include "base/strings/stringprintf.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/time/time.h" #include "brave/browser/ephemeral_storage/ephemeral_storage_tab_helper.h" diff --git a/browser/ephemeral_storage/ephemeral_storage_tab_helper.cc b/browser/ephemeral_storage/ephemeral_storage_tab_helper.cc index dba7b89157e2..8d7ed1c920ed 100644 --- a/browser/ephemeral_storage/ephemeral_storage_tab_helper.cc +++ b/browser/ephemeral_storage/ephemeral_storage_tab_helper.cc @@ -18,6 +18,7 @@ #include "content/public/browser/web_contents.h" #include "net/base/features.h" #include "net/base/url_util.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using content::BrowserContext; using content::NavigationHandle; @@ -119,8 +120,7 @@ void EphemeralStorageTabHelper::CreateEphemeralStorageAreasForDomainAndURL( auto* browser_context = web_contents()->GetBrowserContext(); auto site_instance = content::SiteInstance::CreateForURL(browser_context, new_url); - auto* partition = - BrowserContext::GetStoragePartition(browser_context, site_instance.get()); + auto* partition = browser_context->GetStoragePartition(site_instance.get()); if (base::FeatureList::IsEnabled( net::features::kBraveEphemeralStorageKeepAlive) && @@ -150,7 +150,7 @@ void EphemeralStorageTabHelper::CreateEphemeralStorageAreasForDomainAndURL( std::string local_partition_id = StringToSessionStorageId(new_domain, kLocalStorageSuffix); local_storage_namespace_ = content::CreateSessionStorageNamespace( - partition, local_partition_id, base::nullopt); + partition, local_partition_id, absl::nullopt); // Session storage is always per-tab and never per-TLD, so we always delete // and recreate the session storage when switching domains. @@ -169,11 +169,11 @@ void EphemeralStorageTabHelper::CreateEphemeralStorageAreasForDomainAndURL( partition, session_partition_id, // clone the namespace if there is an opener // https://html.spec.whatwg.org/multipage/browsers.html#copy-session-storage - rfh ? base::make_optional(StringToSessionStorageId( + rfh ? absl::make_optional(StringToSessionStorageId( content::GetSessionStorageNamespaceId( WebContents::FromRenderFrameHost(rfh)), kSessionStorageSuffix)) - : base::nullopt); + : absl::nullopt); tld_ephemeral_lifetime_ = content::TLDEphemeralLifetime::GetOrCreate( browser_context, partition, new_domain); diff --git a/browser/ethereum_remote_client/ethereum_remote_client_service.cc b/browser/ethereum_remote_client/ethereum_remote_client_service.cc index 60c9eb151fbb..55333e8d01e5 100644 --- a/browser/ethereum_remote_client/ethereum_remote_client_service.cc +++ b/browser/ethereum_remote_client/ethereum_remote_client_service.cc @@ -54,8 +54,8 @@ EthereumRemoteClientService::EthereumRemoteClientService( pref_change_registrar_->Init(user_prefs::UserPrefs::Get(context_)); pref_change_registrar_->Add( kBraveWalletWeb3Provider, - base::Bind(&EthereumRemoteClientService::OnPreferenceChanged, - base::Unretained(this))); + base::BindRepeating(&EthereumRemoteClientService::OnPreferenceChanged, + base::Unretained(this))); // In case any web3 providers have already loaded content scripts at // this point. RemoveUnusedWeb3ProviderContentScripts(); diff --git a/browser/extensions/BUILD.gn b/browser/extensions/BUILD.gn index 1f3154cd781c..858489a6d9b6 100644 --- a/browser/extensions/BUILD.gn +++ b/browser/extensions/BUILD.gn @@ -112,6 +112,8 @@ source_set("extensions") { deps += [ "//brave/browser/ethereum_remote_client", "//brave/components/brave_wallet/browser", + "//components/infobars/content", + "//components/prefs", ] } diff --git a/browser/extensions/api/binance_api.cc b/browser/extensions/api/binance_api.cc index 63629fadace4..c3768d72ecea 100644 --- a/browser/extensions/api/binance_api.cc +++ b/browser/extensions/api/binance_api.cc @@ -18,7 +18,6 @@ #include "brave/components/binance/browser/binance_service.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "components/prefs/pref_service.h" #include "extensions/browser/extension_util.h" diff --git a/browser/extensions/api/brave_rewards_api.cc b/browser/extensions/api/brave_rewards_api.cc index 3baf147c87b4..defb31576307 100644 --- a/browser/extensions/api/brave_rewards_api.cc +++ b/browser/extensions/api/brave_rewards_api.cc @@ -489,7 +489,7 @@ void BraveRewardsGetRewardsParametersFunction::OnGet( auto ac_choices = std::make_unique(); for (double const& choice : parameters->auto_contribute_choices) { - ac_choices->AppendDouble(choice); + ac_choices->Append(choice); } data.SetList("autoContributeChoices", std::move(ac_choices)); diff --git a/browser/extensions/api/brave_shields_api.cc b/browser/extensions/api/brave_shields_api.cc index 81fe20918135..c2979f5687fc 100644 --- a/browser/extensions/api/brave_shields_api.cc +++ b/browser/extensions/api/brave_shields_api.cc @@ -68,7 +68,7 @@ BraveShieldsUrlCosmeticResourcesFunction::Run() { std::unique_ptr BraveShieldsUrlCosmeticResourcesFunction::GetUrlCosmeticResourcesOnTaskRunner( const std::string& url) { - base::Optional resources = + absl::optional resources = g_brave_browser_process->ad_block_service()->UrlCosmeticResources(url); if (!resources || !resources->is_dict()) { @@ -113,7 +113,7 @@ std::unique_ptr BraveShieldsHiddenClassIdSelectorsFunction:: const std::vector& classes, const std::vector& ids, const std::vector& exceptions) { - base::Optional hide_selectors = + absl::optional hide_selectors = g_brave_browser_process->ad_block_service()->HiddenClassIdSelectors( classes, ids, exceptions); diff --git a/browser/extensions/api/brave_wallet_api.cc b/browser/extensions/api/brave_wallet_api.cc index 0c21d08de627..1fc240f60410 100644 --- a/browser/extensions/api/brave_wallet_api.cc +++ b/browser/extensions/api/brave_wallet_api.cc @@ -23,8 +23,8 @@ #include "brave/grit/brave_generated_resources.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/prefs/pref_service.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/extension_registry.h" @@ -77,9 +77,9 @@ BraveWalletPromptToEnableWalletFunction::Run() { base::NumberToString(params->tab_id))); } - InfoBarService* infobar_service = - InfoBarService::FromWebContents(contents); - if (infobar_service) { + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(contents); + if (infobar_manager) { CryptoWalletsInfoBarDelegate::InfobarSubType subtype = CryptoWalletsInfoBarDelegate::InfobarSubType::GENERIC_SETUP; auto* service = GetEthereumRemoteClientService(browser_context()); @@ -87,7 +87,7 @@ BraveWalletPromptToEnableWalletFunction::Run() { subtype = CryptoWalletsInfoBarDelegate::InfobarSubType:: LOAD_CRYPTO_WALLETS; } - CryptoWalletsInfoBarDelegate::Create(infobar_service, subtype); + CryptoWalletsInfoBarDelegate::Create(infobar_manager, subtype); } return RespondNow(NoArguments()); diff --git a/browser/extensions/api/brave_wallet_api_browsertest.cc b/browser/extensions/api/brave_wallet_api_browsertest.cc index 4e9770047799..787bca32ccad 100644 --- a/browser/extensions/api/brave_wallet_api_browsertest.cc +++ b/browser/extensions/api/brave_wallet_api_browsertest.cc @@ -12,11 +12,11 @@ #include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/pref_names.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_test.h" @@ -102,13 +102,13 @@ class BraveWalletAPIBrowserTest : public InProcessBrowserTest, ~BraveWalletAPIBrowserTest() override { } - void AddInfoBarObserver(InfoBarService* infobar_service) { + void AddInfoBarObserver(infobars::ContentInfoBarManager* infobar_manager) { DCHECK(!infobar_observer_.IsObserving()); - infobar_observer_.Observe(infobar_service); + infobar_observer_.Observe(infobar_manager); } - void RemoveInfoBarObserver(InfoBarService* infobar_service) { - DCHECK(infobar_observer_.IsObservingSource(infobar_service)); + void RemoveInfoBarObserver(infobars::ContentInfoBarManager* infobar_manager) { + DCHECK(infobar_observer_.IsObservingSource(infobar_manager)); infobar_observer_.Reset(); } @@ -117,11 +117,10 @@ class BraveWalletAPIBrowserTest : public InProcessBrowserTest, } void CryptoWalletsInfoBarAccept(int expected_buttons) { - InfoBarService* infobar_service = - InfoBarService::FromWebContents(active_contents()); - for (size_t i = 0; i < infobar_service->infobar_count(); i++) { - InfoBarDelegate* delegate = - infobar_service->infobar_at(i)->delegate(); + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(active_contents()); + for (size_t i = 0; i < infobar_manager->infobar_count(); i++) { + InfoBarDelegate* delegate = infobar_manager->infobar_at(i)->delegate(); if (delegate->GetIdentifier() == InfoBarDelegate::CRYPTO_WALLETS_INFOBAR_DELEGATE) { ConfirmInfoBarDelegate* confirm_delegate = @@ -134,11 +133,10 @@ class BraveWalletAPIBrowserTest : public InProcessBrowserTest, } void CryptoWalletsInfoBarCancel(int expected_buttons) { - InfoBarService* infobar_service = - InfoBarService::FromWebContents(active_contents()); - for (size_t i = 0; i < infobar_service->infobar_count(); i++) { - InfoBarDelegate* delegate = - infobar_service->infobar_at(i)->delegate(); + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(active_contents()); + for (size_t i = 0; i < infobar_manager->infobar_count(); i++) { + InfoBarDelegate* delegate = infobar_manager->infobar_at(i)->delegate(); if (delegate->GetIdentifier() == InfoBarDelegate::CRYPTO_WALLETS_INFOBAR_DELEGATE) { ConfirmInfoBarDelegate* confirm_delegate = @@ -183,9 +181,9 @@ IN_PROC_BROWSER_TEST_F(BraveWalletAPIBrowserTest, DappDetectionTestAccept) { static_cast(brave_wallet::Web3ProviderTypes::ASK)); } WaitForBraveExtensionAdded(); - InfoBarService* infobar_service = - InfoBarService::FromWebContents(active_contents()); - AddInfoBarObserver(infobar_service); + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(active_contents()); + AddInfoBarObserver(infobar_manager); EXPECT_TRUE( NavigateToURLUntilLoadStop("a.com", "/dapp.html")); WaitForCryptoWalletsInfobarAdded(); @@ -197,7 +195,7 @@ IN_PROC_BROWSER_TEST_F(BraveWalletAPIBrowserTest, DappDetectionTestAccept) { ConfirmInfoBarDelegate::BUTTON_OK | ConfirmInfoBarDelegate::BUTTON_CANCEL); WaitForTabCount(2); - RemoveInfoBarObserver(infobar_service); + RemoveInfoBarObserver(infobar_manager); } IN_PROC_BROWSER_TEST_F(BraveWalletAPIBrowserTest, InfoBarDontAsk) { @@ -208,9 +206,9 @@ IN_PROC_BROWSER_TEST_F(BraveWalletAPIBrowserTest, InfoBarDontAsk) { } // Navigate to dapp WaitForBraveExtensionAdded(); - InfoBarService* infobar_service = - InfoBarService::FromWebContents(active_contents()); - AddInfoBarObserver(infobar_service); + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(active_contents()); + AddInfoBarObserver(infobar_manager); EXPECT_TRUE( NavigateToURLUntilLoadStop("a.com", "/dapp.html")); WaitForCryptoWalletsInfobarAdded(); @@ -226,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(BraveWalletAPIBrowserTest, InfoBarDontAsk) { auto provider_after = static_cast( browser()->profile()->GetPrefs()->GetInteger(kBraveWalletWeb3Provider)); ASSERT_EQ(provider_after, brave_wallet::Web3ProviderTypes::NONE); - RemoveInfoBarObserver(infobar_service); + RemoveInfoBarObserver(infobar_manager); } IN_PROC_BROWSER_TEST_F(BraveWalletAPIBrowserTest, diff --git a/browser/extensions/api/crypto_dot_com_api.cc b/browser/extensions/api/crypto_dot_com_api.cc index 56b72f65b46a..d61392cb0fda 100644 --- a/browser/extensions/api/crypto_dot_com_api.cc +++ b/browser/extensions/api/crypto_dot_com_api.cc @@ -18,7 +18,6 @@ #include "brave/components/ntp_widget_utils/browser/ntp_widget_utils_region.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "components/prefs/pref_service.h" #include "extensions/browser/extension_util.h" diff --git a/browser/extensions/api/gemini_api.cc b/browser/extensions/api/gemini_api.cc index 884e59acf082..9e721fc72d3f 100644 --- a/browser/extensions/api/gemini_api.cc +++ b/browser/extensions/api/gemini_api.cc @@ -17,7 +17,6 @@ #include "brave/components/gemini/browser/regions.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "extensions/browser/extension_util.h" #include "extensions/common/constants.h" diff --git a/browser/extensions/updater/brave_update_client_config.cc b/browser/extensions/updater/brave_update_client_config.cc index feda97d07f1f..698cd44c7cda 100644 --- a/browser/extensions/updater/brave_update_client_config.cc +++ b/browser/extensions/updater/brave_update_client_config.cc @@ -39,7 +39,7 @@ BraveUpdateClientConfig::GetNetworkFetcherFactory() { if (!network_fetcher_factory_) { network_fetcher_factory_ = base::MakeRefCounted( - content::BrowserContext::GetDefaultStoragePartition(context_) + context_->GetDefaultStoragePartition() ->GetURLLoaderFactoryForBrowserProcess(), // Unlike ChromeUpdateClientConfig, which allows to send cookies for // chrome.google.com, we won't be sending any cookies. @@ -58,7 +58,7 @@ BraveUpdateClientConfig::~BraveUpdateClientConfig() = default; // static scoped_refptr BraveUpdateClientConfig::Create( content::BrowserContext* context, - base::Optional update_url_override) { + absl::optional update_url_override) { FactoryCallback& factory = GetFactoryCallback(); return factory.is_null() ? base::MakeRefCounted( context, update_url_override) diff --git a/browser/extensions/updater/brave_update_client_config.h b/browser/extensions/updater/brave_update_client_config.h index ce9f6457beaf..194aa91ddffd 100644 --- a/browser/extensions/updater/brave_update_client_config.h +++ b/browser/extensions/updater/brave_update_client_config.h @@ -11,8 +11,8 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h" -#include "base/optional.h" #include "chrome/browser/extensions/updater/chrome_update_client_config.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -32,7 +32,7 @@ class BraveUpdateClientConfig : public ChromeUpdateClientConfig { public: static scoped_refptr Create( content::BrowserContext* context, - base::Optional url_override); + absl::optional url_override); using ChromeUpdateClientConfig::ChromeUpdateClientConfig; diff --git a/browser/farbling/brave_dark_mode_fingerprint_protection_browsertest.cc b/browser/farbling/brave_dark_mode_fingerprint_protection_browsertest.cc index b7b4edf570da..07afbdb83e76 100644 --- a/browser/farbling/brave_dark_mode_fingerprint_protection_browsertest.cc +++ b/browser/farbling/brave_dark_mode_fingerprint_protection_browsertest.cc @@ -113,17 +113,17 @@ IN_PROC_BROWSER_TEST_F(BraveDarkModeFingerprintProtection, DarkModeCheck) { NavigateToURLUntilLoadStop(dark_mode_url()); std::u16string tab_title; ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); - EXPECT_EQ(base::ASCIIToUTF16("dark"), tab_title); + EXPECT_EQ(u"dark", tab_title); // On fingerprinting default, should return dark mode SetFingerprintingDefault(); NavigateToURLUntilLoadStop(dark_mode_url()); ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); - EXPECT_EQ(base::ASCIIToUTF16("dark"), tab_title); + EXPECT_EQ(u"dark", tab_title); // On fingerprinting block, should return light BlockFingerprinting(); NavigateToURLUntilLoadStop(dark_mode_url()); ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); - EXPECT_EQ(base::ASCIIToUTF16("light"), tab_title); + EXPECT_EQ(u"light", tab_title); } IN_PROC_BROWSER_TEST_F(BraveDarkModeFingerprintProtection, RegressionCheck) { @@ -134,17 +134,17 @@ IN_PROC_BROWSER_TEST_F(BraveDarkModeFingerprintProtection, RegressionCheck) { NavigateToURLUntilLoadStop(dark_mode_url()); std::u16string tab_title; ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); - EXPECT_EQ(base::ASCIIToUTF16("light"), tab_title); + EXPECT_EQ(u"light", tab_title); // Fingerprinting default SetFingerprintingDefault(); NavigateToURLUntilLoadStop(dark_mode_url()); ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); - EXPECT_EQ(base::ASCIIToUTF16("light"), tab_title); + EXPECT_EQ(u"light", tab_title); // Fingerprinting strict/block BlockFingerprinting(); NavigateToURLUntilLoadStop(dark_mode_url()); ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); - EXPECT_EQ(base::ASCIIToUTF16("light"), tab_title); + EXPECT_EQ(u"light", tab_title); } IN_PROC_BROWSER_TEST_F(BraveDarkModeFingerprintProtection, SettingsPagesCheck) { diff --git a/browser/ftx/ftx_protocol_handler.cc b/browser/ftx/ftx_protocol_handler.cc index f877f21749ea..ab0b88b8d2d2 100644 --- a/browser/ftx/ftx_protocol_handler.cc +++ b/browser/ftx/ftx_protocol_handler.cc @@ -28,7 +28,7 @@ void LoadNewTabURL(const GURL& url, content::WebContents::OnceGetter web_contents_getter, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiating_origin) { + const absl::optional& initiating_origin) { content::WebContents* web_contents = std::move(web_contents_getter).Run(); if (!web_contents) { return; @@ -87,7 +87,7 @@ void HandleFTXProtocol(const GURL& url, content::WebContents::OnceGetter web_contents_getter, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiator) { + const absl::optional& initiator) { DCHECK(IsFTXProtocol(url)); base::PostTask( FROM_HERE, {content::BrowserThread::UI}, diff --git a/browser/ftx/ftx_protocol_handler.h b/browser/ftx/ftx_protocol_handler.h index ca52a25bcfe7..c5f67caa08e1 100644 --- a/browser/ftx/ftx_protocol_handler.h +++ b/browser/ftx/ftx_protocol_handler.h @@ -8,8 +8,8 @@ #include -#include "base/optional.h" #include "content/public/browser/web_contents.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -19,7 +19,7 @@ void HandleFTXProtocol(const GURL& url, content::WebContents::OnceGetter web_contents_getter, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiator); + const absl::optional& initiator); bool IsFTXProtocol(const GURL& url); diff --git a/browser/gemini/gemini_protocol_handler.cc b/browser/gemini/gemini_protocol_handler.cc index e8c6c9c666c1..23287633a0c2 100644 --- a/browser/gemini/gemini_protocol_handler.cc +++ b/browser/gemini/gemini_protocol_handler.cc @@ -9,7 +9,6 @@ #include #include -#include "base/optional.h" #include "base/strings/strcat.h" #include "base/strings/string_util.h" #include "base/task/post_task.h" @@ -23,17 +22,17 @@ #include "content/public/browser/web_contents.h" #include "net/base/escape.h" #include "net/base/url_util.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/page_transition_types.h" #include "url/gurl.h" namespace { -void LoadNewTabURL( - const GURL& url, - content::WebContents::OnceGetter web_contents_getter, - ui::PageTransition page_transition, - bool has_user_gesture, - const base::Optional& initiating_origin) { +void LoadNewTabURL(const GURL& url, + content::WebContents::OnceGetter web_contents_getter, + ui::PageTransition page_transition, + bool has_user_gesture, + const absl::optional& initiating_origin) { content::WebContents* web_contents = std::move(web_contents_getter).Run(); if (!web_contents) { return; @@ -73,10 +72,10 @@ void LoadNewTabURL( namespace gemini { void HandleGeminiProtocol(const GURL& url, - content::WebContents::OnceGetter web_contents_getter, - ui::PageTransition page_transition, - bool has_user_gesture, - const base::Optional& initiator) { + content::WebContents::OnceGetter web_contents_getter, + ui::PageTransition page_transition, + bool has_user_gesture, + const absl::optional& initiator) { DCHECK(IsGeminiProtocol(url)); base::PostTask( FROM_HERE, {content::BrowserThread::UI}, diff --git a/browser/gemini/gemini_protocol_handler.h b/browser/gemini/gemini_protocol_handler.h index 2349fcf2e4ec..77718159d1fc 100644 --- a/browser/gemini/gemini_protocol_handler.h +++ b/browser/gemini/gemini_protocol_handler.h @@ -8,8 +8,8 @@ #include -#include "base/optional.h" #include "content/public/browser/web_contents.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/page_transition_types.h" #include "url/gurl.h" @@ -19,7 +19,7 @@ void HandleGeminiProtocol(const GURL& url, content::WebContents::OnceGetter web_contents_getter, ui::PageTransition page_transition, bool has_user_gesture, - const base::Optional& initiator); + const absl::optional& initiator); bool IsGeminiProtocol(const GURL& url); diff --git a/browser/importer/brave_external_process_importer_host.cc b/browser/importer/brave_external_process_importer_host.cc index 2f47688a31ea..1d5a3e2643ce 100644 --- a/browser/importer/brave_external_process_importer_host.cc +++ b/browser/importer/brave_external_process_importer_host.cc @@ -25,20 +25,20 @@ namespace { #if BUILDFLAG(ENABLE_EXTENSIONS) -base::Optional GetChromeExtensionsList( +absl::optional GetChromeExtensionsList( const base::FilePath& secured_preference_path) { if (!base::PathExists(secured_preference_path)) - return base::nullopt; + return absl::nullopt; std::string secured_preference_content; base::ReadFileToString(secured_preference_path, &secured_preference_content); - base::Optional secured_preference = + absl::optional secured_preference = base::JSONReader::Read(secured_preference_content); if (auto* extensions = secured_preference->FindPath( kChromeExtensionsListPath)) { return extensions->Clone(); } - return base::nullopt; + return absl::nullopt; } // Silent installer via websotre w/o any prompt or bubble. @@ -83,7 +83,7 @@ void BraveExternalProcessImporterHost::LaunchExtensionsImport() { } void BraveExternalProcessImporterHost::OnGetChromeExtensionsList( - base::Optional extensions_list) { + absl::optional extensions_list) { if (!extensions_list || !extensions_list->is_dict()) { ExternalProcessImporterHost::NotifyImportEnded(); return; diff --git a/browser/importer/brave_external_process_importer_host.h b/browser/importer/brave_external_process_importer_host.h index a3bca80128ae..6165bf0d7d8e 100644 --- a/browser/importer/brave_external_process_importer_host.h +++ b/browser/importer/brave_external_process_importer_host.h @@ -7,10 +7,10 @@ #define BRAVE_BROWSER_IMPORTER_BRAVE_EXTERNAL_PROCESS_IMPORTER_HOST_H_ #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/values.h" #include "chrome/browser/importer/external_process_importer_host.h" #include "extensions/buildflags/buildflags.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class BraveExternalProcessImporterHost : public ExternalProcessImporterHost { public: @@ -26,7 +26,7 @@ class BraveExternalProcessImporterHost : public ExternalProcessImporterHost { #if BUILDFLAG(ENABLE_EXTENSIONS) void LaunchExtensionsImport(); - void OnGetChromeExtensionsList(base::Optional extensions_list); + void OnGetChromeExtensionsList(absl::optional extensions_list); #endif // Vends weak pointers for the importer to call us back. diff --git a/browser/infobars/BUILD.gn b/browser/infobars/BUILD.gn index bf645aaa9a8e..7afab0d34ae6 100644 --- a/browser/infobars/BUILD.gn +++ b/browser/infobars/BUILD.gn @@ -19,6 +19,7 @@ source_set("infobars") { "//brave/components/p3a", "//chrome/app:chromium_strings", "//chrome/browser/ui", + "//components/infobars/content", "//components/infobars/core", "//components/prefs", "//components/strings", diff --git a/browser/infobars/brave_confirm_p3a_infobar_delegate.cc b/browser/infobars/brave_confirm_p3a_infobar_delegate.cc index 20171ca33efb..c791fd6408b0 100644 --- a/browser/infobars/brave_confirm_p3a_infobar_delegate.cc +++ b/browser/infobars/brave_confirm_p3a_infobar_delegate.cc @@ -12,8 +12,9 @@ #include "brave/common/url_constants.h" #include "brave/components/p3a/pref_names.h" #include "brave/grit/brave_generated_resources.h" -#include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/infobars/confirm_infobar_creator.h" #include "chrome/grit/chromium_strings.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" #include "components/prefs/pref_service.h" #include "components/strings/grit/components_strings.h" @@ -21,8 +22,9 @@ #include "ui/views/vector_icons.h" // static -void BraveConfirmP3AInfoBarDelegate::Create(InfoBarService* infobar_service, - PrefService* local_state) { +void BraveConfirmP3AInfoBarDelegate::Create( + infobars::ContentInfoBarManager* infobar_manager, + PrefService* local_state) { // Don't show infobar if: // - P3A is disabled // - notice has already been acknowledged @@ -34,8 +36,8 @@ void BraveConfirmP3AInfoBarDelegate::Create(InfoBarService* infobar_service, } } - infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( - std::unique_ptr( + infobar_manager->AddInfoBar( + CreateConfirmInfoBar(std::unique_ptr( new BraveConfirmP3AInfoBarDelegate(local_state)))); } diff --git a/browser/infobars/brave_confirm_p3a_infobar_delegate.h b/browser/infobars/brave_confirm_p3a_infobar_delegate.h index 9b26574fa4b4..874113e15f7e 100644 --- a/browser/infobars/brave_confirm_p3a_infobar_delegate.h +++ b/browser/infobars/brave_confirm_p3a_infobar_delegate.h @@ -11,13 +11,17 @@ #include "components/infobars/core/confirm_infobar_delegate.h" #include "url/gurl.h" -class InfoBarService; class PrefService; +namespace infobars { +class ContentInfoBarManager; +} // namespace infobars + // An infobar that is run with a string, buttons, and a "Learn More" link. class BraveConfirmP3AInfoBarDelegate : public ConfirmInfoBarDelegate { public: - static void Create(InfoBarService* infobar_service, PrefService* local_state); + static void Create(infobars::ContentInfoBarManager* infobar_manager, + PrefService* local_state); private: explicit BraveConfirmP3AInfoBarDelegate(PrefService* local_state); diff --git a/browser/infobars/brave_wayback_machine_delegate_impl.cc b/browser/infobars/brave_wayback_machine_delegate_impl.cc index 2614a3411ade..554eac9e30c0 100644 --- a/browser/infobars/brave_wayback_machine_delegate_impl.cc +++ b/browser/infobars/brave_wayback_machine_delegate_impl.cc @@ -9,8 +9,8 @@ #include "brave/common/brave_switches.h" #include "brave/components/brave_wayback_machine/brave_wayback_machine_infobar_delegate.h" #include "brave/components/brave_wayback_machine/brave_wayback_machine_tab_helper.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" -#include "chrome/browser/infobars/infobar_service.h" // static void BraveWaybackMachineDelegateImpl::AttachTabHelperIfNeeded( @@ -31,9 +31,9 @@ BraveWaybackMachineDelegateImpl::~BraveWaybackMachineDelegateImpl() = default; void BraveWaybackMachineDelegateImpl::CreateInfoBar( content::WebContents* web_contents) { - InfoBarService::FromWebContents(web_contents)->AddInfoBar( - CreateInfoBarView( - std::make_unique(), - web_contents), - true); + infobars::ContentInfoBarManager::FromWebContents(web_contents) + ->AddInfoBar(CreateInfoBarView( + std::make_unique(), + web_contents), + true); } diff --git a/browser/infobars/crypto_wallets_infobar_delegate.cc b/browser/infobars/crypto_wallets_infobar_delegate.cc index 02811acc979e..dc339820b307 100644 --- a/browser/infobars/crypto_wallets_infobar_delegate.cc +++ b/browser/infobars/crypto_wallets_infobar_delegate.cc @@ -16,9 +16,10 @@ #include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/pref_names.h" #include "brave/grit/brave_generated_resources.h" -#include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/infobars/confirm_infobar_creator.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/grit/chromium_strings.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" #include "components/prefs/pref_service.h" #include "components/strings/grit/components_strings.h" @@ -29,10 +30,11 @@ #include "ui/views/vector_icons.h" // static -void CryptoWalletsInfoBarDelegate::Create(InfoBarService* infobar_service, +void CryptoWalletsInfoBarDelegate::Create( + infobars::ContentInfoBarManager* infobar_manager, CryptoWalletsInfoBarDelegate::InfobarSubType subtype) { - infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( - std::unique_ptr( + infobar_manager->AddInfoBar( + CreateConfirmInfoBar(std::unique_ptr( new CryptoWalletsInfoBarDelegate(subtype)))); } @@ -95,7 +97,7 @@ GURL CryptoWalletsInfoBarDelegate::GetLinkURL() const { bool CryptoWalletsInfoBarDelegate::Accept() { if (subtype_ == InfobarSubType::LOAD_CRYPTO_WALLETS) { content::WebContents* web_contents = - InfoBarService::WebContentsFromInfoBar(infobar()); + infobars::ContentInfoBarManager::WebContentsFromInfoBar(infobar()); if (web_contents) { auto* browser_context = web_contents->GetBrowserContext(); auto* service = @@ -108,7 +110,7 @@ bool CryptoWalletsInfoBarDelegate::Accept() { } if (infobar() && infobar()->owner()) { content::WebContents* web_contents = - InfoBarService::WebContentsFromInfoBar(infobar()); + infobars::ContentInfoBarManager::WebContentsFromInfoBar(infobar()); if (web_contents) { auto* browser_context = web_contents->GetBrowserContext(); user_prefs::UserPrefs::Get(browser_context) @@ -124,7 +126,7 @@ bool CryptoWalletsInfoBarDelegate::Accept() { bool CryptoWalletsInfoBarDelegate::Cancel() { content::WebContents* web_contents = - InfoBarService::WebContentsFromInfoBar(infobar()); + infobars::ContentInfoBarManager::WebContentsFromInfoBar(infobar()); if (web_contents) { if (subtype_ == InfobarSubType::GENERIC_SETUP) { auto* browser_context = web_contents->GetBrowserContext(); diff --git a/browser/infobars/crypto_wallets_infobar_delegate.h b/browser/infobars/crypto_wallets_infobar_delegate.h index 2c2239dd848f..d0c211558850 100644 --- a/browser/infobars/crypto_wallets_infobar_delegate.h +++ b/browser/infobars/crypto_wallets_infobar_delegate.h @@ -11,18 +11,22 @@ #include "components/infobars/core/confirm_infobar_delegate.h" #include "url/gurl.h" -class InfoBarService; class PrefService; namespace content { class WebContents; -} +} // namespace content + +namespace infobars { +class ContentInfoBarManager; +} // namespace infobars // An infobar that is run with a string, buttons, and a "Learn More" link. class CryptoWalletsInfoBarDelegate : public ConfirmInfoBarDelegate { public: enum class InfobarSubType { LOAD_CRYPTO_WALLETS, GENERIC_SETUP }; - static void Create(InfoBarService* infobar_service, InfobarSubType subtype); + static void Create(infobars::ContentInfoBarManager* infobar_manager, + InfobarSubType subtype); private: explicit CryptoWalletsInfoBarDelegate(InfobarSubType subtype); diff --git a/browser/infobars/sync_v2_migrate_infobar_delegate.cc b/browser/infobars/sync_v2_migrate_infobar_delegate.cc index 07fea6ecf8ce..ba27e5099687 100644 --- a/browser/infobars/sync_v2_migrate_infobar_delegate.cc +++ b/browser/infobars/sync_v2_migrate_infobar_delegate.cc @@ -15,11 +15,12 @@ #include "brave/components/brave_sync/brave_sync_prefs.h" #include "brave/components/brave_sync/features.h" #include "brave/grit/brave_generated_resources.h" -#include "chrome/browser/infobars/infobar_service.h" +#include "chrome/browser/infobars/confirm_infobar_creator.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/grit/chromium_strings.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" #include "components/prefs/pref_service.h" #include "components/strings/grit/components_strings.h" @@ -28,7 +29,9 @@ // static void SyncV2MigrateInfoBarDelegate::Create( - InfoBarService* infobar_service, bool is_v2_user, Profile* profile, + infobars::ContentInfoBarManager* infobar_manager, + bool is_v2_user, + Profile* profile, Browser* browser) { // Show infobar if user had enabled sync v1 (even if they hadn't // re-enabled it via the flag). @@ -60,8 +63,8 @@ void SyncV2MigrateInfoBarDelegate::Create( return; } // Show infobar - infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( - std::unique_ptr( + infobar_manager->AddInfoBar( + CreateConfirmInfoBar(std::unique_ptr( new SyncV2MigrateInfoBarDelegate(browser, profile)))); } diff --git a/browser/infobars/sync_v2_migrate_infobar_delegate.h b/browser/infobars/sync_v2_migrate_infobar_delegate.h index 41e22249b5ff..c7f6203937e8 100644 --- a/browser/infobars/sync_v2_migrate_infobar_delegate.h +++ b/browser/infobars/sync_v2_migrate_infobar_delegate.h @@ -12,7 +12,6 @@ #include "url/gurl.h" class Browser; -class InfoBarService; class Profile; class PrefService; @@ -20,11 +19,17 @@ namespace brave_sync { class Prefs; } // namespace brave_sync +namespace infobars { +class ContentInfoBarManager; +} // namespace infobars + // An infobar that is run with a string, buttons, and a "Learn More" link. class SyncV2MigrateInfoBarDelegate : public ConfirmInfoBarDelegate { public: - static void Create(InfoBarService* infobar_service, bool is_v2_user, - Profile* profile, Browser* browser); + static void Create(infobars::ContentInfoBarManager* infobar_manager, + bool is_v2_user, + Profile* profile, + Browser* browser); private: explicit SyncV2MigrateInfoBarDelegate(Browser* browser, Profile* profile); diff --git a/browser/ipfs/content_browser_client_helper.h b/browser/ipfs/content_browser_client_helper.h index 2b1f677f5ea5..a34699cbeb0f 100644 --- a/browser/ipfs/content_browser_client_helper.h +++ b/browser/ipfs/content_browser_client_helper.h @@ -6,8 +6,8 @@ #ifndef BRAVE_BROWSER_IPFS_CONTENT_BROWSER_CLIENT_HELPER_H_ #define BRAVE_BROWSER_IPFS_CONTENT_BROWSER_CLIENT_HELPER_H_ -#include "base/optional.h" #include "content/public/browser/web_contents.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -29,12 +29,11 @@ bool HandleIPFSURLReverseRewrite( GURL* url, content::BrowserContext* browser_context); -void LoadOrLaunchIPFSURL( - const GURL& url, - content::WebContents::OnceGetter web_contents_getter, - ui::PageTransition page_transition, - bool has_user_gesture, - const base::Optional& initiating_origin); +void LoadOrLaunchIPFSURL(const GURL& url, + content::WebContents::OnceGetter web_contents_getter, + ui::PageTransition page_transition, + bool has_user_gesture, + const absl::optional& initiating_origin); bool HandleIPFSURLRewrite(GURL* url, content::BrowserContext* browser_context); diff --git a/browser/ipfs/import/ipfs_import_controller.cc b/browser/ipfs/import/ipfs_import_controller.cc index 4db11895ae22..9c2ff96daff4 100644 --- a/browser/ipfs/import/ipfs_import_controller.cc +++ b/browser/ipfs/import/ipfs_import_controller.cc @@ -113,7 +113,7 @@ std::unique_ptr CreateMessageCenterNotification( message_center::RichNotificationData notification_data; // hack to prevent origin from showing in the notification // since we're using that to get the notification_id to OpenSettings - notification_data.context_message = base::ASCIIToUTF16(" "); + notification_data.context_message = u" "; auto notification = std::make_unique( message_center::NOTIFICATION_TYPE_SIMPLE, uuid, title, body, gfx::Image(), std::u16string(), link, @@ -187,8 +187,8 @@ void IpfsImportController::SaveWebPage(const base::FilePath& directory) { saved_main_directory_path = saved_main_directory_path.Append( saved_main_file_path.RemoveExtension().BaseName().value() + FILE_PATH_LITERAL("_files")); - auto* download_manager = content::BrowserContext::GetDownloadManager( - web_contents_->GetBrowserContext()); + auto* download_manager = + web_contents_->GetBrowserContext()->GetDownloadManager(); save_package_observer_.reset(new SavePackageFinishedObserver( download_manager, saved_main_file_path, base::BindOnce(&IpfsImportController::OnDownloadFinished, diff --git a/browser/ipfs/import/save_package_observer_browsertest.cc b/browser/ipfs/import/save_package_observer_browsertest.cc index 97f267347a25..c3c8a124d33c 100644 --- a/browser/ipfs/import/save_package_observer_browsertest.cc +++ b/browser/ipfs/import/save_package_observer_browsertest.cc @@ -64,8 +64,8 @@ IN_PROC_BROWSER_TEST_F(SavePackageFinishedObserverBrowserTest, Success) { GURL url = embedded_test_server()->GetURL("/save_page/brave-text-content.html"); ui_test_utils::NavigateToURL(browser(), url); - auto* download_manager = content::BrowserContext::GetDownloadManager( - web_contents()->GetBrowserContext()); + auto* download_manager = + web_contents()->GetBrowserContext()->GetDownloadManager(); { base::RunLoop run_loop; auto completed_callback = base::BindOnce( diff --git a/browser/ipfs/ipfs_blob_context_getter_factory.cc b/browser/ipfs/ipfs_blob_context_getter_factory.cc index 54a368af3131..97e67ea76028 100644 --- a/browser/ipfs/ipfs_blob_context_getter_factory.cc +++ b/browser/ipfs/ipfs_blob_context_getter_factory.cc @@ -16,8 +16,7 @@ namespace ipfs { IpfsBlobContextGetterFactory::IpfsBlobContextGetterFactory( content::BrowserContext* browser_context) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - getter_callback_ = - content::BrowserContext::GetBlobStorageContext(browser_context); + getter_callback_ = browser_context->GetBlobStorageContext(); DCHECK(getter_callback_); } diff --git a/browser/ipfs/ipfs_host_resolver.cc b/browser/ipfs/ipfs_host_resolver.cc index 99311557be96..0c34d1db1afd 100644 --- a/browser/ipfs/ipfs_host_resolver.cc +++ b/browser/ipfs/ipfs_host_resolver.cc @@ -14,6 +14,7 @@ #include "mojo/public/cpp/bindings/receiver.h" #include "net/base/host_port_pair.h" #include "net/dns/public/dns_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace { @@ -80,7 +81,7 @@ void IPFSHostResolver::Resolve(const net::HostPortPair& host, void IPFSHostResolver::OnComplete( int result, const net::ResolveErrorInfo& error_info, - const base::Optional& list) { + const absl::optional& list) { 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 6f1631ba59d3..86f76b1c002c 100644 --- a/browser/ipfs/ipfs_host_resolver.h +++ b/browser/ipfs/ipfs_host_resolver.h @@ -49,7 +49,7 @@ class IPFSHostResolver : public network::ResolveHostClientBase { void OnComplete( int result, const net::ResolveErrorInfo& resolve_error_info, - const base::Optional& resolved_addresses) override; + const absl::optional& resolved_addresses) 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 7c44d4ac3750..ea05a572008f 100644 --- a/browser/ipfs/ipfs_host_resolver_unittest.cc +++ b/browser/ipfs/ipfs_host_resolver_unittest.cc @@ -92,7 +92,7 @@ class FakeHostResolverFail : public FakeHostResolver { pending_response_client) override { mojo::Remote response_client; response_client.Bind(std::move(pending_response_client)); - response_client->OnComplete(-2, net::ResolveErrorInfo(), base::nullopt); + response_client->OnComplete(-2, net::ResolveErrorInfo(), absl::nullopt); resolve_host_called_++; } }; diff --git a/browser/ipfs/ipfs_policy_browsertest.cc b/browser/ipfs/ipfs_policy_browsertest.cc index 5ce22c45e77e..0a31894e7318 100644 --- a/browser/ipfs/ipfs_policy_browsertest.cc +++ b/browser/ipfs/ipfs_policy_browsertest.cc @@ -13,10 +13,10 @@ #include "brave/components/ipfs/ipfs_navigation_throttle.h" #include "brave/components/ipfs/ipfs_utils.h" #include "brave/components/ipfs/pref_names.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/policy/core/browser/browser_policy_connector.h" #include "components/policy/core/common/mock_configuration_policy_provider.h" #include "components/policy/core/common/policy_map.h" @@ -76,9 +76,9 @@ class IpfsPolicyTest : public InProcessBrowserTest { } size_t infobar_count() const { - InfoBarService* infobar_service = - InfoBarService::FromWebContents(web_contents()); - return infobar_service->infobar_count(); + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(web_contents()); + return infobar_manager->infobar_count(); } const GURL& ipfs_url() { return ipfs_url_; } diff --git a/browser/ipfs/ipfs_service_factory.cc b/browser/ipfs/ipfs_service_factory.cc index 84132da96298..822d18341d43 100644 --- a/browser/ipfs/ipfs_service_factory.cc +++ b/browser/ipfs/ipfs_service_factory.cc @@ -78,7 +78,7 @@ KeyedService* IpfsServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { base::FilePath user_data_dir; base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); - auto url_loader = content::BrowserContext::GetDefaultStoragePartition(context) + auto url_loader = context->GetDefaultStoragePartition() ->GetURLLoaderFactoryForBrowserProcess(); auto context_getter = std::make_unique(context); auto* ipfs_updater = g_brave_browser_process diff --git a/browser/ipfs/ipfs_tab_helper.cc b/browser/ipfs/ipfs_tab_helper.cc index 116eaab5a500..88c5368f4b70 100644 --- a/browser/ipfs/ipfs_tab_helper.cc +++ b/browser/ipfs/ipfs_tab_helper.cc @@ -101,8 +101,8 @@ IPFSTabHelper::IPFSTabHelper(content::WebContents* web_contents) : content::WebContentsObserver(web_contents), IpfsImportController(web_contents) { pref_service_ = user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()); - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - web_contents->GetBrowserContext()); + auto* storage_partition = + web_contents->GetBrowserContext()->GetDefaultStoragePartition(); resolver_.reset(new IPFSHostResolver(storage_partition->GetNetworkContext(), kDnsDomainPrefix)); diff --git a/browser/ipfs/ipfs_tab_helper_browsertest.cc b/browser/ipfs/ipfs_tab_helper_browsertest.cc index ac2e399aa6c7..fff0473a5538 100644 --- a/browser/ipfs/ipfs_tab_helper_browsertest.cc +++ b/browser/ipfs/ipfs_tab_helper_browsertest.cc @@ -106,8 +106,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, ResolvedIPFSLinkLocal) { ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); @@ -166,8 +166,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, ResolvedIPFSLinkGateway) { ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); @@ -194,8 +194,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, NoResolveIPFSLinkCalledMode) { ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); @@ -229,8 +229,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); @@ -254,8 +254,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, ResolveIPFSLinkCalled5xx) { ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); @@ -284,8 +284,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, ResolveNotCalled5xx) { ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); @@ -311,8 +311,8 @@ IN_PROC_BROWSER_TEST_F(IpfsTabHelperBrowserTest, ResolvedIPFSLinkBad) { ipfs::IPFSTabHelper::FromWebContents(active_contents()); if (!helper) return; - auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition( - active_contents()->GetBrowserContext()); + auto* storage_partition = + active_contents()->GetBrowserContext()->GetDefaultStoragePartition(); std::unique_ptr resolver( new FakeIPFSHostResolver(storage_partition->GetNetworkContext())); FakeIPFSHostResolver* resolver_raw = resolver.get(); diff --git a/browser/ipfs/test/BUILD.gn b/browser/ipfs/test/BUILD.gn index 846096c90404..234e521ee450 100644 --- a/browser/ipfs/test/BUILD.gn +++ b/browser/ipfs/test/BUILD.gn @@ -66,6 +66,7 @@ source_set("browsertests") { "//brave/components/ipfs", "//chrome/test:test_support", "//chrome/test:test_support_ui", + "//components/infobars/content", "//components/network_session_configurator/common:common", "//components/policy/core/browser", "//components/policy/core/common:test_support", diff --git a/browser/ipfs/test/ipfs_navigation_throttle_unittest.cc b/browser/ipfs/test/ipfs_navigation_throttle_unittest.cc index 6db23d0c8d05..5cd64e23e9ba 100644 --- a/browser/ipfs/test/ipfs_navigation_throttle_unittest.cc +++ b/browser/ipfs/test/ipfs_navigation_throttle_unittest.cc @@ -378,10 +378,11 @@ TEST_F(IpfsNavigationThrottleUnitTest, Instantiation) { // Disable in OTR profile. auto otr_web_contents = content::WebContentsTester::CreateTestWebContents( - profile()->GetPrimaryOTRProfile(), nullptr); + profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true), nullptr); content::MockNavigationHandle otr_test_handle(otr_web_contents.get()); auto throttle_in_otr = IpfsNavigationThrottle::MaybeCreateThrottleFor( - &otr_test_handle, ipfs_service(profile()->GetPrimaryOTRProfile()), + &otr_test_handle, + ipfs_service(profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true)), profile()->GetPrefs(), locale()); EXPECT_EQ(throttle_in_otr, nullptr); diff --git a/browser/ipfs/test/ipfs_network_utils_unittest.cc b/browser/ipfs/test/ipfs_network_utils_unittest.cc index 7c3b60521362..34c49d4363c7 100644 --- a/browser/ipfs/test/ipfs_network_utils_unittest.cc +++ b/browser/ipfs/test/ipfs_network_utils_unittest.cc @@ -15,6 +15,7 @@ #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_browser_context.h" #include "services/network/public/cpp/data_element.h" +#include "services/network/public/cpp/resource_request.h" #include "storage/browser/blob/blob_data_builder.h" #include "storage/browser/blob/blob_data_item.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/browser/ipfs/test/ipfs_service_browsertest.cc b/browser/ipfs/test/ipfs_service_browsertest.cc index c51c8db818fd..582bf2219163 100644 --- a/browser/ipfs/test/ipfs_service_browsertest.cc +++ b/browser/ipfs/test/ipfs_service_browsertest.cc @@ -7,6 +7,7 @@ #include "base/path_service.h" #include "base/run_loop.h" #include "base/strings/strcat.h" +#include "base/strings/stringprintf.h" #include "base/test/mock_callback.h" #include "base/test/scoped_feature_list.h" #include "brave/browser/brave_browser_process.h" @@ -742,12 +743,13 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); auto error_caught = - EvalJsWithManualReply(contents, - "fetch('ipfs://" - "Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC/2')" - " .catch((e) => {" - " window.domAutomationController.send(true);" - " });"); + EvalJs(contents, + "fetch('ipfs://" + "Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC/2')" + " .catch((e) => {" + " window.domAutomationController.send(true);" + " });", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(error_caught.error.empty()); EXPECT_EQ(base::Value(true), error_caught.value); } @@ -766,16 +768,17 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CanFetchIPFSResourcesFromIPFS) { ui_test_utils::NavigateToURL(browser(), url); content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto got_fetch = EvalJsWithManualReply( - contents, - "fetch('ipfs://" - "Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC/2')" - " .then(response => { response.text()" - " .then((response_text) => {" - " const result = response_text == 'simple content 2';" - " window.domAutomationController.send(result);" - " })})" - ".catch((x) => console.log('error: ' + x));"); + auto got_fetch = + EvalJs(contents, + "fetch('ipfs://" + "Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC/2')" + " .then(response => { response.text()" + " .then((response_text) => {" + " const result = response_text == 'simple content 2';" + " window.domAutomationController.send(result);" + " })})" + ".catch((x) => console.log('error: ' + x));", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(got_fetch.error.empty()); EXPECT_EQ(base::Value(true), got_fetch.value); } @@ -791,14 +794,15 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CannotLoadIframeFromHTTP) { browser()->tab_strip_model()->GetActiveWebContents(); auto* child_frame = ChildFrameAt(contents->GetMainFrame(), 0); - auto location = EvalJsWithManualReply( - child_frame, - "const timer = setInterval(function () {" - " if (document.readyState == 'complete') {" - " clearInterval(timer);" - " window.domAutomationController.send(window.location.href);" - " }" - "}, 100);"); + auto location = + EvalJs(child_frame, + "const timer = setInterval(function () {" + " if (document.readyState == 'complete') {" + " clearInterval(timer);" + " window.domAutomationController.send(window.location.href);" + " }" + "}, 100);", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(location.error.empty()); EXPECT_EQ(base::Value("chrome-error://chromewebdata/"), location.value); @@ -818,21 +822,22 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CanLoadIFrameFromIPFS) { browser(), GURL("ipfs://Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC")); content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto result = EvalJsWithManualReply( - contents, - "const iframe = document.createElement('iframe');" - "iframe.src =" - " 'ipfs://Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC/2';" - "document.body.appendChild(iframe);" - "const timer = setInterval(function () {" - " const iframeDoc = iframe.contentDocument || " - " iframe.contentWindow.document;" - " if (iframeDoc.readyState === 'complete' && " - " iframeDoc.location.href !== 'about:blank') {" - " clearInterval(timer);" - " window.domAutomationController.send(window.location.href);" - " }" - "}, 100);"); + auto result = + EvalJs(contents, + "const iframe = document.createElement('iframe');" + "iframe.src =" + " 'ipfs://Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC/2';" + "document.body.appendChild(iframe);" + "const timer = setInterval(function () {" + " const iframeDoc = iframe.contentDocument || " + " iframe.contentWindow.document;" + " if (iframeDoc.readyState === 'complete' && " + " iframeDoc.location.href !== 'about:blank') {" + " clearInterval(timer);" + " window.domAutomationController.send(window.location.href);" + " }" + "}, 100);", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(result.error.empty()); // Make sure main frame URL didn't change auto* prefs = browser()->profile()->GetPrefs(); @@ -856,7 +861,7 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CanLoadIPFSImageFromIPFS) { browser(), GURL("ipfs://Qmc2JTQo4iXf24g98otZmGFQq176eQ2Cdbb88qA5ToMEvC")); content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto loaded = EvalJsWithManualReply( + auto loaded = EvalJs( contents, "let img = document.createElement('img');" "img.src =" @@ -866,7 +871,8 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CanLoadIPFSImageFromIPFS) { "};" "img.onerror = function() {" " window.domAutomationController.send(true);" - "};"); + "};", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(loaded.error.empty()); EXPECT_EQ(base::Value(true), loaded.value); } @@ -880,7 +886,7 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CannotLoadIPFSImageFromHTTP) { ui_test_utils::NavigateToURL(browser(), GetURL("b.com", "/simple.html")); content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - auto loaded = EvalJsWithManualReply( + auto loaded = EvalJs( contents, "let img = document.createElement('img');" "img.src =" @@ -890,7 +896,8 @@ IN_PROC_BROWSER_TEST_F(IpfsServiceBrowserTest, CannotLoadIPFSImageFromHTTP) { "};" "img.onerror = function() {" " window.domAutomationController.send(true);" - "};"); + "};", + content::EXECUTE_SCRIPT_USE_MANUAL_REPLY); ASSERT_TRUE(loaded.error.empty()); EXPECT_EQ(base::Value(true), loaded.value); } diff --git a/browser/metrics/test/BUILD.gn b/browser/metrics/test/BUILD.gn index 9d3fc0c6f856..a7a597606628 100644 --- a/browser/metrics/test/BUILD.gn +++ b/browser/metrics/test/BUILD.gn @@ -17,7 +17,6 @@ source_set("brave_metrics_unit_tests") { deps = [ "//base/test:test_support", "//brave/browser", - "//brave/test:brave_browser_tests", "//chrome/browser:browser", "//chrome/common:channel_info", "//components/version_info:channel", diff --git a/browser/net/brave_ad_block_csp_network_delegate_helper.cc b/browser/net/brave_ad_block_csp_network_delegate_helper.cc index 66cc6757a57e..1b26e19f7245 100644 --- a/browser/net/brave_ad_block_csp_network_delegate_helper.cc +++ b/browser/net/brave_ad_block_csp_network_delegate_helper.cc @@ -17,9 +17,9 @@ namespace brave { -base::Optional GetCspDirectivesOnTaskRunner( +absl::optional GetCspDirectivesOnTaskRunner( std::shared_ptr ctx, - base::Optional original_csp) { + absl::optional original_csp) { std::string source_host; if (ctx->initiator_url.is_valid() && !ctx->initiator_url.host().empty()) { source_host = ctx->initiator_url.host(); @@ -29,10 +29,10 @@ base::Optional GetCspDirectivesOnTaskRunner( // use the request URL as the initiator. source_host = ctx->request_url.host(); } else { - return base::nullopt; + return absl::nullopt; } - base::Optional csp_directives = + absl::optional csp_directives = g_brave_browser_process->ad_block_service()->GetCspDirectives( ctx->request_url, ctx->resource_type, source_host); @@ -44,7 +44,7 @@ void OnReceiveCspDirectives( const ResponseCallback& next_callback, std::shared_ptr ctx, scoped_refptr override_response_headers, - base::Optional csp_directives) { + absl::optional csp_directives) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (csp_directives) { @@ -81,11 +81,11 @@ int OnHeadersReceived_AdBlockCspWork( g_brave_browser_process->ad_block_service()->GetTaskRunner(); std::string original_csp_string; - base::Optional original_csp = base::nullopt; + absl::optional original_csp = absl::nullopt; if ((*override_response_headers) ->GetNormalizedHeader("Content-Security-Policy", &original_csp_string)) { - original_csp = base::Optional(original_csp_string); + original_csp = absl::optional(original_csp_string); } (*override_response_headers)->RemoveHeader("Content-Security-Policy"); 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 33464a966b77..d18bae3ce5d3 100644 --- a/browser/net/brave_ad_block_tp_network_delegate_helper.cc +++ b/browser/net/brave_ad_block_tp_network_delegate_helper.cc @@ -41,6 +41,7 @@ #include "net/proxy_resolution/proxy_config_with_annotation.h" #include "services/network/host_resolver.h" #include "services/network/network_context.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/resource/resource_bundle.h" #include "url/url_canon.h" @@ -65,12 +66,12 @@ void UseCnameResult(scoped_refptr task_runner, const ResponseCallback& next_callback, std::shared_ptr ctx, EngineFlags previous_result, - base::Optional cname); + absl::optional cname); class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { private: mojo::Receiver receiver_{this}; - base::OnceCallback)> cb_; + base::OnceCallback)> cb_; base::TimeTicks start_time_; public: @@ -110,13 +111,13 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { if (!web_contents) { start_time_ = base::TimeTicks::Now(); this->OnComplete(net::ERR_FAILED, net::ResolveErrorInfo(), - base::nullopt); + absl::nullopt); return; } network::mojom::NetworkContext* network_context = - content::BrowserContext::GetDefaultStoragePartition( - web_contents->GetBrowserContext()) + web_contents->GetBrowserContext() + ->GetDefaultStoragePartition() ->GetNetworkContext(); network_context->ResolveHost( @@ -127,21 +128,21 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { receiver_.set_disconnect_handler( base::BindOnce(&AdblockCnameResolveHostClient::OnComplete, base::Unretained(this), net::ERR_NAME_NOT_RESOLVED, - net::ResolveErrorInfo(net::ERR_FAILED), base::nullopt)); + net::ResolveErrorInfo(net::ERR_FAILED), absl::nullopt)); } void OnComplete( int32_t result, const net::ResolveErrorInfo& resolve_error_info, - const base::Optional& resolved_addresses) override { + const absl::optional& resolved_addresses) override { UMA_HISTOGRAM_TIMES("Brave.ShieldsCNAMEBlocking.TotalResolutionTime", base::TimeTicks::Now() - start_time_); if (result == net::OK && resolved_addresses) { DCHECK(resolved_addresses.has_value() && !resolved_addresses->empty()); std::move(cb_).Run( - base::Optional(resolved_addresses->GetCanonicalName())); + absl::optional(resolved_addresses->GetCanonicalName())); } else { - std::move(cb_).Run(base::nullopt); + std::move(cb_).Run(absl::nullopt); } delete this; @@ -164,7 +165,7 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { EngineFlags ShouldBlockRequestOnTaskRunner( std::shared_ptr ctx, EngineFlags previous_result, - base::Optional canonical_url) { + absl::optional canonical_url) { if (!ctx->initiator_url.is_valid()) { return previous_result; } @@ -214,7 +215,7 @@ void UseCnameResult(scoped_refptr task_runner, const ResponseCallback& next_callback, std::shared_ptr ctx, EngineFlags previous_result, - base::Optional cname) { + absl::optional cname) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (cname.has_value() && ctx->request_url.host() != *cname && @@ -227,7 +228,7 @@ void UseCnameResult(scoped_refptr task_runner, task_runner->PostTaskAndReplyWithResult( FROM_HERE, base::BindOnce(&ShouldBlockRequestOnTaskRunner, ctx, previous_result, - base::make_optional(canonical_url)), + absl::make_optional(canonical_url)), base::BindOnce(&OnShouldBlockRequestResult, false, task_runner, next_callback, ctx)); } else { @@ -292,7 +293,7 @@ void OnBeforeURLRequestAdBlockTP(const ResponseCallback& next_callback, task_runner->PostTaskAndReplyWithResult( FROM_HERE, base::BindOnce(&ShouldBlockRequestOnTaskRunner, ctx, EngineFlags(), - base::nullopt), + absl::nullopt), base::BindOnce(&OnShouldBlockRequestResult, should_check_uncloaked, task_runner, next_callback, ctx)); } diff --git a/browser/net/brave_network_delegate_base_unittest.cc b/browser/net/brave_network_delegate_base_unittest.cc index 3742356fb625..55c0e8a327cc 100644 --- a/browser/net/brave_network_delegate_base_unittest.cc +++ b/browser/net/brave_network_delegate_base_unittest.cc @@ -65,7 +65,7 @@ TEST_F(BraveNetworkDelegateBaseTest, RemoveTrackableSecurityHeaders) { url::Origin::Create(tab_url), nullptr, &headers); for (auto header : *TrackableSecurityHeaders()) { - EXPECT_FALSE(headers->HasHeader(header.as_string())); + EXPECT_FALSE(headers->HasHeader(std::string(header))); } EXPECT_TRUE(headers->HasHeader(kAcceptLanguageHeader)); EXPECT_TRUE(headers->HasHeader(kXSSProtectionHeader)); @@ -83,7 +83,7 @@ TEST_F(BraveNetworkDelegateBaseTest, RemoveTrackableSecurityHeadersMixedCase) { url::Origin::Create(tab_url), nullptr, &headers); for (auto header : *TrackableSecurityHeaders()) { - EXPECT_FALSE(headers->HasHeader(header.as_string())); + EXPECT_FALSE(headers->HasHeader(std::string(header))); } EXPECT_TRUE(headers->HasHeader(kAcceptLanguageHeader)); EXPECT_TRUE(headers->HasHeader(kXSSProtectionHeader)); @@ -101,7 +101,7 @@ TEST_F(BraveNetworkDelegateBaseTest, RetainTrackableSecurityHeaders) { url::Origin::Create(tab_url), nullptr, &headers); for (auto header : *TrackableSecurityHeaders()) { - EXPECT_TRUE(headers->HasHeader(header.as_string())); + EXPECT_TRUE(headers->HasHeader(std::string(header))); } EXPECT_TRUE(headers->HasHeader(kAcceptLanguageHeader)); EXPECT_TRUE(headers->HasHeader(kXSSProtectionHeader)); diff --git a/browser/net/brave_network_delegate_browsertest.cc b/browser/net/brave_network_delegate_browsertest.cc index 08b0342da647..c47423b6848f 100644 --- a/browser/net/brave_network_delegate_browsertest.cc +++ b/browser/net/brave_network_delegate_browsertest.cc @@ -4,6 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "base/path_service.h" +#include "base/strings/stringprintf.h" #include "brave/common/brave_paths.h" #include "brave/common/pref_names.h" #include "brave/components/brave_shields/browser/brave_shields_util.h" diff --git a/browser/net/brave_proxying_url_loader_factory.cc b/browser/net/brave_proxying_url_loader_factory.cc index ca7153276e8c..86a1ea86d398 100644 --- a/browser/net/brave_proxying_url_loader_factory.cc +++ b/browser/net/brave_proxying_url_loader_factory.cc @@ -58,7 +58,7 @@ net::RedirectInfo CreateRedirectInfo( const network::ResourceRequest& original_request, const GURL& new_url, int response_code, - const base::Optional& referrer_policy_header) { + const absl::optional& referrer_policy_header) { // Workaround for a bug in Chromium (crbug.com/1097681). // download_utils.cc do not set update_first_party_url_on_redirect to true // for new ResourceRequests, but we can mitigate it by looking at @@ -175,7 +175,7 @@ void BraveProxyingURLLoaderFactory::InProgressRequest::FollowRedirect( const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const base::Optional& new_url) { + const absl::optional& new_url) { if (new_url) request_.url = new_url.value(); @@ -294,7 +294,7 @@ void BraveProxyingURLLoaderFactory::InProgressRequest:: net::RedirectInfo redirect_info = CreateRedirectInfo(request_, redirect_url_, kInternalRedirectStatusCode, - base::nullopt /* referrer_policy_header */); + absl::nullopt /* referrer_policy_header */); network::mojom::URLResponseHeadPtr head = network::mojom::URLResponseHead::New(); diff --git a/browser/net/brave_proxying_url_loader_factory.h b/browser/net/brave_proxying_url_loader_factory.h index c4e3bbd243c2..989eeafb7064 100644 --- a/browser/net/brave_proxying_url_loader_factory.h +++ b/browser/net/brave_proxying_url_loader_factory.h @@ -19,7 +19,6 @@ #include "base/macros.h" #include "base/memory/ref_counted_delete_on_sequence.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/time/time.h" #include "brave/browser/net/resource_context_data.h" #include "brave/browser/net/url_context.h" @@ -32,6 +31,7 @@ #include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace content { @@ -71,7 +71,7 @@ class BraveProxyingURLLoaderFactory const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const base::Optional& new_url) override; + const absl::optional& new_url) override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override; void PauseReadingBodyFromNet() override; @@ -159,7 +159,7 @@ class BraveProxyingURLLoaderFactory std::vector removed_headers; net::HttpRequestHeaders modified_headers; net::HttpRequestHeaders modified_cors_exempt_headers; - base::Optional new_url; + absl::optional new_url; DISALLOW_COPY_AND_ASSIGN(FollowRedirectParams); }; diff --git a/browser/net/brave_proxying_web_socket.cc b/browser/net/brave_proxying_web_socket.cc index 4408d95dcc3c..0d58260f1c69 100644 --- a/browser/net/brave_proxying_web_socket.cc +++ b/browser/net/brave_proxying_web_socket.cc @@ -7,8 +7,8 @@ #include -#include "base/containers/flat_set.h" #include "base/bind.h" +#include "base/containers/flat_set.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/task/post_task.h" @@ -20,6 +20,7 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "net/cookies/site_for_cookies.h" +#include "third_party/abseil-cpp/absl/types/optional.h" BraveProxyingWebSocket::BraveProxyingWebSocket( WebSocketFactory factory, @@ -51,11 +52,11 @@ BraveProxyingWebSocket::~BraveProxyingWebSocket() { } if (on_before_send_headers_callback_) { std::move(on_before_send_headers_callback_) - .Run(net::ERR_ABORTED, base::nullopt); + .Run(net::ERR_ABORTED, absl::nullopt); } if (on_headers_received_callback_) { std::move(on_headers_received_callback_) - .Run(net::ERR_ABORTED, base::nullopt, base::nullopt); + .Run(net::ERR_ABORTED, absl::nullopt, absl::nullopt); } } @@ -65,7 +66,7 @@ BraveProxyingWebSocket* BraveProxyingWebSocket::ProxyWebSocket( content::ContentBrowserClient::WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const base::Optional& user_agent, + const absl::optional& user_agent, mojo::PendingRemote handshake_client) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -262,7 +263,7 @@ void BraveProxyingWebSocket::OnBeforeRequestComplete(int error_code) { void BraveProxyingWebSocket::OnBeforeSendHeadersCompleteFromProxy( int error_code, - const base::Optional& headers) { + const absl::optional& headers) { DCHECK(proxy_has_extra_headers() || !receiver_as_handshake_client_.is_bound()); if (error_code != net::OK) { @@ -308,8 +309,9 @@ void BraveProxyingWebSocket::OnBeforeSendHeadersComplete(int error_code) { } if (on_before_send_headers_callback_) - std::move(on_before_send_headers_callback_).Run( - error_code, base::Optional(request_.headers)); + std::move(on_before_send_headers_callback_) + .Run(error_code, + absl::optional(request_.headers)); if (!proxy_has_extra_headers()) ContinueToStartRequest(error_code); @@ -352,11 +354,11 @@ void BraveProxyingWebSocket::ContinueToStartRequest(int error_code) { void BraveProxyingWebSocket::OnHeadersReceivedCompleteFromProxy( int error_code, - const base::Optional& headers, - const base::Optional& url) { + const absl::optional& headers, + const absl::optional& url) { if (on_headers_received_callback_) std::move(on_headers_received_callback_) - .Run(net::OK, headers, base::nullopt); + .Run(net::OK, headers, absl::nullopt); if (override_headers_) { response_.headers = override_headers_; @@ -385,7 +387,7 @@ void BraveProxyingWebSocket::OnHeadersReceivedComplete(int error_code) { weak_factory_.GetWeakPtr())); } else { OnHeadersReceivedCompleteFromProxy( - error_code, base::Optional(headers), base::nullopt); + error_code, absl::optional(headers), absl::nullopt); } } diff --git a/browser/net/brave_proxying_web_socket.h b/browser/net/brave_proxying_web_socket.h index ed82413eea4e..4ed10e3c494e 100644 --- a/browser/net/brave_proxying_web_socket.h +++ b/browser/net/brave_proxying_web_socket.h @@ -14,7 +14,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "brave/browser/net/resource_context_data.h" #include "brave/browser/net/url_context.h" #include "content/public/browser/content_browser_client.h" @@ -26,6 +25,7 @@ #include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" #include "services/network/public/mojom/websocket.mojom.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -63,7 +63,7 @@ class BraveProxyingWebSocket content::ContentBrowserClient::WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const base::Optional& user_agent, + const absl::optional& user_agent, mojo::PendingRemote handshake_client); @@ -117,11 +117,11 @@ class BraveProxyingWebSocket void ContinueToHeadersReceived(); void OnBeforeSendHeadersCompleteFromProxy( int error_code, - const base::Optional& headers); + const absl::optional& headers); void OnHeadersReceivedCompleteFromProxy( int error_code, - const base::Optional& headers, - const base::Optional& url); + const absl::optional& headers, + const absl::optional& url); void PauseIncomingMethodCallProcessing(); void ResumeIncomingMethodCallProcessing(); diff --git a/browser/net/brave_stp_util.cc b/browser/net/brave_stp_util.cc index aa872c55c744..13d4d3a70fc2 100644 --- a/browser/net/brave_stp_util.cc +++ b/browser/net/brave_stp_util.cc @@ -5,6 +5,8 @@ #include "brave/browser/net/brave_stp_util.h" +#include + #include "base/no_destructor.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" @@ -37,7 +39,7 @@ void RemoveTrackableSecurityHeadersForThirdParty( new net::HttpResponseHeaders(original_response_headers->raw_headers()); } for (auto header : *TrackableSecurityHeaders()) { - (*override_response_headers)->RemoveHeader(header.as_string()); + (*override_response_headers)->RemoveHeader(std::string(header)); } } diff --git a/browser/net/decentralized_dns_network_delegate_helper_unittest.cc b/browser/net/decentralized_dns_network_delegate_helper_unittest.cc index 484c6584baef..ca7de9b391cb 100644 --- a/browser/net/decentralized_dns_network_delegate_helper_unittest.cc +++ b/browser/net/decentralized_dns_network_delegate_helper_unittest.cc @@ -72,7 +72,8 @@ TEST_F(DecentralizedDnsNetworkDelegateHelperTest, EXPECT_TRUE(IsUnstoppableDomainsResolveMethodEthereum(local_state())); // No redirect for OTR context. - brave_request_info->browser_context = profile()->GetPrimaryOTRProfile(); + brave_request_info->browser_context = + profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true); rc = OnBeforeURLRequest_DecentralizedDnsPreRedirectWork(ResponseCallback(), brave_request_info); EXPECT_EQ(rc, net::OK); diff --git a/browser/net/ipfs_redirect_network_delegate_helper_unittest.cc b/browser/net/ipfs_redirect_network_delegate_helper_unittest.cc index f85b7176abd1..9a596a7676df 100644 --- a/browser/net/ipfs_redirect_network_delegate_helper_unittest.cc +++ b/browser/net/ipfs_redirect_network_delegate_helper_unittest.cc @@ -207,7 +207,8 @@ TEST_F(IPFSRedirectNetworkDelegateHelperTest, HeadersIPFSWorkNoRedirect) { TEST_F(IPFSRedirectNetworkDelegateHelperTest, PrivateProfile) { GURL url("ipfs://QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG"); auto brave_request_info = std::make_shared(url); - brave_request_info->browser_context = profile()->GetPrimaryOTRProfile(); + brave_request_info->browser_context = + profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true); brave_request_info->ipfs_gateway_url = GetPublicGateway(); brave_request_info->initiator_url = ipfs::GetIPFSGatewayURL( initiator_cid, "", ipfs::GetDefaultIPFSGateway(profile()->GetPrefs())); diff --git a/browser/net/resource_context_data.cc b/browser/net/resource_context_data.cc index d3ee487ed4f8..3c4049fb9de4 100644 --- a/browser/net/resource_context_data.cc +++ b/browser/net/resource_context_data.cc @@ -61,7 +61,7 @@ BraveProxyingWebSocket* ResourceContextData::StartProxyingWebSocket( content::ContentBrowserClient::WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const base::Optional& user_agent, + const absl::optional& user_agent, mojo::PendingRemote handshake_client, content::BrowserContext* browser_context, @@ -105,7 +105,6 @@ BraveProxyingWebSocket* ResourceContextData::StartProxyingWebSocket( return raw_proxy; } - void ResourceContextData::RemoveProxy(BraveProxyingURLLoaderFactory* proxy) { auto it = proxies_.find(proxy); DCHECK(it != proxies_.end()); @@ -117,4 +116,3 @@ void ResourceContextData::RemoveProxyWebSocket(BraveProxyingWebSocket* proxy) { DCHECK(it != websocket_proxies_.end()); websocket_proxies_.erase(it); } - diff --git a/browser/net/resource_context_data.h b/browser/net/resource_context_data.h index 2b78174155a1..5984765c0b88 100644 --- a/browser/net/resource_context_data.h +++ b/browser/net/resource_context_data.h @@ -66,7 +66,7 @@ class ResourceContextData : public base::SupportsUserData::Data { content::ContentBrowserClient::WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const base::Optional& user_agent, + const absl::optional& user_agent, mojo::PendingRemote handshake_client, content::BrowserContext* browser_context, diff --git a/browser/net/url_context.h b/browser/net/url_context.h index 07c8d4817cca..188e9d3a1246 100644 --- a/browser/net/url_context.h +++ b/browser/net/url_context.h @@ -14,6 +14,7 @@ #include "net/http/http_request_headers.h" #include "net/http/http_response_headers.h" #include "net/url_request/referrer_policy.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h" #include "url/gurl.h" @@ -69,7 +70,7 @@ struct BraveRequestInfo { GURL referrer; net::ReferrerPolicy referrer_policy = net::ReferrerPolicy::CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE; - base::Optional new_referrer; + absl::optional new_referrer; std::string new_url_spec; // TODO(iefremov): rename to shields_up. diff --git a/browser/new_tab/BUILD.gn b/browser/new_tab/BUILD.gn index c68e8fc4457a..5691374e130e 100644 --- a/browser/new_tab/BUILD.gn +++ b/browser/new_tab/BUILD.gn @@ -7,9 +7,7 @@ source_set("unittest") { testonly = true if (!is_android) { - sources = [ - "new_tab_shows_options_unittest.cc", - ] + sources = [ "new_tab_shows_options_unittest.cc" ] deps = [ "//brave/browser", "//brave/common", diff --git a/browser/new_tab/new_tab_shows_options_unittest.cc b/browser/new_tab/new_tab_shows_options_unittest.cc index 4fb6814a3e69..952ee46b9222 100644 --- a/browser/new_tab/new_tab_shows_options_unittest.cc +++ b/browser/new_tab/new_tab_shows_options_unittest.cc @@ -34,7 +34,8 @@ class BraveNewTabTest : public testing::Test { TEST_F(BraveNewTabTest, BasicTest) { Profile* profile = manager()->CreateTestingProfile("Test 1"); - Profile* otr_profile = profile->GetPrimaryOTRProfile(); + Profile* otr_profile = + profile->GetPrimaryOTRProfile(/*create_if_needed=*/true); ASSERT_TRUE(profile); ASSERT_TRUE(otr_profile); diff --git a/browser/notifications/BUILD.gn b/browser/notifications/BUILD.gn index 33fba6aa517a..09b5526b48ee 100644 --- a/browser/notifications/BUILD.gn +++ b/browser/notifications/BUILD.gn @@ -1,4 +1,7 @@ import("//chrome/common/features.gni") +if (is_android) { + import("//build/config/android/rules.gni") +} source_set("notifications") { # Remove when https://github.com/brave/brave-browser/issues/10657 is resolved @@ -9,7 +12,10 @@ source_set("notifications") { "ads_notification_handler.h", ] - deps = [ "//chrome/browser/notifications" ] + deps = [ + "//chrome/browser/notifications", + "//third_party/abseil-cpp:absl", + ] if (is_mac) { sources += [ @@ -45,3 +51,50 @@ source_set("notifications") { ] } } + +if (is_android) { + android_library("java") { + sources = [ + "android/java/src/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java", + "android/java/src/org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl.java", + ] + + deps = [ + ":brave_java", + ":java_resources", + "//base:base_java", + "//chrome/android:chrome_base_module_resources", + "//chrome/browser/notifications:java", + "//chrome/browser/notifications:java_resources", + "//components/browser_ui/notifications/android:java", + "//third_party/androidx:androidx_annotation_annotation_java", + "//ui/android:ui_no_recycler_view_java", + ] + + resources_package = "org.chromium.chrome.browser.notifications" + } + + # TODO(samartnik): we are unable to avoid this patch since we directly patch + # `ChromeChannelDefinitions.java`. There is no straightforward conversion of + # those patches to bytecode patching so we need to find a way to + # workaround those patches https://github.com/brave/brave-browser/issues/15867. + android_library("brave_java") { + sources = [ "android/java/src/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java" ] + + deps = [ + ":java_resources", + "//components/browser_ui/notifications/android:java", + ] + + resources_package = "org.chromium.chrome.browser.notifications" + } + + android_resources("java_resources") { + sources = [ + "android/java/res/layout/web_notification_big_brave_ads.xml", + "android/java/res/layout/web_notification_brave_ads.xml", + ] + + deps = [ "//brave/build/android:android_brave_strings_grd" ] + } +} diff --git a/browser/notifications/ads_notification_handler.cc b/browser/notifications/ads_notification_handler.cc index 176070e27e13..b27ab07cacea 100644 --- a/browser/notifications/ads_notification_handler.cc +++ b/browser/notifications/ads_notification_handler.cc @@ -8,6 +8,7 @@ #include #include "brave/browser/brave_ads/ads_service_factory.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace brave_ads { @@ -47,8 +48,8 @@ void AdsNotificationHandler::OnClick( Profile* profile, const GURL& origin, const std::string& id, - const base::Optional& action_index, - const base::Optional& reply, + const absl::optional& action_index, + const absl::optional& reply, base::OnceClosure completed_closure) { AdsService* ads_service = AdsServiceFactory::GetForProfile(profile); if (!ads_service) { diff --git a/browser/notifications/ads_notification_handler.h b/browser/notifications/ads_notification_handler.h index 2ca8cf015e01..86dd0be4998a 100644 --- a/browser/notifications/ads_notification_handler.h +++ b/browser/notifications/ads_notification_handler.h @@ -31,8 +31,8 @@ class AdsNotificationHandler : public NotificationHandler { void OnClick(Profile* profile, const GURL& origin, const std::string& id, - const base::Optional& action_index, - const base::Optional& reply, + const absl::optional& action_index, + const absl::optional& reply, base::OnceClosure completed_closure) override; void OpenSettings(Profile* profile, const GURL& origin) override; diff --git a/android/java/res/layout/web_notification_big_brave_ads.xml b/browser/notifications/android/java/res/layout/web_notification_big_brave_ads.xml similarity index 100% rename from android/java/res/layout/web_notification_big_brave_ads.xml rename to browser/notifications/android/java/res/layout/web_notification_big_brave_ads.xml diff --git a/android/java/res/layout/web_notification_brave_ads.xml b/browser/notifications/android/java/res/layout/web_notification_brave_ads.xml similarity index 100% rename from android/java/res/layout/web_notification_brave_ads.xml rename to browser/notifications/android/java/res/layout/web_notification_brave_ads.xml diff --git a/browser/brave_ads/android/java/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java b/browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java similarity index 95% rename from browser/brave_ads/android/java/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java rename to browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java index 3e7d6ea09a4d..5fd1f1a5bb31 100644 --- a/browser/brave_ads/android/java/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java +++ b/browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/BraveAdsNotificationBuilder.java @@ -28,7 +28,7 @@ import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApplicationStatus; -import org.chromium.chrome.R; +import org.chromium.chrome.browser.notifications.R; import org.chromium.chrome.browser.notifications.channels.BraveChannelDefinitions; import org.chromium.components.browser_ui.notifications.NotificationMetadata; import org.chromium.components.browser_ui.notifications.NotificationWrapper; @@ -143,18 +143,19 @@ public NotificationWrapper build(NotificationMetadata metadata) { // Note: under the hood this is not a NotificationCompat builder so be mindful of the // API level of methods you call on the builder. // TODO(crbug.com/697104) We should probably use a Compat builder. - String channelId = (ApplicationStatus.hasVisibleActivities()) ? - BraveChannelDefinitions.ChannelId.BRAVE_ADS : - BraveChannelDefinitions.ChannelId.BRAVE_ADS_BACKGROUND; + String channelId = (ApplicationStatus.hasVisibleActivities()) + ? BraveChannelDefinitions.ChannelId.BRAVE_ADS + : BraveChannelDefinitions.ChannelId.BRAVE_ADS_BACKGROUND; NotificationWrapperBuilder builder = - NotificationWrapperBuilderFactory.createNotificationWrapperBuilder(false /* preferCompat */, - channelId, mRemotePackageForBuilderContext, metadata); + NotificationWrapperBuilderFactory.createNotificationWrapperBuilder( + false /* preferCompat */, channelId, mRemotePackageForBuilderContext, + metadata); builder.setTicker(mTickerText); builder.setContentIntent(mContentIntent); builder.setDeleteIntent(mDeleteIntent); - int priority = (ApplicationStatus.hasVisibleActivities()) ? Notification.PRIORITY_HIGH : - Notification.PRIORITY_LOW; + int priority = (ApplicationStatus.hasVisibleActivities()) ? Notification.PRIORITY_HIGH + : Notification.PRIORITY_LOW; builder.setPriorityBeforeO(priority); builder.setDefaults(mDefaults); if (mVibratePattern != null) builder.setVibrate(mVibratePattern); diff --git a/android/java/org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl.java b/browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl.java similarity index 100% rename from android/java/org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl.java rename to browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/BraveNotificationManagerProxyImpl.java diff --git a/android/java/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java b/browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java similarity index 70% rename from android/java/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java rename to browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java index c6e4ce1f1ec9..76af71bbfaa9 100644 --- a/android/java/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java +++ b/browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/channels/BraveChannelDefinitions.java @@ -9,7 +9,7 @@ import android.app.NotificationManager; -import org.chromium.chrome.R; +import org.chromium.chrome.browser.notifications.R; import org.chromium.components.browser_ui.notifications.channels.ChannelDefinitions; import org.chromium.components.browser_ui.notifications.channels.ChannelDefinitions.PredefinedChannel; @@ -28,24 +28,24 @@ public class ChannelGroupId { } static protected void addBraveChannels( - Map map, Set startup) { + Map map, Set startup) { map.put(ChannelId.BRAVE_ADS, PredefinedChannel.create(ChannelId.BRAVE_ADS, - R.string.notification_category_brave_ads, - NotificationManager.IMPORTANCE_HIGH, ChannelGroupId.BRAVE_ADS)); + R.string.notification_category_brave_ads, + NotificationManager.IMPORTANCE_HIGH, ChannelGroupId.BRAVE_ADS)); startup.add(ChannelId.BRAVE_ADS); map.put(ChannelId.BRAVE_ADS_BACKGROUND, PredefinedChannel.create(ChannelId.BRAVE_ADS_BACKGROUND, - R.string.notification_category_brave_ads_background, - NotificationManager.IMPORTANCE_LOW, ChannelGroupId.BRAVE_ADS)); + R.string.notification_category_brave_ads_background, + NotificationManager.IMPORTANCE_LOW, ChannelGroupId.BRAVE_ADS)); startup.add(ChannelId.BRAVE_ADS_BACKGROUND); } static protected void addBraveChannelGroups( - Map map) { + Map map) { map.put(ChannelGroupId.BRAVE_ADS, new ChannelDefinitions.PredefinedChannelGroup( - ChannelGroupId.BRAVE_ADS, R.string.notification_category_group_brave_ads)); + ChannelGroupId.BRAVE_ADS, R.string.notification_category_group_brave_ads)); } } diff --git a/browser/ntp_background_images/android/ntp_background_images_bridge.h b/browser/ntp_background_images/android/ntp_background_images_bridge.h index bc15e1acdedd..b06e9fb2929e 100644 --- a/browser/ntp_background_images/android/ntp_background_images_bridge.h +++ b/browser/ntp_background_images/android/ntp_background_images_bridge.h @@ -13,10 +13,10 @@ #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/singleton.h" -#include "base/optional.h" #include "brave/components/ntp_background_images/browser/ntp_background_images_service.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/core/keyed_service.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class Profile; diff --git a/browser/profiles/brave_profile_manager_browsertest.cc b/browser/profiles/brave_profile_manager_browsertest.cc index d59e69861131..ea05564fabd5 100644 --- a/browser/profiles/brave_profile_manager_browsertest.cc +++ b/browser/profiles/brave_profile_manager_browsertest.cc @@ -142,7 +142,8 @@ IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest, ProfileManager* profile_manager = g_browser_process->profile_manager(); ASSERT_TRUE(profile_manager); Profile* profile = ProfileManager::GetActiveUserProfile(); - Profile* otr_profile = profile->GetPrimaryOTRProfile(); + Profile* otr_profile = + profile->GetPrimaryOTRProfile(/*create_if_needed=*/true); profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); ui_test_utils::WaitForBrowserToOpen(); @@ -186,7 +187,6 @@ IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest, g_browser_process->local_state()); ProfileManager* profile_manager = g_browser_process->profile_manager(); - base::FilePath last_used_path = - profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir()); + base::FilePath last_used_path = profile_manager->GetLastUsedProfileDir(); EXPECT_EQ(last_used_path.BaseName().AsUTF8Unsafe(), chrome::kInitialProfile); } diff --git a/browser/profiles/profile_util.h b/browser/profiles/profile_util.h index aff5072bf0e8..2e86f9a04c36 100644 --- a/browser/profiles/profile_util.h +++ b/browser/profiles/profile_util.h @@ -74,11 +74,12 @@ content::BrowserContext* GetBrowserContextRedirectedInIncognitoOverride( // Get the correct profile for keyed services that do NOT use // GetBrowserContextRedirectedInIncognito or equivalent -#define BRAVE_GET_BROWSER_CONTEXT_TO_USE_WITHOUT_REDIRECT \ - if (brave::IsSessionProfile(context)) { \ - auto* parent = brave::GetParentProfile(context); \ - context = \ - context->IsOffTheRecord() ? parent->GetPrimaryOTRProfile() : parent; \ +#define BRAVE_GET_BROWSER_CONTEXT_TO_USE_WITHOUT_REDIRECT \ + if (brave::IsSessionProfile(context)) { \ + auto* parent = brave::GetParentProfile(context); \ + context = context->IsOffTheRecord() \ + ? parent->GetPrimaryOTRProfile(/*create_if_needed=*/true) \ + : parent; \ } #endif // BRAVE_BROWSER_PROFILES_PROFILE_UTIL_H_ diff --git a/browser/renderer_context_menu/brave_spelling_menu_observer_browsertest.cc b/browser/renderer_context_menu/brave_spelling_menu_observer_browsertest.cc index 42ef3d95a021..96874d1cf9d5 100644 --- a/browser/renderer_context_menu/brave_spelling_menu_observer_browsertest.cc +++ b/browser/renderer_context_menu/brave_spelling_menu_observer_browsertest.cc @@ -37,7 +37,8 @@ class BraveSpellingMenuObserverTest : public InProcessBrowserTest { void Reset(bool incognito = false) { observer_.reset(); menu_.reset(new BraveMockRenderViewContextMenu( - incognito ? browser()->profile()->GetPrimaryOTRProfile() + incognito ? browser()->profile()->GetPrimaryOTRProfile( + /*create_if_needed=*/true) : browser()->profile())); observer_.reset(new SpellingMenuObserver(menu_.get())); menu_->SetObserver(observer_.get()); diff --git a/browser/renderer_context_menu/brave_spelling_options_submenu_observer_browsertest.cc b/browser/renderer_context_menu/brave_spelling_options_submenu_observer_browsertest.cc index e03d12e6e084..9bbfed88271e 100644 --- a/browser/renderer_context_menu/brave_spelling_options_submenu_observer_browsertest.cc +++ b/browser/renderer_context_menu/brave_spelling_options_submenu_observer_browsertest.cc @@ -42,7 +42,8 @@ class BraveSpellingOptionsSubMenuObserverTest : public InProcessBrowserTest { BraveSpellingOptionsSubMenuObserver::GTEST_MODE_NORMAL) { Clear(); menu_.reset(new BraveMockRenderViewContextMenu( - incognito ? browser()->profile()->GetPrimaryOTRProfile() + incognito ? browser()->profile()->GetPrimaryOTRProfile( + /*create_if_needed=*/true) : browser()->profile())); std::unique_ptr observer = std::make_unique(menu_.get(), diff --git a/browser/resources/settings/brave_overrides/settings_menu.js b/browser/resources/settings/brave_overrides/settings_menu.js index f374c67c2162..dccb8cba85d6 100644 --- a/browser/resources/settings/brave_overrides/settings_menu.js +++ b/browser/resources/settings/brave_overrides/settings_menu.js @@ -23,8 +23,16 @@ function createMenuElement (title, href, iconName, pageVisibilitySection) { } function getMenuElement (templateContent, href) { - const menuEl = templateContent.querySelector(`a[href="${href}"]`) + let menuEl = templateContent.querySelector(`a[href="${href}"]`) if (!menuEl) { + // Search templates + const templates = templateContent.querySelectorAll('template') + for (const template of templates) { + menuEl = template.content.querySelector(`a[href="${href}"]`) + if (menuEl) { + return menuEl + } + } console.error(`[Brave Settings Overrides] Could not find menu item '${href}'`) } return menuEl diff --git a/browser/search/BUILD.gn b/browser/search/BUILD.gn index 4abd3c022819..8789a2f42fe3 100644 --- a/browser/search/BUILD.gn +++ b/browser/search/BUILD.gn @@ -28,9 +28,7 @@ source_set("unit_tests") { testonly = true if (!is_android) { - sources = [ - "ntp_utils_unittest.cc", - ] + sources = [ "ntp_utils_unittest.cc" ] deps = [ "//brave/browser/search", "//brave/common:pref_names", @@ -42,9 +40,7 @@ source_set("unit_tests") { "//testing/gtest", ] if (crypto_dot_com_enabled) { - deps += [ - "//brave/components/crypto_dot_com/common", - ] + deps += [ "//brave/components/crypto_dot_com/common" ] } } } diff --git a/browser/search_engines/search_engine_provider_service_browsertest.cc b/browser/search_engines/search_engine_provider_service_browsertest.cc index d5f065507ffd..c7ed26426566 100644 --- a/browser/search_engines/search_engine_provider_service_browsertest.cc +++ b/browser/search_engines/search_engine_provider_service_browsertest.cc @@ -4,7 +4,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "base/path_service.h" -#include "base/strings/utf_string_conversions.h" #include "brave/browser/profiles/brave_profile_manager.h" #include "brave/browser/profiles/profile_util.h" #include "brave/browser/search_engines/guest_window_search_engine_provider_service.h" @@ -50,7 +49,8 @@ TemplateURLData CreateTestSearchEngine() { IN_PROC_BROWSER_TEST_F(SearchEngineProviderServiceTest, PrivateWindowPrefTestWithNonQwantRegion) { Profile* profile = browser()->profile(); - Profile* incognito_profile = profile->GetPrimaryOTRProfile(); + Profile* incognito_profile = + profile->GetPrimaryOTRProfile(/*create_if_needed=*/true); // This test case is only for non-qwant region. if (brave::IsRegionForQwant(profile)) @@ -99,7 +99,8 @@ IN_PROC_BROWSER_TEST_F(SearchEngineProviderServiceTest, IN_PROC_BROWSER_TEST_F(SearchEngineProviderServiceTest, PrivateWindowTestWithQwantRegion) { Profile* profile = browser()->profile(); - Profile* incognito_profile = profile->GetPrimaryOTRProfile(); + Profile* incognito_profile = + profile->GetPrimaryOTRProfile(/*create_if_needed=*/true); // This test case is only for qwant region. if (!brave::IsRegionForQwant(profile)) @@ -256,8 +257,8 @@ const int kTestExtensionPrepopulatedId = 3; // chrome/test/data/extensions/settings_override/manifest.json std::unique_ptr TestExtensionSearchEngine(PrefService* prefs) { auto result = std::make_unique(); - result->SetShortName(base::ASCIIToUTF16("name.de")); - result->SetKeyword(base::ASCIIToUTF16("keyword.de")); + result->SetShortName(u"name.de"); + result->SetKeyword(u"keyword.de"); result->SetURL("http://www.foo.de/s?q={searchTerms}&id=10"); result->favicon_url = GURL("http://www.foo.de/favicon.ico?id=10"); result->suggestions_url = "http://www.foo.de/suggest?q={searchTerms}&id=10"; @@ -311,7 +312,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TestExtensionSearchEngine(prefs); ExpectSimilar(extension_dse.get(), ¤t_dse->data()); - Profile* incognito_profile = profile()->GetPrimaryOTRProfile(); + Profile* incognito_profile = + profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true); auto* incognito_url_service = TemplateURLServiceFactory::GetForProfile(incognito_profile); @@ -337,8 +339,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, // After unloading private window's search provider is ddg. current_incognito_dse = incognito_url_service->GetDefaultSearchProvider(); - EXPECT_EQ(current_incognito_dse->data().short_name(), - base::ASCIIToUTF16("DuckDuckGo")); + EXPECT_EQ(current_incognito_dse->data().short_name(), u"DuckDuckGo"); EXPECT_EQ(TemplateURL::NORMAL, current_incognito_dse->type()); } #endif diff --git a/browser/sources.gni b/browser/sources.gni index 62a8dc1f4713..b1f41eece09e 100644 --- a/browser/sources.gni +++ b/browser/sources.gni @@ -239,6 +239,7 @@ if (is_android) { "//brave/browser/infobars", "//brave/browser/ui/bookmark", "//brave/components/weekly_storage", + "//components/infobars/content", ] } diff --git a/browser/themes/brave_theme_helper.cc b/browser/themes/brave_theme_helper.cc index b940dec3384b..62af9b015760 100644 --- a/browser/themes/brave_theme_helper.cc +++ b/browser/themes/brave_theme_helper.cc @@ -106,7 +106,7 @@ SkColor BraveThemeHelper::GetDefaultColor( } const dark_mode::BraveDarkModeType type = dark_mode::GetActiveBraveDarkModeType(); - const base::Optional braveColor = + const absl::optional braveColor = MaybeGetDefaultColorForBraveUi(id, incognito, is_tor_, type); if (braveColor) { return braveColor.value(); @@ -120,7 +120,7 @@ SkColor BraveThemeHelper::GetDefaultColor( return ThemeHelper::GetDefaultColor(id, incognito, theme_supplier); } -base::Optional BraveThemeHelper::GetOmniboxColor( +absl::optional BraveThemeHelper::GetOmniboxColor( int id, bool incognito, const CustomThemeSupplier* theme_supplier, diff --git a/browser/themes/brave_theme_helper.h b/browser/themes/brave_theme_helper.h index ee0aa4b87e7a..4bcd664cc19b 100644 --- a/browser/themes/brave_theme_helper.h +++ b/browser/themes/brave_theme_helper.h @@ -6,8 +6,8 @@ #ifndef BRAVE_BROWSER_THEMES_BRAVE_THEME_HELPER_H_ #define BRAVE_BROWSER_THEMES_BRAVE_THEME_HELPER_H_ -#include "base/optional.h" #include "chrome/browser/themes/theme_helper.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class Profile; @@ -29,7 +29,7 @@ class BraveThemeHelper : public ThemeHelper { bool incognito, const CustomThemeSupplier* theme_supplier) const override; - base::Optional GetOmniboxColor( + absl::optional GetOmniboxColor( int id, bool incognito, const CustomThemeSupplier* theme_supplier, diff --git a/browser/themes/brave_theme_service_browsertest.cc b/browser/themes/brave_theme_service_browsertest.cc index 0fe1f01d33c7..24625a9f9ecc 100644 --- a/browser/themes/brave_theme_service_browsertest.cc +++ b/browser/themes/brave_theme_service_browsertest.cc @@ -62,7 +62,8 @@ class BraveThemeServiceTestWithoutSystemTheme : public InProcessBrowserTest { IN_PROC_BROWSER_TEST_F(BraveThemeServiceTestWithoutSystemTheme, BraveThemeChangeTest) { Profile* profile = browser()->profile(); - Profile* profile_private = profile->GetPrimaryOTRProfile(); + Profile* profile_private = + profile->GetPrimaryOTRProfile(/*create_if_needed=*/true); const ui::ThemeProvider& tp = ThemeService::GetThemeProviderForProfile(profile); diff --git a/browser/themes/theme_properties.cc b/browser/themes/theme_properties.cc index 1f4b69bf167f..bc393eeeb239 100644 --- a/browser/themes/theme_properties.cc +++ b/browser/themes/theme_properties.cc @@ -15,7 +15,7 @@ const SkColor kLightToolbar = SkColorSetRGB(0xf3, 0xf3, 0xf3); const SkColor kLightFrame = SkColorSetRGB(0xd5, 0xd9, 0xdc); const SkColor kLightToolbarIcon = SkColorSetRGB(0x42, 0x42, 0x42); -base::Optional MaybeGetDefaultColorForBraveLightUi(int id) { +absl::optional MaybeGetDefaultColorForBraveLightUi(int id) { switch (id) { // Applies when the window is active, tabs and also tab bar everywhere // except active tab @@ -82,7 +82,7 @@ base::Optional MaybeGetDefaultColorForBraveLightUi(int id) { case BraveThemeProperties::COLOR_FOR_TEST: return BraveThemeProperties::kLightColorForTest; default: - return base::nullopt; + return absl::nullopt; } } @@ -90,7 +90,7 @@ const SkColor kDarkToolbar = SkColorSetRGB(0x30, 0x34, 0x43); const SkColor kDarkFrame = SkColorSetRGB(0x0C, 0x0C, 0x17); const SkColor kDarkToolbarIcon = SkColorSetRGB(0xed, 0xed, 0xed); -base::Optional MaybeGetDefaultColorForBraveDarkUi(int id) { +absl::optional MaybeGetDefaultColorForBraveDarkUi(int id) { switch (id) { // Applies when the window is active, tabs and also tab bar everywhere // except active tab @@ -159,14 +159,14 @@ base::Optional MaybeGetDefaultColorForBraveDarkUi(int id) { case BraveThemeProperties::COLOR_FOR_TEST: return BraveThemeProperties::kDarkColorForTest; default: - return base::nullopt; + return absl::nullopt; } } const SkColor kPrivateFrame = SkColorSetRGB(0x19, 0x16, 0x2F); const SkColor kPrivateToolbar = SkColorSetRGB(0x32, 0x25, 0x60); -base::Optional MaybeGetDefaultColorForPrivateUi(int id) { +absl::optional MaybeGetDefaultColorForPrivateUi(int id) { switch (id) { // Applies when the window is active, tabs and also tab bar everywhere // except active tab @@ -217,7 +217,7 @@ base::Optional MaybeGetDefaultColorForPrivateUi(int id) { const SkColor kPrivateTorFrame = SkColorSetRGB(0x19, 0x0E, 0x2A); const SkColor kPrivateTorToolbar = SkColorSetRGB(0x49, 0x2D, 0x58); -base::Optional MaybeGetDefaultColorForPrivateTorUi(int id) { +absl::optional MaybeGetDefaultColorForPrivateTorUi(int id) { switch (id) { // Applies when the window is active, tabs and also tab bar everywhere // except active tab @@ -269,9 +269,11 @@ bool IsBraveThemeProperties(int id) { } // namespace BraveThemeProperties // Returns a |nullopt| if the UI color is not handled by Brave. -base::Optional MaybeGetDefaultColorForBraveUi( - int id, bool incognito, - bool is_tor, dark_mode::BraveDarkModeType dark_mode) { +absl::optional MaybeGetDefaultColorForBraveUi( + int id, + bool incognito, + bool is_tor, + dark_mode::BraveDarkModeType dark_mode) { // Consistent (and stable) values across all themes switch (id) { case ThemeProperties::COLOR_TAB_THROBBER_SPINNING: @@ -297,5 +299,5 @@ base::Optional MaybeGetDefaultColorForBraveUi( default: NOTREACHED(); } - return base::nullopt; + return absl::nullopt; } diff --git a/browser/themes/theme_properties.h b/browser/themes/theme_properties.h index 611754fb13dc..8572f3dc5239 100644 --- a/browser/themes/theme_properties.h +++ b/browser/themes/theme_properties.h @@ -6,9 +6,9 @@ #ifndef BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ #define BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ -#include "base/optional.h" #include "brave/browser/themes/brave_dark_mode_utils.h" #include "brave/components/sidebar/buildflags/buildflags.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkColor.h" namespace BraveThemeProperties { @@ -49,8 +49,10 @@ bool IsBraveThemeProperties(int id); } // namespace BraveThemeProperties -base::Optional MaybeGetDefaultColorForBraveUi( - int id, bool incognito, - bool is_tor, dark_mode::BraveDarkModeType dark_mode); +absl::optional MaybeGetDefaultColorForBraveUi( + int id, + bool incognito, + bool is_tor, + dark_mode::BraveDarkModeType dark_mode); #endif // BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ diff --git a/browser/tor/tor_profile_manager.cc b/browser/tor/tor_profile_manager.cc index 19c93a1d9519..ab66290c8b6c 100644 --- a/browser/tor/tor_profile_manager.cc +++ b/browser/tor/tor_profile_manager.cc @@ -75,7 +75,8 @@ TorProfileManager::~TorProfileManager() { Profile* TorProfileManager::GetTorProfile(Profile* original_profile) { Profile* tor_profile = original_profile->GetOffTheRecordProfile( - Profile::OTRProfileID(tor::kTorProfileID)); + Profile::OTRProfileID::CreateFromProfileID(tor::kTorProfileID), + /*create_if_needed=*/true); const std::string context_id = tor_profile->UniqueId(); auto it = tor_profiles_.find(context_id); diff --git a/browser/touch_to_fill/android/internal/java/res/layout/touch_to_fill_header_item.xml b/browser/touch_to_fill/android/internal/java/res/layout/touch_to_fill_header_item.xml index ec5c2aa74974..0bddcd6a8ef7 100644 --- a/browser/touch_to_fill/android/internal/java/res/layout/touch_to_fill_header_item.xml +++ b/browser/touch_to_fill/android/internal/java/res/layout/touch_to_fill_header_item.xml @@ -13,12 +13,14 @@ android:layout_marginBottom="16dp" android:orientation="vertical"> - + app:srcCompat="@drawable/touch_to_fill_new_header_image" + android:visibility="gone" /> Settings - + Basics - + Advanced - + Enter VR - + General - + Sites - + Private - + Sharing - + Browser - + Screen Capture - + Content Suggestions - + Full screen site controls - + Sites - + Virtual Reality - + Updates - + Announcements - + Permission requests - + Price drop alerts + + Sign-in verifications + Unsupported - + Account - + You and Brave - + Sign in to Brave - + Sync and Brave services @@ -323,7 +326,7 @@ CHAR-LIMIT guidelines: Other Brave services - + Brave services @@ -342,7 +345,7 @@ CHAR-LIMIT guidelines: Preload pages for faster browsing and searching - Uses cookies to remember your preferences, even if you don't visit those pages + Preloads pages that Brave thinks you might visit. To do this, Brave may use cookies, if you allow cookies, and may encrypt and send pages through Brave to hide your identity from sites. Show suggestions for similar pages when a page can't be found @@ -371,18 +374,9 @@ CHAR-LIMIT guidelines: Automatically sends crash reports to Brave - - Cancel sync? - - - You can turn on sync anytime in settings - - - Cancel sync - - + Usage data @@ -411,7 +405,7 @@ CHAR-LIMIT guidelines: - + Search engine @@ -454,46 +448,46 @@ CHAR-LIMIT guidelines: On some websites, you can pay with above supported payment apps on your device. - + Add address - + Add card - + Edit card - + Country/Region - + Title - + Email - + Phone - + Name on card - + Card nickname - + Nickname can’t include numbers - + Cardholder name - + Card number - + Expiration date - + Billing address @@ -523,10 +517,10 @@ CHAR-LIMIT guidelines: - + Passwords - + Save passwords @@ -547,7 +541,7 @@ CHAR-LIMIT guidelines: Keep your passwords safe from data breaches and other security issues - + Never saved @@ -604,6 +598,9 @@ CHAR-LIMIT guidelines: Unmask password + + Show password + Delete password @@ -717,24 +714,12 @@ CHAR-LIMIT guidelines: Notifications - - Content suggestions - - - Based on your browsing history - - - From websites - - - Search and site suggestions disabled - - + Theme - + System default @@ -743,12 +728,12 @@ CHAR-LIMIT guidelines: Turn on dark theme when your device's dark theme or Battery Saver is on - + Darken websites - + Privacy and security @@ -815,6 +800,11 @@ Today, websites rely on many technologies, like third-party cookies, for importa Privacy Sandbox preserves the vitality of the open web by creating better ways to perform these services – without breaking sites, and while preventing you from being surreptitiously tracked across the web. Privacy Sandbox is still in active development and is available in selected regions. For now, sites may try out Privacy Sandbox while continuing to use current web technologies like third-party cookies. <link>Learn more</link> + + + With <link>Privacy Sandbox</link>, Brave is developing new technologies to safeguard you from cross-site tracking while preserving the open web. + +Privacy Sandbox trials are still in active development and are available in selected regions. For now, sites may try out Privacy Sandbox while continuing to use current web technologies like third-party cookies. Privacy Sandbox trials @@ -825,10 +815,35 @@ Privacy Sandbox is still in active development and is available in selected regi <li1>Advertisers can learn when thousands of users share a similar interest – like a crowd at a concert — and select ads for the crowd, rather than an individual profile.</li1> <li2>Advertisers can study the effectiveness of ads in a way that does not track you across sites.</li2> + + + When on, sites may use the privacy-preserving techniques shown here to provide their content and services. These include alternatives to cross-site tracking. More trials may be added over time. + +<li1>Advertisers and publishers can use FLoC.</li1> + +<li2>Advertisers and publishers can study the effectiveness of ads in a way that does not track you across sites.</li2> Learn about and control new technologies that aim to replace third-party cookies + + FLoC + + + This trial is active only in <link>some regions</link>. + + + Status + + + Group number + + + Next update + + + Reset group + @@ -871,7 +886,7 @@ Privacy Sandbox is still in active development and is available in selected regi Please verify that this is a valid provider or try again later - + Clear browsing data @@ -904,17 +919,20 @@ Your Brave account may have other forms of browsing history like searches and ac Clears history and autocompletions in the address bar. - Clears history from all signed-in devices. + Clears history from all synced devices. Clears history and autocompletions in the address bar. Your Brave sync chain may have other forms of browsing history at <link>myactivity.google.com</link>. - Clears history from all signed-in devices. Your Brave sync chain may have other forms of browsing history at <link>myactivity.google.com</link>. + Clears history from all synced devices. Your Brave sync chain may have other forms of browsing history at <link>myactivity.google.com</link>. To clear <link1>search</link1> or other forms of history, visit <link2>My Brave Activity</link2> + + Your search engine is %1$sBing. If applicable, see their instructions to delete your search history. + Saved passwords @@ -924,7 +942,7 @@ Your Brave account may have other forms of browsing history like searches and ac Clearing browsing data - + Clear data @@ -951,10 +969,10 @@ Your Brave account may have other forms of browsing history like searches and ac All time - + Also clear data from these sites? - + Also clear data from these sites & apps? @@ -983,7 +1001,7 @@ Your Brave account may have other forms of browsing history like searches and ac - + Safety check @@ -1074,7 +1092,7 @@ Your Brave account may have other forms of browsing history like searches and ac - + Safe Browsing @@ -1083,22 +1101,22 @@ Your Brave account may have other forms of browsing history like searches and ac Safe Browsing is off - + Safe Browsing - + Enhanced protection Faster, proactive protection against dangerous websites, downloads, and extensions. Warns you about password breaches. Requires browsing data to be sent to Brave. - + Standard protection Standard protection against websites, downloads, and extensions that are known to be dangerous. - + No protection (not recommended) @@ -1154,7 +1172,7 @@ Your Brave account may have other forms of browsing history like searches and ac - + Accessibility @@ -1186,31 +1204,31 @@ Your Brave account may have other forms of browsing history like searches and ac - + Languages - + %1$sBrave’s language - + Default device language - + Add language - + Change language - + Select language - + Suggested languages - + Other languages - + Content languages @@ -1225,7 +1243,7 @@ Your Brave account may have other forms of browsing history like searches and ac Offer to send pages in other languages to Brave Translate - + Offer to translate @@ -1246,25 +1264,28 @@ Your Brave account may have other forms of browsing history like searches and ac Loading %1$sHindi - - Downloading… + + %1$sहिन्दी - Downloading… + + + %1$sहिन्दी - Language ready, restart %2$sBrave. - - Language ready, restart %1$sBrave + + %1$sहिन्दी - This language couldn't be downloaded. Try again later. - + %1$sHindi is ready. - + Restart Brave - + Translation settings - + Advanced - + Translate into this language @@ -1441,9 +1462,6 @@ Your Brave account may have other forms of browsing history like searches and ac Bluetooth - - Wi-Fi - This file is large (%1$s300MB) @@ -1467,6 +1485,9 @@ Your Brave account may have other forms of browsing history like searches and ac Choose where to download + + Confirm download + Don‘t show again @@ -1529,7 +1550,7 @@ Your Brave account may have other forms of browsing history like searches and ac - + About Brave @@ -1549,10 +1570,7 @@ Your Brave account may have other forms of browsing history like searches and ac - - Add account - - + Signed in to Brave as @@ -1616,7 +1634,7 @@ Your Brave account may have other forms of browsing history like searches and ac - + Legal information @@ -1648,10 +1666,10 @@ Your Brave account may have other forms of browsing history like searches and ac - + Sign out and turn off sync? - + Clear your Brave data from this device? @@ -1702,70 +1720,73 @@ Your Brave account may have other forms of browsing history like searches and ac Tabs that you've opened in Brave on your other devices will appear here. - + Search and browse - + Syncing - + Sync everything - + Addresses and more - + Bookmarks - + History - + Passwords - + Open tabs - + Settings Payment methods and addresses using Brave Pay - + Encryption Manage synced data - + Encryption Encrypt synced passwords with your Brave sync chain - - Encrypt synced data with Brave password as of %1$sOct 3, 2014 - Encrypt synced data with your own sync passphrase Create passphrase - + Brave sync chain Passphrase encryption doesn’t include payment methods and addresses from Brave Pay. Only someone with your passphrase can read your encrypted data. The passphrase is not sent to or stored by Brave. If you forget your passphrase or want to change this setting you'll need to reset sync. <learnmore>Learn more</learnmore> - + Passphrase - + Confirm passphrase - + + Your data was encrypted with your <learnmore>sync passphrase</learnmore> on %1$sSept 1, 2012. Enter it to start sync. + + + Signed in as %1$sfoo@gmail.com. + + This field cannot be blank @@ -1779,13 +1800,13 @@ Your Brave account may have other forms of browsing history like searches and ac To change this setting, <resetlink>reset sync</resetlink> - + Incorrect passphrase - + Verifying… - + Loading… @@ -1840,6 +1861,9 @@ To change this setting, <resetlink>reset sync

<link>Get help</link> + + Brave needs permission to scan for nearby devices. <permission_link>Update permissions</permission_link>. + Connected Device @@ -1858,13 +1882,13 @@ To change this setting, <resetlink>reset sync

- + Sync isn't working - + Password sync isn't working - + Initial sync setup not finished @@ -1913,22 +1937,22 @@ To change this setting, <resetlink>reset sync

- + Sync has stopped working - + Please update your sign-in details. - + Could not connect to the sync server. - + %1$sBrave is out of date. - + The service is not available; try again later. - + Accept and sign in @@ -1942,14 +1966,14 @@ To change this setting, <resetlink>reset sync

Standard tabs - + Private tabs Switched to standard tabs - - Switched to private tabs + + Switched to Private tabs Reopen closed tab @@ -1985,7 +2009,7 @@ To change this setting, <resetlink>reset sync

Do you want to start downloading ^1specialfile.pdf again? - + Download @@ -2076,14 +2100,14 @@ To change this setting, <resetlink>reset sync

- + Translate… - + Print… - + Share… @@ -2101,7 +2125,7 @@ To change this setting, <resetlink>reset sync

View site information - + Web View @@ -2115,6 +2139,9 @@ To change this setting, <resetlink>reset sync

Use password + + Verify it’s you + @@ -2122,102 +2149,114 @@ To change this setting, <resetlink>reset sync

- + Open in other window - + + Open in new window + + Open in new tab - + Open in new tab in group - - Open in private tab + + Open in Private tab - + Call - + Copy - + Send message - + Add to contacts - + Copy link address - + Copy link text - + Download link - + Download image - + Open image - + Open image in new tab - + Preview image <new>New</new> - + Load image - + Copy image - + Search with Brave Lens <new>New</new> - + Search image with Brave Lens <new>New</new> - + Translate image with Brave Lens <new>New</new> - + Shop similar products <new>New</new> - + Shop image with Brave Lens <new>New</new> - + Search similar products <new>New</new> - + Search %1$sBrave for this image - + Share image - + Share link - + Download video - + Open in new Brave tab - - Open in private tab + + Open in Private tab - + Preview page <new>New</new> - + Read later <new>New</new> - + Fast page + + Share highlight + + + Remove highlight + + + Learn more... + @@ -2248,7 +2287,7 @@ To change this setting, <resetlink>reset sync

- + Open %1$sTelegram @@ -2318,13 +2357,13 @@ To change this setting, <resetlink>reset sync

- + Contents hidden - + Settings - + Manage @@ -2341,7 +2380,7 @@ To change this setting, <resetlink>reset sync

Waiting for another download… - + Private tab @@ -2368,7 +2407,7 @@ To change this setting, <resetlink>reset sync

%1$shttp://abc.com/test.pdf download failed due to an unknown error. - + Downloading… @@ -2558,13 +2597,19 @@ To change this setting, <resetlink>reset sync

Search your history + + History isn’t saved in Private + + + Brave doesn’t save your browsing history when you choose to browse privately. You can still use bookmarks to access your favorite sites. + - + Private Tabs - - Close all private tabs + + Close all Private tabs @@ -2597,7 +2642,7 @@ To change this setting, <resetlink>reset sync

Help make Brave better by sending usage statistics and crash reports to Brave. - + Accept & continue @@ -2614,24 +2659,9 @@ To change this setting, <resetlink>reset sync

Add account to device - - Open a Private tab - - - Waiting for Google Play Services to finish updating - - - - - Use Private to sign in - - -In Private, your activity <b1>might still be visible </b1>to websites that you visit, your employer or school, and your internet service provider. -Data from your Private session will only be cleared from Brave when you <b2>close all Private tabs</b2>. - - + Turn on sync? @@ -2646,10 +2676,10 @@ Data from your Private session will only be cleared from Brave when you You can always choose what to sync in <LINK1>settings</LINK1>. - + Yes, I'm in - + Choose an account @@ -2719,12 +2749,12 @@ Data from your Private session will only be cleared from Brave when you - + Brave does not have access to the requested resource. - + Recent tabs @@ -2736,9 +2766,6 @@ Data from your Private session will only be cleared from Brave when you Item removed - - Item removed: %1$sPrime minister announces new health care plans - Brave doodle: %1$sEinstein’s birthday @@ -2797,13 +2824,13 @@ Data from your Private session will only be cleared from Brave when you - Control your Brave accounts data + Control your Brave sync chain data Interests - Manage the topics that you're interested in + Manage the topics you're interested in Hidden @@ -2815,7 +2842,13 @@ Data from your Private session will only be cleared from Brave when you - Manage the sites that you're following + Manage the sites you follow + + + Following + + + Updates Unavailable Turn off @@ -2837,6 +2870,9 @@ Data from your Private session will only be cleared from Brave when you For you Following + + Unread stories ready + Control your stories and activity here @@ -2952,96 +2988,129 @@ Data from your Private session will only be cleared from Brave when you New tab - - New private tab + + New Private tab From <pub>%1$s</pub>example.com<bg>delivered by Brave</bg> + + New tab + + + Share + + + Voice search + + + Based on your usage + + + Current recommendation: %1$sNew tab + + + Toolbar shortcut + + + Quickly open a new tab. To edit this shortcut, touch and hold. + + + Quickly share this page. To edit this shortcut, touch and hold. + + + Quickly search with your voice. To edit this shortcut, touch and hold. + + + Edit shortcut + - + Update Brave - + Newer version is available - + Brave can’t update - + Android version is unsupported - + Downloading… - + Couldn’t download - + Update ready - + Restart Brave - + + New window + + Move to other window - + Forward - + Bookmark - + Download - + Page info - + Refresh - + Stop refreshing - + New tab - - New private tab + + New Private tab - + Bookmarks - + Recent tabs - + History - + Downloads - + Find in page - + Follow - + Following - + Request desktop site - + Request mobile site - + Show Paint Preview - + Desktop site @@ -3050,33 +3119,33 @@ Data from your Private session will only be cleared from Brave when you Turn on Request desktop site - + Appearance - + Settings - + Close all tabs - - Close private tabs + + Close Private tabs - + Group tabs - + Track prices - + Get image descriptions - + Stop image descriptions - + Bookmarks @@ -3090,55 +3159,55 @@ Data from your Private session will only be cleared from Brave when you %1$d1 bookmark} other {%1$d8 bookmarks}} - + Bookmarked in %1$sBrave - + Bookmarked - + Bookmarked to %1$sMobile bookmarks Failed to add bookmark. - + Parent folder - + Select - + Edit - + Move to… - + Delete - + Show in folder - + New folder… - + Choose folder - + Edit folder - + Move bookmarks - + Delete bookmarks - + Close dialog - + Search your bookmarks @@ -3159,28 +3228,28 @@ Data from your Private session will only be cleared from Brave when you List of bookmark folders is closed - + Edit bookmark - + Add folder - + Edit folder - + Name - + URL - + Folder - + Title required - + URL required @@ -3194,7 +3263,7 @@ Data from your Private session will only be cleared from Brave when you Unread - Available offline - + Added to reading list @@ -3234,14 +3303,6 @@ Data from your Private session will only be cleared from Brave when you - - View offline in %1$sBrave - - - - www.example.com%1$s and more sites - - {NUM_IN_PROGRESS, plural, =1 {Brave will load your page when ready} @@ -3284,37 +3345,37 @@ Data from your Private session will only be cleared from Brave when you - + Offline - + Preview - + No enabled voice search available Tab opened in background. - + Open in Brave - + Open in Private Brave - + Open in %1$sBrave - + Open in browser Show simplified view - + Bookmarks and web history @@ -3338,14 +3399,14 @@ Data from your Private session will only be cleared from Brave when you New tab - - New private tab + + New Private tab New tab - - New private tab + + New Private tab Private mode @@ -3380,11 +3441,11 @@ Data from your Private session will only be cleared from Brave when you New tab - - Enter private mode + + Enter Private mode - - Leave private mode + + Leave Private mode Tab @@ -3392,10 +3453,10 @@ Data from your Private session will only be cleared from Brave when you Selected Tab - + Private Tab - + Selected Private Tab @@ -3643,6 +3704,18 @@ Data from your Private session will only be cleared from Brave when you Refollow + + You’re following %1$sBrave + + + You’ll now see stories from %1$sBrave when you open a new tab. You can control the sites you’re following in Manage Follows. + + + Soon, you’ll see stories from %1$sBrave when you open a new tab. You can control the sites you’re following in Manage Follows. + + + Open a new tab + @@ -3651,10 +3724,10 @@ Data from your Private session will only be cleared from Brave when you Stored data that Brave doesn't think is important (e.g. sites with no saved settings or that you don't visit often) - + Unimportant data - + Free up space @@ -3663,22 +3736,22 @@ Data from your Private session will only be cleared from Brave when you All data stored by sites, including cookies and other locally stored data - + Computing… - + Unknown - + Site storage - + Manage Total data used by Brave, including accounts, bookmarks, and saved settings - + Clear All Data @@ -3780,63 +3853,69 @@ Data from your Private session will only be cleared from Brave when you Apps + + Uninstall + + + Site settings + - + Open a new tab - + Reopen the last closed tab - + Open a new tab in Private mode - + Open the menu - + Jump to the next tab - + Jump to the previous tab - + Close current tab - + Open the Find Bar - + Jump to the address bar - + Open the bookmarks manager - + Bookmark the current page - + Open the history page - + Open options to print page - + Make everything on the page bigger - + Make everything on the page smaller - + Return everything on the page to default size - + Reload the current page - + Reload the current page, ignoring cached content - + Open the Brave Help Center in a new tab @@ -3856,7 +3935,7 @@ Data from your Private session will only be cleared from Brave when you Brave is still preparing for VR. Restart Brave later. - + Something went wrong. @@ -3956,6 +4035,9 @@ Data from your Private session will only be cleared from Brave when you Translate this page to any language from the More options button + + New: share a link that scrolls to this text + @@ -3978,7 +4060,7 @@ Data from your Private session will only be cleared from Brave when you - + Remove and recreate this shortcut @@ -4152,7 +4234,7 @@ Data from your Private session will only be cleared from Brave when you - + Brave Assistant in Brave @@ -4264,6 +4346,10 @@ Data from your Private session will only be cleared from Brave when you + + Place your phone close to the computer + + Connected to device @@ -4292,6 +4378,14 @@ Data from your Private session will only be cleared from Brave when you + + Your computer wants to register this device for signing in to a site + + + + Your computer wants to use this device to sign in to a site + + QR Code @@ -4350,10 +4444,34 @@ Data from your Private session will only be cleared from Brave when you + + Drag to take a long screenshot + + + + Can\u2019t go higher. Try starting from further up the page. + + + + Can\u2019t go lower. Try starting from further down the page. + + + + Can\u2019t extend screenshot. Try again when your phone isn\u2019t busy. + + + + Something went wrong. Try again. + + Link to highlight + + Stylize highlight + + Copied @@ -4473,17 +4591,20 @@ Data from your Private session will only be cleared from Brave when you - Displaying Paint Preview. Press back to exit the Paint Preview demo. + Displaying Paint Preview. Paint Preview playback failed. + + Paint Preview does not have accessibility support. + Previewing this page - + Reload @@ -4531,7 +4652,7 @@ Data from your Private session will only be cleared from Brave when you Get descriptions - + Image descriptions @@ -4597,6 +4718,9 @@ Data from your Private session will only be cleared from Brave when you Ad + + Results from\n%1$s + diff --git a/browser/ui/android/strings/android_chrome_strings_override.grd b/browser/ui/android/strings/android_chrome_strings_override.grd index 856498a4601c..cd2ecd3b45ba 100644 --- a/browser/ui/android/strings/android_chrome_strings_override.grd +++ b/browser/ui/android/strings/android_chrome_strings_override.grd @@ -10,7 +10,7 @@ FAQ: - Tell me more, please? Ok: http://www.chromium.org/developers/design-documents/ui-localization -CHAR-LIMIT guidelines: +CHAR_LIMIT guidelines: Certain strings need character limits to prevent a long translation from breaking the UI. Translators will ensure the translation fits within the limit, but may be forced to use odd abbreviations to do so. There is a tradeoff here, so only use character limits when they're @@ -20,7 +20,7 @@ CHAR-LIMIT guidelines: translation will be cut off. On the other hand, an error message that can wrap over multiple lines doesn't need a limit. - * Most strings - No limit. Omit "[CHAR-LIMIT=...]" altogether. + * Most strings - No limit. Omit "[CHAR_LIMIT=...]" altogether. * Main menu items - 27, or 24 characters if it has a checkbox * Settings headers - 32 characters * Settings items - 32 characters @@ -113,12 +113,13 @@ CHAR-LIMIT guidelines: - + Private Automatically sends crash reports to Brave + When enabled, sites may use the privacy-preserving techniques shown here to provide their content and services. These include alternatives to cross-site tracking. More trials may be added over time. @@ -129,74 +130,66 @@ CHAR-LIMIT guidelines: When Lite mode is on, Brave uses Brave servers to make pages load faster. Lite mode rewrites very slow pages to load only essential content. Lite mode does not apply to Private tabs. - + Private tabs - - Switched to private tabs + + Switched to Private tabs - - Open in private tab + + Open in Private tab - - Open in private tab + + Open in Private tab - + Private tab - - Private Tabs - - - Close all private tabs + + History isn’t saved in Private - - - Open a Private tab + + Private Tabs - - Use Private to sign in + + Close all Private tabs - -In Private, your activity <b1>might still be visible </b1>to websites that you visit, your employer or school, and your internet service provider. -Data from your Private session will only be cleared from Brave when you <b2>close all Private tabs</b2>. - - - New private tab + + New Private tab - - New private tab + + New Private tab - - Close private tabs + + Close Private tabs - + Open in Private Brave - - New private tab + + New Private tab - - New private tab + + New Private tab Private mode - - Enter private mode + + Enter Private mode - - Leave private mode + + Leave Private mode - + Private Tab - + Selected Private Tab - + Open a new tab in Private mode diff --git a/browser/ui/android/toolbar/java/res/layout/tab_switcher_toolbar.xml b/browser/ui/android/toolbar/java/res/layout/tab_switcher_toolbar.xml index f49824ac3c17..069ba0402359 100644 --- a/browser/ui/android/toolbar/java/res/layout/tab_switcher_toolbar.xml +++ b/browser/ui/android/toolbar/java/res/layout/tab_switcher_toolbar.xml @@ -6,10 +6,12 @@ + android:clickable="true" + android:focusable="true" > + android:visibility="gone" + tools:ignore="UseSwitchCompatOrMaterialXml"/> diff --git a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc index 54b6ec171547..a1798dcdc5d9 100644 --- a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc +++ b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc @@ -9,9 +9,9 @@ #include "base/strings/utf_string_conversions.h" #include "cc/paint/paint_flags.h" -#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" #include "chrome/grit/theme_resources.h" #include "extensions/common/constants.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" @@ -22,19 +22,19 @@ #include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/skia_paint_util.h" -base::Optional +absl::optional BraveActionIconWithBadgeImageSource::GetCustomGraphicSize() { return kBraveActionGraphicSize; } -base::Optional +absl::optional BraveActionIconWithBadgeImageSource::GetCustomGraphicXOffset() { return std::floor( (size().width() - kBraveActionRightMargin - kBraveActionGraphicSize) / 2.0); } -base::Optional +absl::optional BraveActionIconWithBadgeImageSource::GetCustomGraphicYOffset() { return std::floor((size().height() - kBraveActionGraphicSize) / 2.0); } diff --git a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h index 39656536b24b..491306839274 100644 --- a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h +++ b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* 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/. */ @@ -8,23 +9,24 @@ #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h" namespace gfx { - class Canvas; - class Rect; +class Canvas; +class Rect; } // The purpose of this subclass is to: // - Paint the BraveAction badge in a custom location and with a different size // to regular BrowserAction extensions. class BraveActionIconWithBadgeImageSource : public IconWithBadgeImageSource { - public: - using IconWithBadgeImageSource::IconWithBadgeImageSource; - private: - base::Optional GetCustomGraphicSize() override; - base::Optional GetCustomGraphicXOffset() override; - base::Optional GetCustomGraphicYOffset() override; - void PaintBadge(gfx::Canvas* canvas) override; - gfx::Rect GetIconAreaRect() const override; - DISALLOW_COPY_AND_ASSIGN(BraveActionIconWithBadgeImageSource); + public: + using IconWithBadgeImageSource::IconWithBadgeImageSource; + + private: + absl::optional GetCustomGraphicSize() override; + absl::optional GetCustomGraphicXOffset() override; + absl::optional GetCustomGraphicYOffset() override; + void PaintBadge(gfx::Canvas* canvas) override; + gfx::Rect GetIconAreaRect() const override; + DISALLOW_COPY_AND_ASSIGN(BraveActionIconWithBadgeImageSource); }; -#endif +#endif // BRAVE_BROWSER_UI_BRAVE_ACTIONS_BRAVE_ACTION_ICON_WITH_BADGE_IMAGE_SOURCE_H_ diff --git a/browser/ui/brave_actions/brave_action_view_controller.cc b/browser/ui/brave_actions/brave_action_view_controller.cc index eca009f86d43..0fd556c29b54 100644 --- a/browser/ui/brave_actions/brave_action_view_controller.cc +++ b/browser/ui/brave_actions/brave_action_view_controller.cc @@ -9,18 +9,26 @@ #include #include -#include "brave/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h" +#include "base/memory/ptr_util.h" #include "brave/browser/profiles/profile_util.h" +#include "brave/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h" #include "chrome/browser/extensions/extension_view_host.h" #include "chrome/browser/extensions/extension_view_host_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/extensions/extensions_container.h" #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" #include "components/sessions/content/session_tab_helper.h" #include "components/vector_icons/vector_icons.h" #include "extensions/browser/extension_action.h" +#include "extensions/browser/extension_action_manager.h" +#include "extensions/browser/extension_registry.h" +#include "extensions/common/api/extension_action/action_info.h" #include "extensions/common/constants.h" +#include "extensions/common/extension.h" +#include "extensions/common/manifest_constants.h" +#include "extensions/common/permissions/api_permission.h" #include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/canvas_image_source.h" @@ -28,6 +36,40 @@ #include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/scoped_canvas.h" +// static +std::unique_ptr BraveActionViewController::Create( + const extensions::ExtensionId& extension_id, + Browser* browser, + ExtensionsContainer* extensions_container) { + DCHECK(browser); + + auto* registry = extensions::ExtensionRegistry::Get(browser->profile()); + scoped_refptr extension = + registry->enabled_extensions().GetByID(extension_id); + DCHECK(extension); + extensions::ExtensionAction* extension_action = + extensions::ExtensionActionManager::Get(browser->profile()) + ->GetExtensionAction(*extension); + DCHECK(extension_action); + + // WrapUnique() because the constructor is private. + return base::WrapUnique(new BraveActionViewController( + std::move(extension), browser, extension_action, registry, + extensions_container)); +} + +BraveActionViewController::BraveActionViewController( + scoped_refptr extension, + Browser* browser, + extensions::ExtensionAction* extension_action, + extensions::ExtensionRegistry* extension_registry, + ExtensionsContainer* extensions_container) + : ExtensionActionViewController(std::move(extension), + browser, + extension_action, + extension_registry, + extensions_container) {} + bool BraveActionViewController::IsEnabled( content::WebContents* web_contents) const { bool is_enabled = ExtensionActionViewController::IsEnabled(web_contents); @@ -37,11 +79,6 @@ bool BraveActionViewController::IsEnabled( return is_enabled; } -bool BraveActionViewController::DisabledClickOpensMenu() const { - // disabled is a per-tab state - return false; -} - ui::MenuModel* BraveActionViewController::GetContextMenu() { // no context menu for brave actions button return nullptr; @@ -75,13 +112,14 @@ bool BraveActionViewController::TriggerPopupWithUrl( return false; popup_host_ = host.get(); - popup_host_observer_.Add(popup_host_); + popup_host_observation_.Observe(popup_host_); ShowPopup(std::move(host), grant_tab_permissions, show_action); return true; } void BraveActionViewController::OnPopupClosed() { - popup_host_observer_.Remove(popup_host_); + DCHECK(popup_host_observation_.IsObservingSource(popup_host_)); + popup_host_observation_.Reset(); popup_host_ = nullptr; view_delegate_->OnPopupClosed(); } @@ -116,6 +154,5 @@ BraveActionViewController::GetIconImageSource( // If the extension doesn't want to run on the active web contents, we // grayscale it to indicate that. image_source->set_grayscale(!IsEnabled(web_contents)); - image_source->set_paint_page_action_decoration(false); return image_source; } diff --git a/browser/ui/brave_actions/brave_action_view_controller.h b/browser/ui/brave_actions/brave_action_view_controller.h index 690cef3e4299..69eb22cb2fb9 100644 --- a/browser/ui/brave_actions/brave_action_view_controller.h +++ b/browser/ui/brave_actions/brave_action_view_controller.h @@ -10,8 +10,13 @@ #include #include "chrome/browser/ui/extensions/extension_action_view_controller.h" +#include "extensions/common/extension_id.h" class BraveActionIconWithBadgeImageSource; +class Browser; +class ExtensionAction; +class ExtensionRegistry; +class ExtensionsContainer; class ToolbarActionViewController; namespace ui { @@ -25,26 +30,38 @@ class MenuModel; // - Remove the context menu from the button since we do not allow uninstall class BraveActionViewController : public ExtensionActionViewController { public: - using ExtensionActionViewController::ExtensionActionViewController; - bool IsEnabled(content::WebContents* web_contents) const override; - gfx::Image GetIcon(content::WebContents* web_contents, - const gfx::Size& size) override; - bool DisabledClickOpensMenu() const override; - ui::MenuModel* GetContextMenu() override; - bool ExecuteActionUI(std::string relative_path); - ToolbarActionViewController* GetExtensionViewController( - const std::string& extension_id); + static std::unique_ptr Create( + const extensions::ExtensionId& extension_id, + Browser* browser, + ExtensionsContainer* extensions_container); + + bool IsEnabled(content::WebContents* web_contents) const override; + gfx::Image GetIcon(content::WebContents* web_contents, + const gfx::Size& size) override; + ui::MenuModel* GetContextMenu() override; + bool ExecuteActionUI(std::string relative_path); + ToolbarActionViewController* GetExtensionViewController( + const std::string& extension_id); + private: - ExtensionActionViewController* GetPreferredPopupViewController() override; - bool TriggerPopupWithUrl(PopupShowAction show_action, + // New instances should be instantiated with Create(). + BraveActionViewController( + scoped_refptr extension, + Browser* browser, + extensions::ExtensionAction* extension_action, + extensions::ExtensionRegistry* extension_registry, + ExtensionsContainer* extensions_container); + + ExtensionActionViewController* GetPreferredPopupViewController() override; + bool TriggerPopupWithUrl(PopupShowAction show_action, const GURL& popup_url, bool grant_tab_permissions) override; - void OnPopupClosed() override; - // Returns the image source for the icon. - std::unique_ptr GetIconImageSource( - content::WebContents* web_contents, - const gfx::Size& size); - DISALLOW_COPY_AND_ASSIGN(BraveActionViewController); + void OnPopupClosed() override; + // Returns the image source for the icon. + std::unique_ptr GetIconImageSource( + content::WebContents* web_contents, + const gfx::Size& size); + DISALLOW_COPY_AND_ASSIGN(BraveActionViewController); }; #endif // BRAVE_BROWSER_UI_BRAVE_ACTIONS_BRAVE_ACTION_VIEW_CONTROLLER_H_ diff --git a/browser/ui/brave_ads/ad_notification_control_buttons_view.cc b/browser/ui/brave_ads/ad_notification_control_buttons_view.cc index ff47e2ee7cef..c56e005a1252 100644 --- a/browser/ui/brave_ads/ad_notification_control_buttons_view.cc +++ b/browser/ui/brave_ads/ad_notification_control_buttons_view.cc @@ -14,13 +14,13 @@ #include "brave/browser/ui/brave_ads/padded_image_view.h" #include "brave/grit/brave_generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/layer.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/native_theme/native_theme.h" #include "ui/views/background.h" #include "ui/views/layout/box_layout.h" -#include "ui/views/metadata/metadata_impl_macros.h" namespace brave_ads { diff --git a/browser/ui/brave_ads/ad_notification_control_buttons_view.h b/browser/ui/brave_ads/ad_notification_control_buttons_view.h index e6c3ba7ab7a3..40fb920e48bd 100644 --- a/browser/ui/brave_ads/ad_notification_control_buttons_view.h +++ b/browser/ui/brave_ads/ad_notification_control_buttons_view.h @@ -6,7 +6,7 @@ #ifndef BRAVE_BROWSER_UI_BRAVE_ADS_AD_NOTIFICATION_CONTROL_BUTTONS_VIEW_H_ #define BRAVE_BROWSER_UI_BRAVE_ADS_AD_NOTIFICATION_CONTROL_BUTTONS_VIEW_H_ -#include "ui/views/metadata/metadata_header_macros.h" +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/view.h" namespace views { diff --git a/browser/ui/brave_ads/ad_notification_header_view.cc b/browser/ui/brave_ads/ad_notification_header_view.cc index d9667f3042b5..e34dcee595d1 100644 --- a/browser/ui/brave_ads/ad_notification_header_view.cc +++ b/browser/ui/brave_ads/ad_notification_header_view.cc @@ -14,6 +14,7 @@ #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/font_list.h" #include "ui/gfx/geometry/insets.h" @@ -22,7 +23,6 @@ #include "ui/views/border.h" #include "ui/views/controls/label.h" #include "ui/views/layout/flex_layout.h" -#include "ui/views/metadata/metadata_impl_macros.h" namespace brave_ads { diff --git a/browser/ui/brave_ads/ad_notification_header_view.h b/browser/ui/brave_ads/ad_notification_header_view.h index 47c53c357170..35c0ad8c943c 100644 --- a/browser/ui/brave_ads/ad_notification_header_view.h +++ b/browser/ui/brave_ads/ad_notification_header_view.h @@ -6,8 +6,8 @@ #ifndef BRAVE_BROWSER_UI_BRAVE_ADS_AD_NOTIFICATION_HEADER_VIEW_H_ #define BRAVE_BROWSER_UI_BRAVE_ADS_AD_NOTIFICATION_HEADER_VIEW_H_ +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/gfx/text_constants.h" -#include "ui/views/metadata/metadata_header_macros.h" #include "ui/views/view.h" namespace views { diff --git a/browser/ui/brave_ads/ad_notification_popup.cc b/browser/ui/brave_ads/ad_notification_popup.cc index 49c61f8a7e2c..6ce49c27ba69 100644 --- a/browser/ui/brave_ads/ad_notification_popup.cc +++ b/browser/ui/brave_ads/ad_notification_popup.cc @@ -21,6 +21,8 @@ #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/compositor/layer.h" #include "ui/display/screen.h" #include "ui/gfx/animation/linear_animation.h" #include "ui/gfx/animation/tween.h" @@ -36,7 +38,6 @@ #include "ui/gfx/skia_paint_util.h" #include "ui/native_theme/native_theme.h" #include "ui/views/layout/box_layout.h" -#include "ui/views/metadata/metadata_impl_macros.h" #include "ui/views/widget/widget.h" #if defined(OS_WIN) diff --git a/browser/ui/brave_ads/ad_notification_popup.h b/browser/ui/brave_ads/ad_notification_popup.h index 8ee283b4b6fb..f34ca8d0b245 100644 --- a/browser/ui/brave_ads/ad_notification_popup.h +++ b/browser/ui/brave_ads/ad_notification_popup.h @@ -12,9 +12,9 @@ #include "base/scoped_observation.h" #include "brave/browser/ui/brave_ads/ad_notification.h" +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/display/display_observer.h" #include "ui/gfx/animation/animation_delegate.h" -#include "ui/views/metadata/metadata_header_macros.h" #include "ui/views/widget/widget_delegate.h" #include "ui/views/widget/widget_observer.h" diff --git a/browser/ui/brave_ads/ad_notification_view.cc b/browser/ui/brave_ads/ad_notification_view.cc index a3bb4118ede8..b5604d47866b 100644 --- a/browser/ui/brave_ads/ad_notification_view.cc +++ b/browser/ui/brave_ads/ad_notification_view.cc @@ -13,10 +13,11 @@ #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/compositor/layer.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/vector2d.h" #include "ui/native_theme/native_theme.h" -#include "ui/views/metadata/metadata_impl_macros.h" #include "ui/views/view.h" namespace brave_ads { diff --git a/browser/ui/brave_ads/ad_notification_view.h b/browser/ui/brave_ads/ad_notification_view.h index 44093b496048..d88c0e99cf9d 100644 --- a/browser/ui/brave_ads/ad_notification_view.h +++ b/browser/ui/brave_ads/ad_notification_view.h @@ -7,8 +7,8 @@ #define BRAVE_BROWSER_UI_BRAVE_ADS_AD_NOTIFICATION_VIEW_H_ #include "brave/browser/ui/brave_ads/ad_notification.h" -#include "ui/views/animation/ink_drop_host_view.h" -#include "ui/views/metadata/metadata_header_macros.h" +#include "ui/base/metadata/metadata_header_macros.h" +#include "ui/views/view.h" namespace gfx { class Canvas; @@ -17,7 +17,7 @@ class Point; namespace brave_ads { -class AdNotificationView : public views::InkDropHostView { +class AdNotificationView : public views::View { public: METADATA_HEADER(AdNotificationView); @@ -29,7 +29,7 @@ class AdNotificationView : public views::InkDropHostView { void OnCloseButtonPressed(); - // views::InkDropHostView: + // views::View: void GetAccessibleNodeData(ui::AXNodeData* node_data) override; bool OnMousePressed(const ui::MouseEvent& event) override; bool OnMouseDragged(const ui::MouseEvent& event) override; diff --git a/browser/ui/brave_ads/padded_image_button.cc b/browser/ui/brave_ads/padded_image_button.cc index 553b1c6e394f..24043993295f 100644 --- a/browser/ui/brave_ads/padded_image_button.cc +++ b/browser/ui/brave_ads/padded_image_button.cc @@ -8,6 +8,7 @@ #include #include +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/geometry/insets.h" @@ -16,7 +17,6 @@ #include "ui/views/animation/ink_drop_impl.h" #include "ui/views/background.h" #include "ui/views/border.h" -#include "ui/views/metadata/metadata_impl_macros.h" namespace brave_ads { @@ -36,14 +36,18 @@ const float kVisibleOpacity = 0.12f; PaddedImageButton::PaddedImageButton(PressedCallback callback) : views::ImageButton(callback) { + views::InkDrop::UseInkDropForSquareRipple(ink_drop(), + /*highlight_on_hover=*/false, + /*highlight_on_focus=*/false); + SetBackground(views::CreateSolidBackground(kBackgroundColor)); SetBorder(views::CreateEmptyBorder(kBorderInset)); SetAnimateOnStateChange(false); - SetInkDropMode(InkDropMode::ON); - SetInkDropVisibleOpacity(kVisibleOpacity); + ink_drop()->SetMode(views::InkDropHost::InkDropMode::ON); + ink_drop()->SetVisibleOpacity(kVisibleOpacity); SetHasInkDropActionOnClick(true); } @@ -60,19 +64,13 @@ void PaddedImageButton::AdjustBorderInsetToFitHeight(const int height) { SetBorder(views::CreateEmptyBorder(insets)); } -std::unique_ptr PaddedImageButton::CreateInkDrop() { - std::unique_ptr ink_drop = CreateDefaultInkDropImpl(); - ink_drop->SetShowHighlightOnHover(false); - ink_drop->SetShowHighlightOnFocus(false); - return std::move(ink_drop); -} - void PaddedImageButton::OnThemeChanged() { ImageButton::OnThemeChanged(); const SkColor background_color = GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_WindowBackground); - SetInkDropBaseColor(color_utils::GetColorWithMaxContrast(background_color)); + ink_drop()->SetBaseColor( + color_utils::GetColorWithMaxContrast(background_color)); } BEGIN_METADATA(PaddedImageButton, views::ImageButton) diff --git a/browser/ui/brave_ads/padded_image_button.h b/browser/ui/brave_ads/padded_image_button.h index 60c36fda81a0..88f8c7fc21b4 100644 --- a/browser/ui/brave_ads/padded_image_button.h +++ b/browser/ui/brave_ads/padded_image_button.h @@ -8,8 +8,8 @@ #include +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/controls/button/image_button.h" -#include "ui/views/metadata/metadata_header_macros.h" namespace views { class InkDrop; @@ -30,9 +30,6 @@ class PaddedImageButton : public views::ImageButton { void AdjustBorderInsetToFitHeight(const int height); - // views::InkDropHostView: - std::unique_ptr CreateInkDrop() override; - // views::Button: void OnThemeChanged() override; diff --git a/browser/ui/brave_ads/padded_image_view.cc b/browser/ui/brave_ads/padded_image_view.cc index a81d65ae1eb8..f5af066075e4 100644 --- a/browser/ui/brave_ads/padded_image_view.cc +++ b/browser/ui/brave_ads/padded_image_view.cc @@ -5,11 +5,11 @@ #include "brave/browser/ui/brave_ads/padded_image_view.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/geometry/insets.h" #include "ui/views/background.h" #include "ui/views/border.h" -#include "ui/views/metadata/metadata_impl_macros.h" namespace brave_ads { diff --git a/browser/ui/brave_ads/padded_image_view.h b/browser/ui/brave_ads/padded_image_view.h index eecf94f2f737..027704c95cb8 100644 --- a/browser/ui/brave_ads/padded_image_view.h +++ b/browser/ui/brave_ads/padded_image_view.h @@ -6,8 +6,8 @@ #ifndef BRAVE_BROWSER_UI_BRAVE_ADS_PADDED_IMAGE_VIEW_H_ #define BRAVE_BROWSER_UI_BRAVE_ADS_PADDED_IMAGE_VIEW_H_ +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/controls/image_view.h" -#include "ui/views/metadata/metadata_header_macros.h" namespace brave_ads { diff --git a/browser/ui/brave_browser.cc b/browser/ui/brave_browser.cc index ff87796b8ecf..5bddc22a420a 100644 --- a/browser/ui/brave_browser.cc +++ b/browser/ui/brave_browser.cc @@ -4,6 +4,10 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "brave/browser/ui/brave_browser.h" +#include "chrome/browser/search/search.h" +#include "chrome/common/webui_url_constants.h" +#include "content/public/common/url_constants.h" +#include "url/gurl.h" #if BUILDFLAG(ENABLE_SIDEBAR) #include "brave/browser/ui/brave_browser_window.h" @@ -49,6 +53,29 @@ void BraveBrowser::ScheduleUIUpdate(content::WebContents* source, #endif } +bool BraveBrowser::ShouldDisplayFavicon( + content::WebContents* web_contents) const { + // Override to not show favicon for NTP in tab. + + // Suppress the icon for the new-tab page, even if a navigation to it is + // not committed yet. Note that we're looking at the visible URL, so + // navigations from NTP generally don't hit this case and still show an icon. + GURL url = web_contents->GetVisibleURL(); + if (url.SchemeIs(content::kChromeUIScheme) && + url.host_piece() == chrome::kChromeUINewTabHost) { + return false; + } + + // Also suppress instant-NTP. This does not use search::IsInstantNTP since + // it looks at the last-committed entry and we need to show icons for pending + // navigations away from it. + if (search::IsInstantNTPURL(url, profile())) { + return false; + } + + return Browser::ShouldDisplayFavicon(web_contents); +} + void BraveBrowser::OnTabStripModelChanged( TabStripModel* tab_strip_model, const TabStripModelChange& change, diff --git a/browser/ui/brave_browser.h b/browser/ui/brave_browser.h index 7c15489bc191..3c3d333165e5 100644 --- a/browser/ui/brave_browser.h +++ b/browser/ui/brave_browser.h @@ -19,6 +19,10 @@ class SidebarController; class BraveBrowserWindow; #endif +namespace content { +class WebContents; +} // namespace content + class BraveBrowser : public Browser { public: explicit BraveBrowser(const CreateParams& params); @@ -30,6 +34,7 @@ class BraveBrowser : public Browser { // Browser overrides: void ScheduleUIUpdate(content::WebContents* source, unsigned changed_flags) override; + bool ShouldDisplayFavicon(content::WebContents* web_contents) const override; void OnTabStripModelChanged( TabStripModel* tab_strip_model, const TabStripModelChange& change, diff --git a/browser/ui/brave_browser_browsertest.cc b/browser/ui/brave_browser_browsertest.cc new file mode 100644 index 000000000000..39b6ecf51c4c --- /dev/null +++ b/browser/ui/brave_browser_browsertest.cc @@ -0,0 +1,20 @@ +/* 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/. */ + +#include "brave/browser/ui/brave_browser.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/ui_test_utils.h" +#include "content/public/test/browser_test.h" + +using BraveBrowserBrowserTest = InProcessBrowserTest; + +IN_PROC_BROWSER_TEST_F(BraveBrowserBrowserTest, NTPFaviconTest) { + ui_test_utils::NavigateToURL(browser(), GURL("brave://newtab/")); + + auto* tab_model = browser()->tab_strip_model(); + EXPECT_FALSE( + browser()->ShouldDisplayFavicon(tab_model->GetActiveWebContents())); +} diff --git a/browser/ui/brave_layout_constants.cc b/browser/ui/brave_layout_constants.cc index c59740c84818..47234960987f 100644 --- a/browser/ui/brave_layout_constants.cc +++ b/browser/ui/brave_layout_constants.cc @@ -9,7 +9,7 @@ #include "ui/base/pointer/touch_ui_controller.h" // Returns a |nullopt| if the UI color is not handled by Brave. -base::Optional GetBraveLayoutConstant(LayoutConstant constant) { +absl::optional GetBraveLayoutConstant(LayoutConstant constant) { const bool touch = ui::TouchUiController::Get()->touch_ui(); // const bool hybrid = mode == ui::MaterialDesignController::MATERIAL_HYBRID; // const bool touch_optimized_material = @@ -23,5 +23,5 @@ base::Optional GetBraveLayoutConstant(LayoutConstant constant) { default: break; } - return base::nullopt; + return absl::nullopt; } diff --git a/browser/ui/brave_layout_constants.h b/browser/ui/brave_layout_constants.h index 3870ad7294e6..ad2b6950ee82 100644 --- a/browser/ui/brave_layout_constants.h +++ b/browser/ui/brave_layout_constants.h @@ -1,9 +1,14 @@ -#ifndef BRAVE_BROWSER_UI_LAYOUT_CONSTANTS_H_ -#define BRAVE_BROWSER_UI_LAYOUT_CONSTANTS_H_ +/* 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/. */ + +#ifndef BRAVE_BROWSER_UI_BRAVE_LAYOUT_CONSTANTS_H_ +#define BRAVE_BROWSER_UI_BRAVE_LAYOUT_CONSTANTS_H_ -#include "base/optional.h" #include "chrome/browser/ui/layout_constants.h" +#include "third_party/abseil-cpp/absl/types/optional.h" -base::Optional GetBraveLayoutConstant(LayoutConstant constant); +absl::optional GetBraveLayoutConstant(LayoutConstant constant); -#endif \ No newline at end of file +#endif // BRAVE_BROWSER_UI_BRAVE_LAYOUT_CONSTANTS_H_ diff --git a/browser/ui/sidebar/sidebar_model.h b/browser/ui/sidebar/sidebar_model.h index 761e0097de04..baf19dc19064 100644 --- a/browser/ui/sidebar/sidebar_model.h +++ b/browser/ui/sidebar/sidebar_model.h @@ -11,12 +11,12 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "base/optional.h" #include "base/scoped_observation.h" #include "brave/browser/ui/sidebar/sidebar_model_data.h" #include "brave/components/sidebar/sidebar_service.h" #include "components/history/core/browser/history_service.h" #include "components/history/core/browser/history_service_observer.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class CancelableTaskTracker; diff --git a/browser/ui/views/brave_actions/brave_action_view.cc b/browser/ui/views/brave_actions/brave_action_view.cc index f8e69d10e8bd..6ef43a962ed2 100644 --- a/browser/ui/views/brave_actions/brave_action_view.cc +++ b/browser/ui/views/brave_actions/brave_action_view.cc @@ -17,6 +17,7 @@ #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" +#include "ui/gfx/skia_util.h" #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/view.h" diff --git a/browser/ui/views/brave_actions/brave_actions_container.cc b/browser/ui/views/brave_actions/brave_actions_container.cc index 1ef69655b405..fe3f853d5a10 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.cc +++ b/browser/ui/views/brave_actions/brave_actions_container.cc @@ -209,11 +209,8 @@ void BraveActionsContainer::AddAction(const extensions::Extension* extension) { // do not require that logic. // If we do require notifications when popups are open or closed, // then we should inherit and pass |this| through. - actions_[id].view_controller_ = std::make_unique( - extension, browser_, - extension_action_manager_->GetExtensionAction(*extension), - empty_extensions_container_.get(), - /*in_overflow_mode*/false); + actions_[id].view_controller_ = BraveActionViewController::Create( + extension->id(), browser_, empty_extensions_container_.get()); // The button view actions_[id].view_ = std::make_unique( actions_[id].view_controller_.get(), this); @@ -329,9 +326,6 @@ content::WebContents* BraveActionsContainer::GetCurrentWebContents() { return browser_->tab_strip_model()->GetActiveWebContents(); } -void BraveActionsContainer::OnToolbarActionViewDragDone() { -} - views::LabelButton* BraveActionsContainer::GetOverflowReferenceView() const { // Our action views should always be visible, // so we should not need another view. diff --git a/browser/ui/views/brave_actions/brave_actions_container.h b/browser/ui/views/brave_actions/brave_actions_container.h index 12d30ecff59b..d2ea59aad8d4 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.h +++ b/browser/ui/views/brave_actions/brave_actions_container.h @@ -22,6 +22,7 @@ #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry_observer.h" #include "extensions/common/extension.h" +#include "ui/gfx/skia_util.h" #include "ui/views/view.h" #if BUILDFLAG(BRAVE_REWARDS_ENABLED) @@ -60,8 +61,6 @@ class BraveActionsContainer : public views::View, void SetShouldHide(bool should_hide); // ToolbarActionView::Delegate content::WebContents* GetCurrentWebContents() override; - // Notifies that a drag completed. - void OnToolbarActionViewDragDone() override; // Returns the view of the toolbar actions overflow menu to use as a // reference point for a popup when this view isn't visible. views::LabelButton* GetOverflowReferenceView() const override; diff --git a/browser/ui/views/brave_actions/brave_rewards_action_stub_view.cc b/browser/ui/views/brave_actions/brave_rewards_action_stub_view.cc index 92f00adb0a28..d49cdfec8b7d 100644 --- a/browser/ui/views/brave_actions/brave_rewards_action_stub_view.cc +++ b/browser/ui/views/brave_actions/brave_rewards_action_stub_view.cc @@ -21,15 +21,16 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/geometry/rect.h" +#include "ui/gfx/image/canvas_image_source.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_rep_default.h" -#include "ui/gfx/image/canvas_image_source.h" -#include "ui/views/view.h" -#include "ui/views/view_class_properties.h" +#include "ui/gfx/skia_util.h" #include "ui/views/animation/ink_drop_impl.h" #include "ui/views/controls/button/label_button_border.h" #include "ui/views/controls/highlight_path_generator.h" +#include "ui/views/view.h" +#include "ui/views/view_class_properties.h" namespace { @@ -61,10 +62,14 @@ BraveRewardsActionStubView::BraveRewardsActionStubView( std::u16string()), profile_(profile), delegate_(delegate) { - SetInkDropMode(InkDropMode::ON); + ink_drop()->SetMode(views::InkDropHost::InkDropMode::ON); + ink_drop()->SetBaseColorCallback(base::BindRepeating( + [](views::View* host) { return GetToolbarInkDropBaseColor(host); }, + this)); + SetHasInkDropActionOnClick(true); SetHorizontalAlignment(gfx::ALIGN_CENTER); - SetInkDropVisibleOpacity(kToolbarInkDropVisibleOpacity); + ink_drop()->SetVisibleOpacity(kToolbarInkDropVisibleOpacity); // Create badge-and-image source like an extension icon would auto preferred_size = GetPreferredSize(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); @@ -89,7 +94,6 @@ BraveRewardsActionStubView::BraveRewardsActionStubView( SK_ColorWHITE, kRewardsBadgeBg)); image_source->SetBadge(std::move(badge)); - image_source->set_paint_page_action_decoration(false); gfx::ImageSkia icon(gfx::Image( gfx::ImageSkia( std::move(image_source), @@ -144,12 +148,3 @@ std::unique_ptr BraveRewardsActionStubView:: gfx::Insets(0, 0, 0, 0)); return border; } - -SkColor BraveRewardsActionStubView::GetInkDropBaseColor() const { - return GetToolbarInkDropBaseColor(this); -} - -std::unique_ptr -BraveRewardsActionStubView::CreateInkDropHighlight() const { - return CreateToolbarInkDropHighlight(this); -} diff --git a/browser/ui/views/brave_actions/brave_rewards_action_stub_view.h b/browser/ui/views/brave_actions/brave_rewards_action_stub_view.h index ee4b55121f1b..ea4f0e994781 100644 --- a/browser/ui/views/brave_actions/brave_rewards_action_stub_view.h +++ b/browser/ui/views/brave_actions/brave_rewards_action_stub_view.h @@ -33,9 +33,6 @@ class BraveRewardsActionStubView : public views::LabelButton { // views::LabelButton: std::unique_ptr CreateDefaultBorder() const override; - SkColor GetInkDropBaseColor() const override; - std::unique_ptr CreateInkDropHighlight() - const override; SkPath GetHighlightPath() const; diff --git a/browser/ui/views/download/brave_download_item_view.cc b/browser/ui/views/download/brave_download_item_view.cc index bd88efbc84f0..48f83ad45ec7 100644 --- a/browser/ui/views/download/brave_download_item_view.cc +++ b/browser/ui/views/download/brave_download_item_view.cc @@ -223,7 +223,7 @@ gfx::ImageSkia BraveDownloadItemView::GetLockIcon(int height) { } // Update accessible name with origin URL. -void BraveDownloadItemView::SetMode(Mode mode) { +void BraveDownloadItemView::SetMode(download::DownloadItemMode mode) { DownloadItemView::SetMode(mode); if (IsShowingWarningDialog()) return; diff --git a/browser/ui/views/download/brave_download_item_view.h b/browser/ui/views/download/brave_download_item_view.h index f1e5afd8acaf..fc8278d6c00e 100644 --- a/browser/ui/views/download/brave_download_item_view.h +++ b/browser/ui/views/download/brave_download_item_view.h @@ -7,6 +7,7 @@ #define BRAVE_BROWSER_UI_VIEWS_DOWNLOAD_BRAVE_DOWNLOAD_ITEM_VIEW_H_ #include "brave/browser/download/brave_download_item_model.h" +#include "chrome/browser/ui/download/download_item_mode.h" #include "chrome/browser/ui/views/download/download_item_view.h" // The purpose of this subclass is to add URL origin and lock icon to the @@ -48,7 +49,7 @@ class BraveDownloadItemView : public DownloadItemView { gfx::ImageSkia GetLockIcon(int height); // Overrides the accessible name construction to reflect the origin URL. - void SetMode(Mode mode) override; + void SetMode(download::DownloadItemMode mode) override; // Brave download item model. BraveDownloadItemModel brave_model_; diff --git a/browser/ui/views/infobars/BUILD.gn b/browser/ui/views/infobars/BUILD.gn index d5bb899f3900..f4a9db5ecef7 100644 --- a/browser/ui/views/infobars/BUILD.gn +++ b/browser/ui/views/infobars/BUILD.gn @@ -16,6 +16,8 @@ source_set("brave_wayback_machine") { "//brave/app:brave_generated_resources_grit", "//brave/app/vector_icons", "//brave/components/brave_wayback_machine", + "//components/infobars/content", + "//components/infobars/core", "//components/prefs:prefs", "//components/resources", "//components/user_prefs", diff --git a/browser/ui/views/infobars/brave_wayback_machine_infobar_contents_view.cc b/browser/ui/views/infobars/brave_wayback_machine_infobar_contents_view.cc index c3fd43a702a8..2141b535f970 100644 --- a/browser/ui/views/infobars/brave_wayback_machine_infobar_contents_view.cc +++ b/browser/ui/views/infobars/brave_wayback_machine_infobar_contents_view.cc @@ -17,11 +17,11 @@ #include "brave/components/brave_wayback_machine/wayback_machine_url_fetcher.h" #include "brave/grit/brave_generated_resources.h" #include "brave/grit/brave_theme_resources.h" -#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_typography.h" #include "components/grit/components_scaled_resources.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" #include "components/prefs/pref_service.h" #include "components/user_prefs/user_prefs.h" @@ -54,9 +54,9 @@ BraveWaybackMachineInfoBarContentsView::BraveWaybackMachineInfoBarContentsView( : contents_(contents), wayback_machine_url_fetcher_( this, - content::BrowserContext::GetDefaultStoragePartition( - contents->GetBrowserContext())-> - GetURLLoaderFactoryForBrowserProcess()) { + contents->GetBrowserContext() + ->GetDefaultStoragePartition() + ->GetURLLoaderFactoryForBrowserProcess()) { pref_service_ = user_prefs::UserPrefs::Get(contents_->GetBrowserContext()); SetLayoutManager(std::make_unique()); InitializeChildren(); @@ -101,15 +101,16 @@ void BraveWaybackMachineInfoBarContentsView::OnWaybackURLFetched( } void BraveWaybackMachineInfoBarContentsView::HideInfobar() { - InfoBarService* infobar_service = InfoBarService::FromWebContents(contents_); - if (!infobar_service) + infobars::ContentInfoBarManager* infobar_manager = + infobars::ContentInfoBarManager::FromWebContents(contents_); + if (!infobar_manager) return; - for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { - infobars::InfoBar* infobar = infobar_service->infobar_at(i); + for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { + infobars::InfoBar* infobar = infobar_manager->infobar_at(i); if (infobar->delegate()->GetIdentifier() == BraveWaybackMachineInfoBarDelegate::WAYBACK_MACHINE_INFOBAR_DELEGATE) { - infobar_service->RemoveInfoBar(infobar); + infobar_manager->RemoveInfoBar(infobar); break; } } diff --git a/browser/ui/views/location_bar/brave_location_bar_view.cc b/browser/ui/views/location_bar/brave_location_bar_view.cc index 0033c674153d..0702f99c12ec 100644 --- a/browser/ui/views/location_bar/brave_location_bar_view.cc +++ b/browser/ui/views/location_bar/brave_location_bar_view.cc @@ -25,9 +25,11 @@ #include "components/omnibox/browser/omnibox_edit_model.h" #include "components/version_info/channel.h" #include "content/public/browser/navigation_entry.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/skia_util.h" #include "ui/views/controls/highlight_path_generator.h" #if BUILDFLAG(ENABLE_TOR) @@ -57,12 +59,12 @@ class BraveLocationBarViewFocusRingHighlightPathGenerator DISALLOW_COPY_AND_ASSIGN(BraveLocationBarViewFocusRingHighlightPathGenerator); }; -base::Optional GetFocusRingColor(Profile* profile) { +absl::optional GetFocusRingColor(Profile* profile) { constexpr SkColor kPrivateFocusRingColor = SkColorSetRGB(0xC6, 0xB3, 0xFF); constexpr SkColor kTorPrivateFocusRingColor = SkColorSetRGB(0xCF, 0xAB, 0xE2); if (brave::IsRegularProfile(profile) || profile->IsGuestSession()) { // Don't update color. - return base::nullopt; + return absl::nullopt; } if (profile->IsTor()) return kTorPrivateFocusRingColor; diff --git a/browser/ui/views/location_bar/ipfs_location_view.cc b/browser/ui/views/location_bar/ipfs_location_view.cc index d431e7846362..2e3350fadfb2 100644 --- a/browser/ui/views/location_bar/ipfs_location_view.cc +++ b/browser/ui/views/location_bar/ipfs_location_view.cc @@ -25,6 +25,7 @@ #include "ui/gfx/geometry/size.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/skia_util.h" #include "ui/gfx/text_constants.h" #include "ui/views/animation/ink_drop_impl.h" #include "ui/views/background.h" @@ -77,11 +78,11 @@ class IPFSLocationButtonView : public views::LabelButton { SetEnabledTextColors(kTextColor); SetHorizontalAlignment(gfx::ALIGN_RIGHT); SetImageLabelSpacing(6); - SetInkDropMode(InkDropMode::ON); + ink_drop()->SetMode(views::InkDropHost::InkDropMode::ON); SetBorder(views::CreateEmptyBorder( GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING))); SetHasInkDropActionOnClick(true); - SetInkDropVisibleOpacity(kToolbarInkDropVisibleOpacity); + ink_drop()->SetVisibleOpacity(kToolbarInkDropVisibleOpacity); UpdateBorder(); // Ensure focus ring follows border views::HighlightPathGenerator::Install( diff --git a/browser/ui/views/location_bar/onion_location_view.cc b/browser/ui/views/location_bar/onion_location_view.cc index cd1fe95c4e1d..2a10372f81bb 100644 --- a/browser/ui/views/location_bar/onion_location_view.cc +++ b/browser/ui/views/location_bar/onion_location_view.cc @@ -26,6 +26,7 @@ #include "ui/gfx/geometry/size.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/skia_util.h" #include "ui/gfx/text_constants.h" #include "ui/views/animation/ink_drop_impl.h" #include "ui/views/background.h" @@ -93,11 +94,11 @@ class OnionLocationButtonView : public views::LabelButton { SetEnabledTextColors(kTextColor); SetHorizontalAlignment(gfx::ALIGN_RIGHT); SetImageLabelSpacing(6); - SetInkDropMode(InkDropMode::ON); + ink_drop()->SetMode(views::InkDropHost::InkDropMode::ON); SetBorder(views::CreateEmptyBorder( GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING))); SetHasInkDropActionOnClick(true); - SetInkDropVisibleOpacity(kToolbarInkDropVisibleOpacity); + ink_drop()->SetVisibleOpacity(kToolbarInkDropVisibleOpacity); UpdateBorder(); // Ensure focus ring follows border views::HighlightPathGenerator::Install( diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc index edfa348f6f35..09a744758a9a 100644 --- a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc @@ -18,11 +18,13 @@ #include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h" #include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/pointer/touch_ui_controller.h" #include "ui/base/theme_provider.h" #include "ui/gfx/image/image.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/skia_util.h" #include "ui/views/background.h" #include "ui/views/border.h" #include "ui/views/controls/highlight_path_generator.h" @@ -56,7 +58,7 @@ BraveAvatarToolbarButton::BraveAvatarToolbarButton(BrowserView* browser_view) void BraveAvatarToolbarButton::SetHighlight( const std::u16string& highlight_text, - base::Optional highlight_color) { + absl::optional highlight_color) { std::u16string revised_highlight_text; if (browser_->profile()->IsTor()) { revised_highlight_text = diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.h b/browser/ui/views/profiles/brave_avatar_toolbar_button.h index e6e71e4e0689..66046d69daa8 100644 --- a/browser/ui/views/profiles/brave_avatar_toolbar_button.h +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.h @@ -16,7 +16,7 @@ class BraveAvatarToolbarButton : public AvatarToolbarButton { // ToolbarButton: void SetHighlight(const std::u16string& highlight_text, - base::Optional highlight_color) override; + absl::optional highlight_color) override; void UpdateColorsAndInsets() override; private: diff --git a/browser/ui/views/profiles/brave_incognito_menu_view.cc b/browser/ui/views/profiles/brave_incognito_menu_view.cc index e8414f585b4f..5330e1501109 100644 --- a/browser/ui/views/profiles/brave_incognito_menu_view.cc +++ b/browser/ui/views/profiles/brave_incognito_menu_view.cc @@ -61,7 +61,7 @@ void BraveIncognitoMenuView::BuildMenu() { SetProfileIdentityInfo( /*profile_name=*/std::u16string(), /*background_color=*/SK_ColorTRANSPARENT, - /*edit_button=*/base::nullopt, + /*edit_button=*/absl::nullopt, ui::ImageModel::FromVectorIcon(kIncognitoProfileIcon, icon_color), l10n_util::GetStringUTF16(GetProfileMenuTitleId(browser()->profile())), window_count > 1 ? l10n_util::GetPluralStringFUTF16( @@ -70,11 +70,12 @@ void BraveIncognitoMenuView::BuildMenu() { AddTorButton(); - AddFeatureButton(l10n_util::GetStringUTF16( - GetProfileMenuCloseButtonTextId(browser()->profile())), - base::BindRepeating(&IncognitoMenuView::OnExitButtonClicked, - base::Unretained(this)), - kCloseAllIcon); + AddFeatureButton( + l10n_util::GetStringUTF16( + GetProfileMenuCloseButtonTextId(browser()->profile())), + base::BindRepeating(&BraveIncognitoMenuView::OnExitButtonClicked, + base::Unretained(this)), + kCloseAllIcon); } void BraveIncognitoMenuView::AddTorButton() { diff --git a/browser/ui/views/profiles/brave_profile_menu_view.cc b/browser/ui/views/profiles/brave_profile_menu_view.cc index 91545790bd49..acfab5072dd6 100644 --- a/browser/ui/views/profiles/brave_profile_menu_view.cc +++ b/browser/ui/views/profiles/brave_profile_menu_view.cc @@ -17,11 +17,18 @@ #include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/signin/profile_colors_util.h" +#include "chrome/browser/ui/ui_features.h" #include "chrome/grit/generated_resources.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/image_model.h" +namespace { +bool IsGuest(Profile* profile) { + return profile->IsGuestSession() || profile->IsEphemeralGuestProfile(); +} +} // namespace + void BraveProfileMenuView::BuildIdentity() { ProfileMenuView::BuildIdentity(); Profile* profile = browser()->profile(); @@ -34,9 +41,9 @@ void BraveProfileMenuView::BuildIdentity() { SetProfileIdentityInfo( /*profile_name=*/std::u16string(), profile_attributes->GetProfileThemeColors().profile_highlight_color, - /*edit_button=*/base::nullopt, + /*edit_button=*/absl::nullopt, ui::ImageModel::FromImage(profile_attributes->GetAvatarIcon()), - /*title=*/std::u16string()); + /*title=*/profile_attributes->GetName()); } // We don't want autofill buttons in this menu. @@ -50,14 +57,25 @@ void BraveProfileMenuView::BuildFeatureButtons() { Profile* profile = browser()->profile(); int window_count = chrome::GetBrowserCount(profile); if (!profile->IsOffTheRecord() && profile->HasPrimaryOTRProfile()) - window_count += chrome::GetBrowserCount(profile->GetPrimaryOTRProfile()); - if (window_count > 1) { + window_count += chrome::GetBrowserCount( + profile->GetPrimaryOTRProfile(/*create_if_needed=*/true)); + if (base::FeatureList::IsEnabled(features::kNewProfilePicker) && + IsGuest(profile)) { AddFeatureButton( - l10n_util::GetPluralStringFUTF16(IDS_PROFILES_CLOSE_X_WINDOWS_BUTTON, + l10n_util::GetPluralStringFUTF16(IDS_GUEST_PROFILE_MENU_CLOSE_BUTTON, window_count), - base::BindRepeating(&ProfileMenuView::OnExitProfileButtonClicked, + base::BindRepeating(&BraveProfileMenuView::OnExitProfileButtonClicked, base::Unretained(this)), vector_icons::kCloseIcon); + } else { + if (window_count > 1) { + AddFeatureButton( + l10n_util::GetPluralStringFUTF16(IDS_PROFILES_CLOSE_X_WINDOWS_BUTTON, + window_count), + base::BindRepeating(&BraveProfileMenuView::OnExitProfileButtonClicked, + base::Unretained(this)), + vector_icons::kCloseIcon); + } } } @@ -66,10 +84,3 @@ gfx::ImageSkia BraveProfileMenuView::GetSyncIcon() const { return gfx::ImageSkia(); } -void BraveProfileMenuView::OnExitProfileButtonClicked() { - if (browser()->profile()->IsGuestSession()) { - RecordClick(ActionableItem::kExitProfileButton); - } else { - ProfileMenuView::OnExitProfileButtonClicked(); - } -} diff --git a/browser/ui/views/profiles/brave_profile_menu_view.h b/browser/ui/views/profiles/brave_profile_menu_view.h index 41ba0ea0c9a9..6852de9519df 100644 --- a/browser/ui/views/profiles/brave_profile_menu_view.h +++ b/browser/ui/views/profiles/brave_profile_menu_view.h @@ -15,9 +15,6 @@ class BraveProfileMenuView : public ProfileMenuView { using ProfileMenuView::ProfileMenuView; ~BraveProfileMenuView() override = default; - // Button/link actions. - void OnExitProfileButtonClicked() override; - // Helper methods for building the menu. void BuildIdentity() override; void BuildAutofillButtons() override; diff --git a/browser/ui/views/profiles/brave_profile_menu_view_browsertest.cc b/browser/ui/views/profiles/brave_profile_menu_view_browsertest.cc index 23b119c4d29b..40993694380c 100644 --- a/browser/ui/views/profiles/brave_profile_menu_view_browsertest.cc +++ b/browser/ui/views/profiles/brave_profile_menu_view_browsertest.cc @@ -3,6 +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/. */ +#include "chrome/browser/browser_process.h" +#include "chrome/browser/profiles/profile.h" +#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/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" #include "chrome/browser/ui/views/profiles/profile_menu_view_base.h" @@ -12,7 +17,7 @@ #include "ui/events/base_event_utils.h" #include "ui/events/event.h" #include "ui/gfx/geometry/point.h" -#include "ui/views/controls/button/label_button.h" +#include "ui/views/controls/label.h" class BraveProfileMenuViewTest : public InProcessBrowserTest { public: @@ -46,14 +51,29 @@ class BraveProfileMenuViewTest : public InProcessBrowserTest { return bubble; } - void CheckIdentityHasNoText() { + std::u16string GetProfileName() { + Profile* profile = browser()->profile(); + ProfileAttributesEntry* profile_attributes = + g_browser_process->profile_manager() + ->GetProfileAttributesStorage() + .GetProfileAttributesWithPath(profile->GetPath()); + return profile_attributes->GetName(); + } + + void CheckIdentity() { ProfileMenuViewBase* menu = profile_menu(); // Profile image and title container. EXPECT_EQ(2u, menu->identity_info_container_->children().size()); - // Each should have 0 children. - for (const auto* view : menu->identity_info_container_->children()) { - EXPECT_EQ(0u, view->children().size()); - } + // Profile image should have 1 child - header and image container. + EXPECT_EQ(1u, + menu->identity_info_container_->children()[0]->children().size()); + // Title container should have 1 child - title, which is the profile name. + const auto* title_container_view = + menu->identity_info_container_->children()[1]; + EXPECT_EQ(1u, title_container_view->children().size()); + const auto* title_view = title_container_view->children()[0]; + EXPECT_EQ(GetProfileName(), + static_cast(title_view)->GetText()); } private: @@ -62,5 +82,5 @@ class BraveProfileMenuViewTest : public InProcessBrowserTest { IN_PROC_BROWSER_TEST_F(BraveProfileMenuViewTest, TestCurrentProfileView) { OpenProfileMenuView(); - CheckIdentityHasNoText(); + CheckIdentity(); } diff --git a/browser/ui/views/rounded_separator.h b/browser/ui/views/rounded_separator.h index 0bbbd4f6639b..1eadcc9508a8 100644 --- a/browser/ui/views/rounded_separator.h +++ b/browser/ui/views/rounded_separator.h @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* 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/. */ @@ -8,11 +9,11 @@ #include #include "base/macros.h" -#include "base/optional.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/view.h" -// The RoundedSeparator class is a view that shows a line used to visually separate -// other views. +// The RoundedSeparator class is a view that shows a line used to visually +// separate other views. class RoundedSeparator : public views::View { public: // The separator's class name. @@ -36,9 +37,9 @@ class RoundedSeparator : public views::View { private: int preferred_height_ = kThickness; - base::Optional overridden_color_; + absl::optional overridden_color_; DISALLOW_COPY_AND_ASSIGN(RoundedSeparator); }; -#endif +#endif // BRAVE_BROWSER_UI_VIEWS_ROUNDED_SEPARATOR_H_ diff --git a/browser/ui/views/sidebar/bubble_border_with_arrow.cc b/browser/ui/views/sidebar/bubble_border_with_arrow.cc index f2a532da5581..348ebb431847 100644 --- a/browser/ui/views/sidebar/bubble_border_with_arrow.cc +++ b/browser/ui/views/sidebar/bubble_border_with_arrow.cc @@ -9,6 +9,7 @@ #include "cc/paint/paint_flags.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/skia_util.h" #include "ui/views/view.h" // static diff --git a/browser/ui/views/sidebar/sidebar_add_item_bubble_delegate_view.cc b/browser/ui/views/sidebar/sidebar_add_item_bubble_delegate_view.cc index 98137188d97e..2882ebd2a375 100644 --- a/browser/ui/views/sidebar/sidebar_add_item_bubble_delegate_view.cc +++ b/browser/ui/views/sidebar/sidebar_add_item_bubble_delegate_view.cc @@ -127,7 +127,6 @@ SidebarAddItemBubbleDelegateView::CreateNonClientFrameView( std::make_unique(arrow(), GetShadow(), color()); constexpr int kRadius = 4; border->SetCornerRadius(kRadius); - border->set_md_shadow_color(SkColorSetARGB(0x2E, 0x63, 0x69, 0x6E)); auto* border_ptr = border.get(); frame->SetBubbleBorder(std::move(border)); // Replace frame's background to draw arrow. diff --git a/browser/ui/views/sidebar/sidebar_item_added_feedback_bubble.cc b/browser/ui/views/sidebar/sidebar_item_added_feedback_bubble.cc index 1c7637f57e42..82c595f37155 100644 --- a/browser/ui/views/sidebar/sidebar_item_added_feedback_bubble.cc +++ b/browser/ui/views/sidebar/sidebar_item_added_feedback_bubble.cc @@ -12,6 +12,7 @@ #include "brave/browser/ui/views/sidebar/sidebar_item_added_feedback_bubble.h" #include "brave/grit/brave_generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/compositor/layer.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/views/background.h" #include "ui/views/bubble/bubble_border.h" @@ -68,7 +69,6 @@ SidebarItemAddedFeedbackBubble::CreateNonClientFrameView( std::make_unique(arrow(), GetShadow(), color()); constexpr int kFeedbackBubbleRadius = 6; border->SetCornerRadius(kFeedbackBubbleRadius); - border->set_md_shadow_color(SkColorSetARGB(0x5C, 0x63, 0x69, 0x6E)); auto* border_ptr = border.get(); frame->SetBubbleBorder(std::move(border)); // Replace default background to draw arrow. diff --git a/browser/ui/views/sidebar/sidebar_items_contents_view.cc b/browser/ui/views/sidebar/sidebar_items_contents_view.cc index a502437ffc9a..96e89671e063 100644 --- a/browser/ui/views/sidebar/sidebar_items_contents_view.cc +++ b/browser/ui/views/sidebar/sidebar_items_contents_view.cc @@ -30,6 +30,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" +#include "ui/compositor/compositor.h" #include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/views/background.h" diff --git a/browser/ui/views/sidebar/sidebar_show_options_event_detect_widget.cc b/browser/ui/views/sidebar/sidebar_show_options_event_detect_widget.cc index 1bda9c95a7ee..56020f55205c 100644 --- a/browser/ui/views/sidebar/sidebar_show_options_event_detect_widget.cc +++ b/browser/ui/views/sidebar/sidebar_show_options_event_detect_widget.cc @@ -128,7 +128,7 @@ SidebarShowOptionsEventDetectWidget::CreateWidget(Delegate* delegate) { params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.parent = browser_view_->GetWidget()->GetNativeView(); params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent; - params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; + params.activatable = views::Widget::InitParams::Activatable::kNo; widget->Init(std::move(params)); std::unique_ptr contents_view = diff --git a/browser/ui/views/speedreader/reader_mode_bubble.cc b/browser/ui/views/speedreader/reader_mode_bubble.cc index 8e5368fba150..26229620a476 100644 --- a/browser/ui/views/speedreader/reader_mode_bubble.cc +++ b/browser/ui/views/speedreader/reader_mode_bubble.cc @@ -23,13 +23,13 @@ #include "content/public/browser/web_ui_controller.h" #include "content/public/common/referrer.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/window_open_disposition.h" #include "ui/events/event.h" #include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/label.h" #include "ui/views/controls/styled_label.h" #include "ui/views/layout/box_layout.h" -#include "ui/views/metadata/metadata_impl_macros.h" #include "ui/views/view.h" namespace { diff --git a/browser/ui/views/speedreader/reader_mode_bubble.h b/browser/ui/views/speedreader/reader_mode_bubble.h index 872a4382718d..51afd8a460e7 100644 --- a/browser/ui/views/speedreader/reader_mode_bubble.h +++ b/browser/ui/views/speedreader/reader_mode_bubble.h @@ -8,7 +8,7 @@ #include "brave/browser/ui/speedreader/speedreader_bubble_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h" -#include "ui/views/metadata/metadata_header_macros.h" +#include "ui/base/metadata/metadata_header_macros.h" namespace content { class WebContents; diff --git a/browser/ui/views/speedreader/speedreader_bubble_util.cc b/browser/ui/views/speedreader/speedreader_bubble_util.cc index 767a30b34d42..f0d78b0fb78f 100644 --- a/browser/ui/views/speedreader/speedreader_bubble_util.cc +++ b/browser/ui/views/speedreader/speedreader_bubble_util.cc @@ -27,7 +27,7 @@ std::unique_ptr BuildLabelWithEndingLink( views::Link::ClickedCallback callback) { auto label = std::make_unique(); std::u16string text = reg_text; - text.append(base::ASCIIToUTF16(kSpeedreaderSeparator)); + text.append(kSpeedreaderSeparator); size_t default_format_offset = text.length(); text.append(link_text); label->SetText(text); diff --git a/browser/ui/views/speedreader/speedreader_bubble_util.h b/browser/ui/views/speedreader/speedreader_bubble_util.h index 5de17b58ee57..0b4536dc476f 100644 --- a/browser/ui/views/speedreader/speedreader_bubble_util.h +++ b/browser/ui/views/speedreader/speedreader_bubble_util.h @@ -28,7 +28,7 @@ constexpr int kLineHeight = 16; constexpr int kBoxLayoutChildSpacing = 10; // Separator used in StyledLabel -constexpr char kSpeedreaderSeparator[] = " "; +constexpr char16_t kSpeedreaderSeparator[] = u" "; // Reader Mode blurple color constexpr SkColor kColorReaderBlurple = SkColorSetRGB(0x4c, 0x54, 0xd2); diff --git a/browser/ui/views/speedreader/speedreader_mode_bubble.cc b/browser/ui/views/speedreader/speedreader_mode_bubble.cc index 8a4d1c0a2a27..c422c45c8e32 100644 --- a/browser/ui/views/speedreader/speedreader_mode_bubble.cc +++ b/browser/ui/views/speedreader/speedreader_mode_bubble.cc @@ -25,6 +25,7 @@ #include "content/public/browser/web_ui_controller.h" #include "content/public/common/referrer.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/window_open_disposition.h" #include "ui/events/event.h" #include "ui/views/controls/button/md_text_button.h" @@ -33,7 +34,6 @@ #include "ui/views/controls/link.h" #include "ui/views/controls/styled_label.h" #include "ui/views/layout/box_layout.h" -#include "ui/views/metadata/metadata_impl_macros.h" #include "ui/views/view.h" namespace { @@ -102,7 +102,7 @@ void SpeedreaderModeBubble::Init() { DCHECK(!host.empty()); auto site = base::ASCIIToUTF16(host); auto offset = site.length(); - site.append(base::ASCIIToUTF16(kSpeedreaderSeparator)); + site.append(kSpeedreaderSeparator); site.append(l10n_util::GetStringUTF16(IDS_PAGE_IS_DISTILLED)); auto site_title_label = std::make_unique(); site_title_label->SetText(site); diff --git a/browser/ui/views/speedreader/speedreader_mode_bubble.h b/browser/ui/views/speedreader/speedreader_mode_bubble.h index 095485634cfe..25597cdb2743 100644 --- a/browser/ui/views/speedreader/speedreader_mode_bubble.h +++ b/browser/ui/views/speedreader/speedreader_mode_bubble.h @@ -10,7 +10,7 @@ #include "brave/browser/ui/speedreader/speedreader_bubble_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h" -#include "ui/views/metadata/metadata_header_macros.h" +#include "ui/base/metadata/metadata_header_macros.h" namespace content { class WebContents; diff --git a/browser/ui/views/tabs/brave_alert_indicator.cc b/browser/ui/views/tabs/brave_alert_indicator.cc index 59dff76719b3..b8ee1d4269cd 100644 --- a/browser/ui/views/tabs/brave_alert_indicator.cc +++ b/browser/ui/views/tabs/brave_alert_indicator.cc @@ -15,13 +15,14 @@ #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/tab_style_views.h" #include "content/public/browser/web_contents.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkPathTypes.h" #include "ui/gfx/color_utils.h" #include "ui/views/background.h" namespace { -bool IsAudioState(const base::Optional& state) { +bool IsAudioState(const absl::optional& state) { return (state.has_value() && (state.value() == TabAlertState::AUDIO_PLAYING || state.value() == TabAlertState::AUDIO_MUTING)); } @@ -96,10 +97,8 @@ void BraveAlertIndicator::OnMouseReleased(const ui::MouseEvent& event) { auto* web_contents = tab_strip_model->GetWebContentsAt(tab_index); if (web_contents == nullptr) return; - chrome::SetTabAudioMuted(web_contents, - !web_contents->IsAudioMuted(), - TabMutedReason::CONTEXT_MENU, - std::string()); + chrome::SetTabAudioMuted(web_contents, !web_contents->IsAudioMuted(), + TabMutedReason::CONTENT_SETTING, std::string()); } void BraveAlertIndicator::OnMouseEntered(const ui::MouseEvent& event) { diff --git a/browser/ui/views/toolbar/speedreader_button.cc b/browser/ui/views/toolbar/speedreader_button.cc index 04347668c74a..232cc728fd55 100644 --- a/browser/ui/views/toolbar/speedreader_button.cc +++ b/browser/ui/views/toolbar/speedreader_button.cc @@ -43,9 +43,9 @@ const char* SpeedreaderButton::GetClassName() const { } void SpeedreaderButton::SetHighlighted(bool bubble_visible) { - AnimateInkDrop(bubble_visible ? views::InkDropState::ACTIVATED - : views::InkDropState::DEACTIVATED, - nullptr); + ink_drop()->AnimateToState(bubble_visible ? views::InkDropState::ACTIVATED + : views::InkDropState::DEACTIVATED, + nullptr); } void SpeedreaderButton::OnPreferenceChanged() { diff --git a/browser/ui/views/toolbar/wallet_button.cc b/browser/ui/views/toolbar/wallet_button.cc index 70e386bc0002..67e6243e8cd7 100644 --- a/browser/ui/views/toolbar/wallet_button.cc +++ b/browser/ui/views/toolbar/wallet_button.cc @@ -16,8 +16,8 @@ #include "components/grit/brave_components_strings.h" #include "components/prefs/pref_service.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/paint_vector_icon.h" -#include "ui/views/metadata/metadata_impl_macros.h" WalletButton::WalletButton(View* backup_anchor_view, Profile* profile, diff --git a/browser/ui/views/toolbar/wallet_button.h b/browser/ui/views/toolbar/wallet_button.h index 1552667a25c6..190948f6456d 100644 --- a/browser/ui/views/toolbar/wallet_button.h +++ b/browser/ui/views/toolbar/wallet_button.h @@ -13,8 +13,8 @@ #include "chrome/browser/ui/views/bubble/webui_bubble_manager.h" #include "chrome/browser/ui/views/toolbar/toolbar_button.h" #include "components/prefs/pref_change_registrar.h" +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/controls/button/menu_button_controller.h" -#include "ui/views/metadata/metadata_header_macros.h" #include "ui/views/widget/widget_observer.h" class PrefService; diff --git a/browser/ui/webui/brave_rewards_page_ui.cc b/browser/ui/webui/brave_rewards_page_ui.cc index 3435f4d21aef..46fdb0839193 100644 --- a/browser/ui/webui/brave_rewards_page_ui.cc +++ b/browser/ui/webui/brave_rewards_page_ui.cc @@ -545,7 +545,7 @@ void RewardsDOMHandler::OnGetRewardsParameters( if (parameters) { auto choices = std::make_unique(); for (double const& choice : parameters->auto_contribute_choices) { - choices->AppendDouble(choice); + choices->Append(choice); } data.SetDouble("rate", parameters->rate); diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index e8cebc1662c6..4ec67008a57c 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -1158,7 +1158,8 @@ content::WebUIDataSource* CreateWebUIDataSource( // Allow a policy to be created so that we // can allow trusted HTML and trusted lazy-load script sources. source->OverrideContentSecurityPolicy( - network::mojom::CSPDirectiveName::TrustedTypes, "default"); + network::mojom::CSPDirectiveName::TrustedTypes, + "trusted-types default;"); } source->UseStringsJs(); diff --git a/browser/ui/webui/brave_welcome_ui.cc b/browser/ui/webui/brave_welcome_ui.cc index fb356e70b9dd..458894d63075 100644 --- a/browser/ui/webui/brave_welcome_ui.cc +++ b/browser/ui/webui/brave_welcome_ui.cc @@ -16,6 +16,7 @@ #include "brave/common/webui_url_constants.h" #include "brave/components/brave_welcome/resources/grit/brave_welcome_generated_map.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/webui/settings/search_engines_handler.h" @@ -25,6 +26,7 @@ #include "components/grit/brave_components_resources.h" #include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_service.h" +#include "content/public/browser/page_navigator.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" 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 3ae4d1741414..ec212517abfa 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 @@ -6,10 +6,7 @@ Crypto Wallets - - - diff --git a/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.tsx b/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.tsx index 29865741c7e3..dd0b0bdce034 100644 --- a/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.tsx +++ b/browser/ui/webui/ethereum_remote_client/ethereum_remote_client_page.tsx @@ -15,6 +15,7 @@ import LegacyApp from './components/legacy_app' import Theme from 'brave-ui/theme/brave-default' import DarkTheme from 'brave-ui/theme/brave-dark' import BraveCoreThemeProvider from '../../../../components/common/BraveCoreThemeProvider' +import { loadTimeData } from '../../../../components/common/loadTimeData' function initialize () { chrome.braveWallet.shouldPromptForSetup((prompt: boolean) => { @@ -31,10 +32,7 @@ function initialize () { function renderUI () { new Promise(resolve => chrome.braveTheme.getBraveThemeType(resolve)) .then((themeType: chrome.braveTheme.ThemeType) => { - window.i18nTemplate.process(window.document, window.loadTimeData) - if (window.loadTimeData && window.loadTimeData.data_) { - initLocale(window.loadTimeData.data_) - } + initLocale(loadTimeData.data_) render( 0: - print >> sys.stderr, parser.get_usage() - return 1 - - # sign file with dsa - file = open(options.output, 'w') - command = [options.sign_update_path, options.target, options.sign_key_file] - try: - subprocess.check_call(command, stdout=file) - except subprocess.CalledProcessError as e: - print(e.output) - raise e - file.close() - - return 0 - - -if __name__ == '__main__': - sys.exit(Main(sys.argv[1:])) diff --git a/build/mac/generate_eddsa_sig.py b/build/mac/generate_eddsa_sig.py deleted file mode 100644 index 48879dba1b5d..000000000000 --- a/build/mac/generate_eddsa_sig.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python - -# 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 optparse -import subprocess -import sys - - -def Main(argv): - parser = optparse.OptionParser('%prog [options]') - parser.add_option('--sign-update', dest='sign_update_path', action='store', - type='string', default=None, help='The path of sign_update binary') - parser.add_option('--sign-key', dest='sign_key', action='store', - type='string', default=None, help='The private key to sign patch file') - parser.add_option('--target', dest='target', action='store', - type='string', default=None, help='Target file path for signing.') - parser.add_option('--output', dest='output', action='store', - type='string', default=None, help='The path of eddsa output.') - (options, args) = parser.parse_args(argv) - - if len(args) > 0: - print >> sys.stderr, parser.get_usage() - return 1 - - # sign file with eddsa - file = open(options.output, 'w') - command = [options.sign_update_path, '-s', options.sign_key, options.target] - try: - subprocess.check_call(command, stdout=file) - except subprocess.CalledProcessError as e: - print(e.output) - raise e - file.close() - - return 0 - - -if __name__ == '__main__': - sys.exit(Main(sys.argv[1:])) diff --git a/build/mac/generate_sig.py b/build/mac/generate_sig.py new file mode 100644 index 000000000000..e31d7e2e5b39 --- /dev/null +++ b/build/mac/generate_sig.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +# 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 argparse +import subprocess +import sys + + +def Main(): + parser = argparse.ArgumentParser(usage='%(prog)s [options]') + parser.add_argument('--sign-update', dest='sign_update_path', action='store', + help='The path of sign_update binary', required=True) + group_key = parser.add_mutually_exclusive_group(required=True) + group_key.add_argument('--sign-key-file', dest='sign_key_file', action='store', + help='The private key file to sign dmg file') + group_key.add_argument('--sign-key', dest='sign_key', action='store', + help='The private key to sign dmg or patch file') + parser.add_argument('--target', dest='target', action='store', + help='Target file path for signing.', required=True) + parser.add_argument('--output', dest='output', action='store', + help='The path of the output.', required=True) + group_algorithm = parser.add_mutually_exclusive_group(required=True) + group_algorithm.add_argument("--dsa", action="store_true", help='Use DSA') + group_algorithm.add_argument("--eddsa", action="store_true", help='Use EdDSA') + args = parser.parse_args() + + # sign file with the specified algorithm + with open(args.output, 'w') as file: + if args.dsa: + if not args.sign_key_file: + print('--sign-key-file argument is required with --dsa.', file=sys.stderr) + return 1 + command = [args.sign_update_path, args.target, args.sign_key_file] + if args.eddsa: + if not args.sign_key: + print('--sign-key argument is required with --eddsa.', file=sys.stderr) + return 1 + command = [args.sign_update_path, '-s', args.sign_key, args.target] + try: + subprocess.check_call(command, stdout=file) + except subprocess.CalledProcessError as e: + print(e.output) + raise e + + return 0 + + +if __name__ == '__main__': + sys.exit(Main()) diff --git a/build/mac/tweak_info_plist.py b/build/mac/tweak_info_plist.py index 703b3f559a13..9d636c75d348 100644 --- a/build/mac/tweak_info_plist.py +++ b/build/mac/tweak_info_plist.py @@ -1,5 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# 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/. @@ -20,113 +21,103 @@ # by the time the app target is done, the info.plist is correct. # -import optparse -import os +import argparse import plistlib -import re import subprocess import sys import tempfile def _ConvertPlist(source_plist, output_plist, fmt): - """Convert |source_plist| to |fmt| and save as |output_plist|.""" - return subprocess.call( - ['plutil', '-convert', fmt, '-o', output_plist, source_plist]) + """Convert |source_plist| to |fmt| and save as |output_plist|.""" + return subprocess.call( + ['plutil', '-convert', fmt, '-o', output_plist, source_plist]) def _RemoveKeys(plist, *keys): - """Removes a varargs of keys from the plist.""" - for key in keys: - try: - del plist[key] - except KeyError: - pass + """Removes a varargs of keys from the plist.""" + for key in keys: + try: + del plist[key] + except KeyError: + pass def _OverrideVersionKey(plist, brave_version): - """ `minor.build` version string is used for update. - When we begin to use the Major version component, Brave version string will - be `1.0.0` for example and `Minor.Build` (`0.0`) would be used for update - check. Without modifying these numbers, update will fail as `0.0` is lower - than `70.121` for example. - - To ensure minor version is higher than existing minor versions, we can - multiply the major version by 100 and set it to `CFBundleVersion`.""" - version_values = brave_version.split('.') - if int(version_values[0]) >= 1: - adjusted_minor = int(version_values[1]) + (100 * int(version_values[0])) - plist['CFBundleVersion'] = str(adjusted_minor) + '.' + version_values[2] - - -def Main(argv): - parser = optparse.OptionParser('%prog [options]') - parser.add_option('--plist', dest='plist_path', action='store', - type='string', default=None, help='The path of the plist to tweak.') - parser.add_option('--output', dest='plist_output', action='store', - type='string', default=None, help='If specified, the path to output ' + \ - 'the tweaked plist, rather than overwriting the input.') - parser.add_option('--brave_channel', dest='brave_channel', action='store', - type='string', default=None, help='Channel (beta, dev, nightly)') - parser.add_option('--brave_product_dir_name', dest='brave_product_dir_name', - action='store', type='string', default=None, - help='Product directory name') - parser.add_option('--brave_eddsa_key', dest='brave_eddsa_key', action='store', - type='string', default=None, help='Public EdDSA key for update') - parser.add_option('--brave_version', dest='brave_version', action='store', - type='string', default=None, help='brave version string') - parser.add_option('--format', choices=('binary1', 'xml1', 'json'), - default='xml1', help='Format to use when writing property list ' - '(default: %(default)s)') - parser.add_option('--skip_signing', dest='skip_signing', action='store_true') - (options, args) = parser.parse_args(argv) - - if len(args) > 0: - print >>sys.stderr, parser.get_usage() - return 1 - - if not options.plist_path: - print >>sys.stderr, 'No --plist specified.' - return 1 - - # Read the plist into its parsed format. Convert the file to 'xml1' as - # plistlib only supports that format in Python 2.7. - with tempfile.NamedTemporaryFile() as temp_info_plist: - retcode = _ConvertPlist(options.plist_path, temp_info_plist.name, 'xml1') - if retcode != 0: - return retcode - plist = plistlib.readPlist(temp_info_plist.name) - - output_path = options.plist_path - if options.plist_output is not None: - output_path = options.plist_output - - if options.skip_signing: - plist['KSChannelID'] = options.brave_channel - elif 'KSChannelID' in plist: - # 'KSChannelID' is set at _modify_plists() of modification.py. - del plist['KSChannelID'] - - plist['CrProductDirName'] = options.brave_product_dir_name - - if options.brave_eddsa_key: - plist['SUPublicEDKey'] = options.brave_eddsa_key - - _OverrideVersionKey(plist, options.brave_version) - - # Explicitly disable profiling - plist['SUEnableSystemProfiling'] = False - - # Explicitly change notifications from banner to alert - plist['NSUserNotificationAlertStyle'] = 'alert' - - # Now that all keys have been mutated, rewrite the file. - with tempfile.NamedTemporaryFile() as temp_info_plist: - plistlib.writePlist(plist, temp_info_plist.name) - - # Convert Info.plist to the format requested by the --format flag. Any - # format would work on Mac but iOS requires specific format. - return _ConvertPlist(temp_info_plist.name, output_path, options.format) + """ `minor.build` version string is used for update. + When we begin to use the Major version component, Brave version string will + be `1.0.0` for example and `Minor.Build` (`0.0`) would be used for update + check. Without modifying these numbers, update will fail as `0.0` is lower + than `70.121` for example. + + To ensure minor version is higher than existing minor versions, we can + multiply the major version by 100 and set it to `CFBundleVersion`.""" + version_values = brave_version.split('.') + if int(version_values[0]) >= 1: + adjusted_minor = int(version_values[1]) + (100 * int(version_values[0])) + plist['CFBundleVersion'] = str(adjusted_minor) + '.' + version_values[2] + + +def Main(): + parser = argparse.ArgumentParser(usage='%(prog)s [options]') + parser.add_argument('--plist', dest='plist_path', action='store', + required=True, help='The path of the plist to tweak.') + parser.add_argument('--output', dest='plist_output', action='store', + default=None, help='If specified, the path to output ' + \ + 'the tweaked plist, rather than overwriting the input.') + parser.add_argument('--brave_channel', dest='brave_channel', action='store', + default=None, help='Channel (beta, dev, nightly)') + parser.add_argument('--brave_product_dir_name', dest='brave_product_dir_name', + action='store', default=None, + help='Product directory name') + parser.add_argument('--brave_eddsa_key', dest='brave_eddsa_key', action='store', + default=None, help='Public EdDSA key for update') + parser.add_argument('--brave_version', dest='brave_version', action='store', + default=None, help='brave version string') + parser.add_argument('--format', choices=('binary1', 'xml1', 'json'), + default='xml1', help='Format to use when writing property list ' + '(default: %(default)s)') + parser.add_argument('--skip_signing', dest='skip_signing', action='store_true') + args = parser.parse_args() + + # Read the plist into its parsed format. Convert the file to 'xml1' as + # plistlib only supports that format in Python 2.7. + with tempfile.NamedTemporaryFile() as temp_info_plist: + retcode = _ConvertPlist(args.plist_path, temp_info_plist.name, 'xml1') + if retcode != 0: + return retcode + plist = plistlib.readPlist(temp_info_plist.name) + + output_path = args.plist_path + if args.plist_output is not None: + output_path = args.plist_output + + if args.skip_signing: + plist['KSChannelID'] = args.brave_channel + elif 'KSChannelID' in plist: + # 'KSChannelID' is set at _modify_plists() of modification.py. + del plist['KSChannelID'] + + plist['CrProductDirName'] = args.brave_product_dir_name + + if args.brave_eddsa_key: + plist['SUPublicEDKey'] = args.brave_eddsa_key + + _OverrideVersionKey(plist, args.brave_version) + + # Explicitly disable profiling + plist['SUEnableSystemProfiling'] = False + + # Explicitly change notifications from banner to alert + plist['NSUserNotificationAlertStyle'] = 'alert' + + # Now that all keys have been mutated, rewrite the file. + with tempfile.NamedTemporaryFile() as temp_info_plist: + plistlib.writePlist(plist, temp_info_plist.name) + + # Convert Info.plist to the format requested by the --format flag. Any + # format would work on Mac but iOS requires specific format. + return _ConvertPlist(temp_info_plist.name, output_path, args.format) if __name__ == '__main__': - sys.exit(Main(sys.argv[1:])) + sys.exit(Main()) diff --git a/chromium_src/chrome/browser/DEPS b/chromium_src/chrome/browser/DEPS index 590bc3ad95b0..0a64cdbdd4d5 100644 --- a/chromium_src/chrome/browser/DEPS +++ b/chromium_src/chrome/browser/DEPS @@ -98,6 +98,7 @@ include_rules = [ "+components/gcm_driver/gcm_buildflags.h", "+components/grit/brave_components_resources.h", "+components/grit/brave_components_strings.h", + "+components/infobars/content", "+components/infobars/core", "+components/keep_alive_registry", "+components/keyed_service/content", diff --git a/chromium_src/chrome/browser/flags/android/chrome_feature_list.cc b/chromium_src/chrome/browser/flags/android/chrome_feature_list.cc index f9e9e0dc4502..ff0e005346b0 100644 --- a/chromium_src/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chromium_src/chrome/browser/flags/android/chrome_feature_list.cc @@ -26,9 +26,9 @@ const base::Feature* kBraveFeaturesExposedToJava[] = { const base::Feature* BraveFindFeatureExposedToJava( const std::string& feature_name) { - for (size_t i = 0; i < base::size(kBraveFeaturesExposedToJava); ++i) { - if (kBraveFeaturesExposedToJava[i]->name == feature_name) - return kBraveFeaturesExposedToJava[i]; + for (const base::Feature* feature : kBraveFeaturesExposedToJava) { + if (feature->name == feature_name) + return feature; } return nullptr; diff --git a/chromium_src/chrome/browser/importer/importer_list.cc b/chromium_src/chrome/browser/importer/importer_list.cc index 22ca18abc20e..89b672ffac64 100644 --- a/chromium_src/chrome/browser/importer/importer_list.cc +++ b/chromium_src/chrome/browser/importer/importer_list.cc @@ -17,7 +17,7 @@ void AddChromeToProfiles(std::vector* profiles, base::ListValue* chrome_profiles, const base::FilePath& user_data_folder, const std::string& brand) { - for (const auto& value : *chrome_profiles) { + for (const auto& value : chrome_profiles->GetList()) { const base::DictionaryValue* dict; if (!value.GetAsDictionary(&dict)) continue; diff --git a/chromium_src/chrome/browser/media/router/media_router_feature_browsertest.cc b/chromium_src/chrome/browser/media/router/media_router_feature_browsertest.cc index 2c7658dea34f..5e627da5ee64 100644 --- a/chromium_src/chrome/browser/media/router/media_router_feature_browsertest.cc +++ b/chromium_src/chrome/browser/media/router/media_router_feature_browsertest.cc @@ -5,6 +5,7 @@ #include "chrome/browser/media/router/media_router_feature.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" diff --git a/chromium_src/chrome/browser/notifications/notification_handler.h b/chromium_src/chrome/browser/notifications/notification_handler.h index f0983370ab1c..10006d9118f7 100644 --- a/chromium_src/chrome/browser/notifications/notification_handler.h +++ b/chromium_src/chrome/browser/notifications/notification_handler.h @@ -10,6 +10,8 @@ #include "../../../../../chrome/browser/notifications/notification_handler.h" #undef NotificationHandler +#include "base/check.h" + class NotificationHandler : public NotificationHandler_ChromiumImpl { public: // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.notifications diff --git a/chromium_src/chrome/browser/profiles/profile.cc b/chromium_src/chrome/browser/profiles/profile.cc index 2e9eb5e2b45f..6ada7ec21d77 100644 --- a/chromium_src/chrome/browser/profiles/profile.cc +++ b/chromium_src/chrome/browser/profiles/profile.cc @@ -18,6 +18,12 @@ const Profile::OTRProfileID Profile::OTRProfileID::TorID() { return OTRProfileID(tor::kTorProfileID); } +// static +Profile::OTRProfileID Profile::OTRProfileID::CreateFromProfileID( + const std::string& profile_id) { + return OTRProfileID(profile_id); +} + bool Profile::IsTor() const { return IsOffTheRecord() && GetOTRProfileID() == OTRProfileID::TorID(); } diff --git a/chromium_src/chrome/browser/profiles/profile.h b/chromium_src/chrome/browser/profiles/profile.h index d2caf12083c4..f58442bf73ba 100644 --- a/chromium_src/chrome/browser/profiles/profile.h +++ b/chromium_src/chrome/browser/profiles/profile.h @@ -7,13 +7,17 @@ #define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_PROFILE_H_ #define PrimaryID PrimaryID(); static const OTRProfileID TorID +#define CreateUniqueForTesting \ + CreateFromProfileID(const std::string& profile_id); \ + static OTRProfileID CreateUniqueForTesting #define HasPrimaryOTRProfile IsTor() const override; bool HasPrimaryOTRProfile #define IsIncognitoProfile \ IsIncognitoProfile_ChromiumImpl() const; \ bool IsIncognitoProfile #include "../../../../../chrome/browser/profiles/profile.h" #undef IsIncognitoProfile -#undef PrimaryID #undef HasPrimaryOTRProfile +#undef CreateUniqueForTesting +#undef PrimaryID #endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_PROFILE_H_ diff --git a/chromium_src/chrome/browser/profiles/profile_avatar_icon_util.cc b/chromium_src/chrome/browser/profiles/profile_avatar_icon_util.cc index 1836887524b0..a3ae0d3bf3b4 100644 --- a/chromium_src/chrome/browser/profiles/profile_avatar_icon_util.cc +++ b/chromium_src/chrome/browser/profiles/profile_avatar_icon_util.cc @@ -188,7 +188,7 @@ gfx::Image GetPlaceholderAvatarIconWithColors(SkColor fill_color, // GetPlaceholderAvatarIconWithColors function above which is used in this // function. Also, changes the label from "Default Avatar" to our placeholder // avatar name. -std::unique_ptr GetDefaultProfileAvatarIconAndLabel( +base::flat_map GetDefaultProfileAvatarIconAndLabel( SkColor fill_color, SkColor stroke_color, bool selected) { diff --git a/chromium_src/chrome/browser/profiles/profile_avatar_icon_util_unittest.cc b/chromium_src/chrome/browser/profiles/profile_avatar_icon_util_unittest.cc index cf594e700357..b3e7da40da90 100644 --- a/chromium_src/chrome/browser/profiles/profile_avatar_icon_util_unittest.cc +++ b/chromium_src/chrome/browser/profiles/profile_avatar_icon_util_unittest.cc @@ -23,12 +23,12 @@ TEST(ProfileUtilTest, KeepChromiumChoice) { TEST(ProfileUtilTest, BraveAvatarIconChoices) { // Test that the avatar icon choices presented to the user are brave's. - std::unique_ptr avatars( + std::vector avatars( profiles::GetCustomProfileAvatarIconsAndLabels(0)); const size_t expected_selectable_avatar_count = profiles::kBraveDefaultAvatarIconsCount; - const size_t actual_selectable_avatar_count = avatars->GetSize(); + const size_t actual_selectable_avatar_count = avatars.size(); // Avatars are Brave's, not Chromium's EXPECT_EQ(actual_selectable_avatar_count, @@ -49,4 +49,3 @@ TEST(ProfileUtilTest, RandomIconNeverFirstIcon) { } } // namespace - diff --git a/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc b/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc index b9717db681df..627b8d1aaca0 100644 --- a/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc +++ b/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc @@ -69,7 +69,7 @@ TEST(AccountConsistencyDisabledTest, DiceFixAuthErrorsForAllProfiles) { // Incognito profile. Profile* incognito_profile = profile.GetOffTheRecordProfile( - Profile::OTRProfileID::PrimaryID()); + Profile::OTRProfileID::PrimaryID(), /*create_if_needed=*/true); EXPECT_FALSE(AccountConsistencyModeManager::IsDiceEnabledForProfile( incognito_profile)); EXPECT_FALSE( diff --git a/chromium_src/chrome/browser/sync/sync_ui_util.cc b/chromium_src/chrome/browser/sync/sync_ui_util.cc index c35054a8d567..57dd2eb8cceb 100644 --- a/chromium_src/chrome/browser/sync/sync_ui_util.cc +++ b/chromium_src/chrome/browser/sync/sync_ui_util.cc @@ -9,11 +9,11 @@ namespace sync_ui_util { -AvatarSyncErrorType GetAvatarSyncErrorType(Profile* profile) { +absl::optional GetAvatarSyncErrorType(Profile* profile) { // Brave Sync works differently in that there is no sign-in // and nothing to prompt the user to manage once their sync // chain is setup. - return NO_SYNC_ERROR; + return absl::nullopt; } } // namespace sync_ui_util diff --git a/chromium_src/chrome/browser/ui/browser.h b/chromium_src/chrome/browser/ui/browser.h index d2d00017dfdd..8aced4a5ba4a 100644 --- a/chromium_src/chrome/browser/ui/browser.h +++ b/chromium_src/chrome/browser/ui/browser.h @@ -7,6 +7,7 @@ #define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_BROWSER_H_ #define ScheduleUIUpdate virtual ScheduleUIUpdate +#define ShouldDisplayFavicon virtual ShouldDisplayFavicon #define BRAVE_BROWSER_H \ private: \ friend class BookmarkPrefsService; \ @@ -16,5 +17,6 @@ #undef BRAVE_BROWSER_H #undef ScheduleUIUpdate +#undef ShouldDisplayFavicon #endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_BROWSER_H_ diff --git a/chromium_src/chrome/browser/ui/browser_navigator.cc b/chromium_src/chrome/browser/ui/browser_navigator.cc index 25e9ac681c8f..28a8b0c83339 100644 --- a/chromium_src/chrome/browser/ui/browser_navigator.cc +++ b/chromium_src/chrome/browser/ui/browser_navigator.cc @@ -45,7 +45,8 @@ void MaybeHandleInParent(NavigateParams* params, bool allow_in_incognito) { if (!allow_in_incognito) { params->initiating_profile = profile->IsOffTheRecord() - ? brave::GetParentProfile(profile)->GetPrimaryOTRProfile() + ? brave::GetParentProfile(profile)->GetPrimaryOTRProfile( + /*create_if_needed=*/true) : brave::GetParentProfile(profile); } else if (HandleURLInParent(params, profile)) { params->browser = BraveGetOrCreateBrowser( diff --git a/chromium_src/chrome/browser/ui/browser_tabrestore.cc b/chromium_src/chrome/browser/ui/browser_tabrestore.cc index f34feb63e8df..821b53f6fb52 100644 --- a/chromium_src/chrome/browser/ui/browser_tabrestore.cc +++ b/chromium_src/chrome/browser/ui/browser_tabrestore.cc @@ -42,7 +42,7 @@ WebContents* AddRestoredTab( int tab_index, int selected_navigation, const std::string& extension_app_id, - base::Optional group, + absl::optional group, bool select, bool pin, base::TimeTicks last_active_time, diff --git a/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc b/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc index bdc35b363635..c9ba48b4a897 100644 --- a/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc +++ b/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc @@ -19,15 +19,17 @@ #undef BRAVE_ICON_WITH_BADGE_IMAGE_SOURCE_DRAW_2 #undef BRAVE_ICON_WITH_BADGE_IMAGE_SOURCE_DRAW_1 +#include "third_party/abseil-cpp/absl/types/optional.h" + // Implement default virtual methods -base::Optional IconWithBadgeImageSource::GetCustomGraphicSize() { - return base::nullopt; +absl::optional IconWithBadgeImageSource::GetCustomGraphicSize() { + return absl::nullopt; } -base::Optional IconWithBadgeImageSource::GetCustomGraphicXOffset() { - return base::nullopt; +absl::optional IconWithBadgeImageSource::GetCustomGraphicXOffset() { + return absl::nullopt; } -base::Optional IconWithBadgeImageSource::GetCustomGraphicYOffset() { - return base::nullopt; +absl::optional IconWithBadgeImageSource::GetCustomGraphicYOffset() { + return absl::nullopt; } diff --git a/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.h b/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.h index 45a2284b2af1..762ff820e2a4 100644 --- a/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.h +++ b/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.h @@ -11,12 +11,12 @@ class BraveActionIconWithBadgeImageSource; #define BRAVE_ICON_WITH_BADGE_IMAGE_SOURCE_H_ \ private: \ friend class BraveActionIconWithBadgeImageSource; \ - virtual base::Optional GetCustomGraphicSize(); \ - virtual base::Optional GetCustomGraphicXOffset(); \ - virtual base::Optional GetCustomGraphicYOffset(); \ + virtual absl::optional GetCustomGraphicSize(); \ + virtual absl::optional GetCustomGraphicXOffset(); \ + virtual absl::optional GetCustomGraphicYOffset(); \ \ public: \ -// #define BRAVE_ICON_WITH_BADGE_IMAGE_SOURCE_H_ + // #define BRAVE_ICON_WITH_BADGE_IMAGE_SOURCE_H_ #define PaintBadge virtual PaintBadge #define GetIconAreaRect virtual GetIconAreaRect diff --git a/chromium_src/chrome/browser/ui/layout_constants.cc b/chromium_src/chrome/browser/ui/layout_constants.cc index 7f1ea301b13c..adf12a33b15a 100644 --- a/chromium_src/chrome/browser/ui/layout_constants.cc +++ b/chromium_src/chrome/browser/ui/layout_constants.cc @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2018 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/. */ @@ -10,7 +11,7 @@ int GetLayoutConstant(LayoutConstant constant) { // get brave overriden value - const base::Optional braveOption = GetBraveLayoutConstant(constant); + const absl::optional braveOption = GetBraveLayoutConstant(constant); if (braveOption) { return braveOption.value(); } diff --git a/chromium_src/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chromium_src/chrome/browser/ui/startup/startup_browser_creator_impl.cc index bdae7bb1638a..992520fdf958 100644 --- a/chromium_src/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chromium_src/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -5,13 +5,14 @@ #include "brave/browser/ui/startup/default_brave_browser_prompt.h" #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" +#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/confirm_infobar_delegate.h" #define GoogleApiKeysInfoBarDelegate BraveGoogleKeysInfoBarDelegate class BraveGoogleKeysInfoBarDelegate { public: - static void Create(InfoBarService* infobar_service) { + static void Create(infobars::ContentInfoBarManager* infobar_manager) { // lulz } }; diff --git a/chromium_src/chrome/browser/ui/tabs/tab_renderer_data.cc b/chromium_src/chrome/browser/ui/tabs/tab_renderer_data.cc new file mode 100644 index 000000000000..55eb9602cd4c --- /dev/null +++ b/chromium_src/chrome/browser/ui/tabs/tab_renderer_data.cc @@ -0,0 +1,28 @@ +/* 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/. */ + +#include "chrome/browser/ui/tabs/tab_renderer_data.h" + +#define FromTabInModel FromTabInModel_ChromiumImpl +#include "../../../../../../chrome/browser/ui/tabs/tab_renderer_data.cc" +#undef FromTabInModel + +#include "brave/common/webui_url_constants.h" +#include "url/gurl.h" + +TabRendererData TabRendererData::FromTabInModel(TabStripModel* model, + int index) { + auto data = FromTabInModel_ChromiumImpl(model, index); + if (data.should_themify_favicon) { + content::WebContents* const contents = model->GetWebContentsAt(index); + const GURL& url = contents->GetVisibleURL(); + if (url.SchemeIs(content::kChromeUIScheme) && + (url.host_piece() == kWelcomeHost || + url.host_piece() == kRewardsPageHost)) { + data.should_themify_favicon = false; + } + } + return data; +} diff --git a/chromium_src/chrome/browser/ui/tabs/tab_renderer_data.h b/chromium_src/chrome/browser/ui/tabs/tab_renderer_data.h new file mode 100644 index 000000000000..3e2d17ac42cf --- /dev/null +++ b/chromium_src/chrome/browser/ui/tabs/tab_renderer_data.h @@ -0,0 +1,16 @@ +/* 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/. */ + +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_TABS_TAB_RENDERER_DATA_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_TABS_TAB_RENDERER_DATA_H_ + +#define FromTabInModel \ + FromTabInModel_ChromiumImpl(TabStripModel* model, int index); \ + static TabRendererData FromTabInModel + +#include "../../../../../../chrome/browser/ui/tabs/tab_renderer_data.h" +#undef FromTabInModel + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_TABS_TAB_RENDERER_DATA_H_ diff --git a/chromium_src/chrome/browser/ui/views/download/download_item_view.cc b/chromium_src/chrome/browser/ui/views/download/download_item_view.cc index 296349881bba..30afe6c7fd50 100644 --- a/chromium_src/chrome/browser/ui/views/download/download_item_view.cc +++ b/chromium_src/chrome/browser/ui/views/download/download_item_view.cc @@ -6,5 +6,5 @@ #include "../../../../../../../chrome/browser/ui/views/download/download_item_view.cc" bool DownloadItemView::IsShowingWarningDialog() const { - return is_download_warning(mode_); + return has_warning_label(mode_); } diff --git a/chromium_src/chrome/browser/ui/views/download/download_item_view.h b/chromium_src/chrome/browser/ui/views/download/download_item_view.h index e9d35097a70a..fe4b55c8a99c 100644 --- a/chromium_src/chrome/browser/ui/views/download/download_item_view.h +++ b/chromium_src/chrome/browser/ui/views/download/download_item_view.h @@ -6,6 +6,33 @@ #ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ #define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ +// Note: SetMode method name is quite common. To re-define only SetMode in +// download_item_view.h, all the original headers need to be added. +#include "base/files/file_path.h" +#include "base/memory/weak_ptr.h" +#include "base/scoped_observation.h" +#include "base/task/cancelable_task_tracker.h" +#include "base/time/time.h" +#include "base/timer/timer.h" +#include "chrome/browser/download/download_commands.h" +#include "chrome/browser/download/download_ui_model.h" +#include "chrome/browser/icon_loader.h" +#include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" +#include "third_party/abseil-cpp/absl/types/optional.h" +#include "ui/base/metadata/metadata_header_macros.h" +#include "ui/base/models/image_model.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_types.h" +#include "ui/gfx/animation/slide_animation.h" +#include "ui/gfx/animation/throb_animation.h" +#include "ui/gfx/geometry/size.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" +#include "ui/views/animation/animation_delegate_views.h" +#include "ui/views/context_menu_controller.h" +#include "ui/views/controls/button/button.h" +#include "ui/views/view.h" + #define BRAVE_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ \ private: \ friend class BraveDownloadItemView; \ diff --git a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc index 14002f66295e..ad097934cc4e 100644 --- a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc +++ b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.cc @@ -17,7 +17,7 @@ BraveAvatarToolbarButtonDelegate::BraveAvatarToolbarButtonDelegate( AvatarToolbarButton::State BraveAvatarToolbarButtonDelegate::GetState() const { AvatarToolbarButton::State state = AvatarToolbarButtonDelegate::GetState(); - if (state == AvatarToolbarButton::State::kGenericProfile) { + if (state == AvatarToolbarButton::State::kNormal) { ProfileAttributesEntry* entry = g_browser_process->profile_manager() ->GetProfileAttributesStorage() diff --git a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h index 5993f8bd2329..08b8d438bd22 100644 --- a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h +++ b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h @@ -13,7 +13,6 @@ #include "base/scoped_observer.h" #include "build/build_config.h" #include "chrome/browser/profiles/profile_attributes_storage.h" -#include "chrome/browser/ui/avatar_button_error_controller_delegate.h" #include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" #include "components/signin/public/identity_manager/identity_manager.h" diff --git a/chromium_src/chrome/browser/ui/views/profiles/profile_menu_view.cc b/chromium_src/chrome/browser/ui/views/profiles/profile_menu_view.cc new file mode 100644 index 000000000000..6d121f3a8c2d --- /dev/null +++ b/chromium_src/chrome/browser/ui/views/profiles/profile_menu_view.cc @@ -0,0 +1,15 @@ +/* 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/. */ + +#include "chrome/app/vector_icons/vector_icons.h" +#include "ui/gfx/vector_icon_types.h" + +namespace { +constexpr gfx::VectorIcon kGuestMenuEmptyArtIcon; +} // namespace + +#define kGuestMenuArtIcon kGuestMenuEmptyArtIcon +#include "../../../../../../../chrome/browser/ui/views/profiles/profile_menu_view.cc" +#undef kGuestMenuArtIcon diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab_icon.cc b/chromium_src/chrome/browser/ui/views/tabs/tab_icon.cc deleted file mode 100644 index fb341d8c9710..000000000000 --- a/chromium_src/chrome/browser/ui/views/tabs/tab_icon.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* 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/. */ - -#include "brave/common/webui_url_constants.h" -#include "url/gurl.h" - -namespace { -// Forward delcare replacement function. The original file is patched to -// call this replacement. -bool BraveShouldThemifyFaviconForUrl(const GURL& url); -} // namespace - -#define ShouldThemifyFaviconForUrl ShouldThemifyFaviconForUrl_ChromiumImpl -#include "../../../../../../../chrome/browser/ui/views/tabs/tab_icon.cc" -#undef ShouldThemifyFaviconForUrl - -namespace { -// Implementation of the replacement function checks for Brave-specific URLs for -// which the favicon should not be themified and then falls back onto the -// original Chromium implementation for all other URLs. -bool BraveShouldThemifyFaviconForUrl(const GURL& url) { - if (url.SchemeIs(content::kChromeUIScheme) && - (url.host_piece() == kWelcomeHost || - url.host_piece() == kRewardsPageHost)) - return false; - - return ShouldThemifyFaviconForUrl_ChromiumImpl(url); -} -} // namespace diff --git a/chromium_src/chrome/browser/ui/webui/app_launcher_login_handler.cc b/chromium_src/chrome/browser/ui/webui/app_launcher_login_handler.cc deleted file mode 100644 index 2e64e335857b..000000000000 --- a/chromium_src/chrome/browser/ui/webui/app_launcher_login_handler.cc +++ /dev/null @@ -1,28 +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/. */ - -#include "chrome/browser/ui/webui/app_launcher_login_handler.h" -#include "base/values.h" - -#define RegisterMessages RegisterMessages_ChromiumImpl -#include "../../../../../../chrome/browser/ui/webui/app_launcher_login_handler.cc" -#undef RegisterMessages - -namespace { -void DummyCallback() {} -void DummyWebUICallback(const base::ListValue* args) {} -} // namespace - -void AppLauncherLoginHandler::RegisterMessages() { - // WebUIMessageCallbacks are emplaced in the map - // if the key exists in the WebUIs message_callback_ - // insertion will be ignored - web_ui()->RegisterMessageCallback("initializeSyncLogin", - base::BindRepeating(&DummyWebUICallback)); - - AppLauncherLoginHandler::RegisterMessages_ChromiumImpl(); - profile_info_watcher_ = std::make_unique( - Profile::FromWebUI(web_ui()), base::BindRepeating(DummyCallback)); -} diff --git a/chromium_src/chrome/browser/ui/webui/app_launcher_login_handler.h b/chromium_src/chrome/browser/ui/webui/app_launcher_login_handler.h deleted file mode 100644 index dc531fdc877e..000000000000 --- a/chromium_src/chrome/browser/ui/webui/app_launcher_login_handler.h +++ /dev/null @@ -1,17 +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/. */ - -#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_LOGIN_HANDLER_H_ -#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_LOGIN_HANDLER_H_ - -#include "content/public/browser/web_ui_message_handler.h" - -#define RegisterMessages \ - RegisterMessages_ChromiumImpl(); \ - virtual void RegisterMessages -#include "../../../../../../chrome/browser/ui/webui/app_launcher_login_handler.h" -#undef RegisterMessages - -#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_LOGIN_HANDLER_H_ diff --git a/chromium_src/chrome/browser/ui/webui/help/version_updater_mac.mm b/chromium_src/chrome/browser/ui/webui/help/version_updater_mac.mm index 581fd8e52d81..7f654e0d5d97 100644 --- a/chromium_src/chrome/browser/ui/webui/help/version_updater_mac.mm +++ b/chromium_src/chrome/browser/ui/webui/help/version_updater_mac.mm @@ -184,13 +184,13 @@ - (void)handleStatusNotification:(NSNotification*)notification { if (status == FAILED) { if (!message.empty()) { - message += base::UTF8ToUTF16("

"); + message += u"

"; } message += l10n_util::GetStringUTF16(IDS_UPGRADE_ERROR_DETAILS); - message += base::UTF8ToUTF16("

");
+      message += u"
";
       message += base::UTF8ToUTF16(net::EscapeForHTML(error_messages));
-      message += base::UTF8ToUTF16("
"); + message += u"
"; } } diff --git a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index 83f6dfd72835..7375c26a3b6b 100644 --- a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -48,21 +48,22 @@ void BraveAddLocalizedStrings(content::WebUIDataSource*, Profile*); #include "brave/browser/ui/webui/brave_settings_ui.h" namespace settings { -const char kWebRTCLearnMoreURL[] = - "https://support.brave.com/hc/en-us/articles/" - "360017989132-How-do-I-change-my-Privacy-Settings-#webrtc"; -const char kBraveBuildInstructionsUrl[] = - "https://github.com/brave/brave-browser/wiki"; -const char kBraveLicenseUrl[] = "https://mozilla.org/MPL/2.0/"; -const char kBraveReleaseTagPrefix[] = - "https://github.com/brave/brave-browser/releases/tag/v"; -const char kGoogleLoginLearnMoreURL[] = - "https://github.com/brave/brave-browser/wiki/" - "Allow-Google-login---Third-Parties-and-Extensions"; -const char kDNSLinkLearnMoreURL[] = "https://docs.ipfs.io/concepts/dnslink/"; -const char kUnstoppableDomainsLearnMoreURL[] = - "https://github.com/brave/brave-browser/wiki/" - "Resolve-Methods-for-Unstoppable-Domains"; +const char16_t kWebRTCLearnMoreURL[] = + u"https://support.brave.com/hc/en-us/articles/" + u"360017989132-How-do-I-change-my-Privacy-Settings-#webrtc"; +const char16_t kBraveBuildInstructionsUrl[] = + u"https://github.com/brave/brave-browser/wiki"; +const char16_t kBraveLicenseUrl[] = u"https://mozilla.org/MPL/2.0/"; +const char16_t kBraveReleaseTagPrefix[] = + u"https://github.com/brave/brave-browser/releases/tag/v"; +const char16_t kGoogleLoginLearnMoreURL[] = + u"https://github.com/brave/brave-browser/wiki/" + u"Allow-Google-login---Third-Parties-and-Extensions"; +const char16_t kDNSLinkLearnMoreURL[] = + u"https://docs.ipfs.io/concepts/dnslink/"; +const char16_t kUnstoppableDomainsLearnMoreURL[] = + u"https://github.com/brave/brave-browser/wiki/" + u"Resolve-Methods-for-Unstoppable-Domains"; void BraveAddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) { @@ -298,14 +299,10 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, {"ipfsPeersNodeRestartButton", IDS_SETTINGS_IPFS_PEER_NODE_RESTART_BUTTON}, }; html_source->AddLocalizedStrings(localized_strings); - html_source->AddString("webRTCLearnMoreURL", - base::ASCIIToUTF16(kWebRTCLearnMoreURL)); - html_source->AddString("googleLoginLearnMoreURL", - base::ASCIIToUTF16(kGoogleLoginLearnMoreURL)); - html_source->AddString("ipfsDNSLinkLearnMoreURL", - base::UTF8ToUTF16(kDNSLinkLearnMoreURL)); - html_source->AddString("speedreaderLearnMoreURL", - base::UTF8ToUTF16(kSpeedreaderLearnMoreUrl)); + html_source->AddString("webRTCLearnMoreURL", kWebRTCLearnMoreURL); + html_source->AddString("googleLoginLearnMoreURL", kGoogleLoginLearnMoreURL); + html_source->AddString("ipfsDNSLinkLearnMoreURL", kDNSLinkLearnMoreURL); + html_source->AddString("speedreaderLearnMoreURL", kSpeedreaderLearnMoreUrl); html_source->AddString( "getMoreExtensionsUrl", base::ASCIIToUTF16( @@ -322,11 +319,10 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, base::ASCIIToUTF16(ipfs::kIPFSLearnMorePrivacyURL)); html_source->AddString("ipfsMethodDesc", ipfs_method_desc); - html_source->AddString( - "resolveUnstoppableDomainsSubDesc", - l10n_util::GetStringFUTF16( - IDS_SETTINGS_RESOLVE_UNSTOPPABLE_DOMAINS_SUB_DESC, - base::ASCIIToUTF16(kUnstoppableDomainsLearnMoreURL))); + html_source->AddString("resolveUnstoppableDomainsSubDesc", + l10n_util::GetStringFUTF16( + IDS_SETTINGS_RESOLVE_UNSTOPPABLE_DOMAINS_SUB_DESC, + kUnstoppableDomainsLearnMoreURL)); } void BraveAddResources(content::WebUIDataSource* html_source, @@ -337,10 +333,10 @@ void BraveAddResources(content::WebUIDataSource* html_source, void BraveAddAboutStrings(content::WebUIDataSource* html_source, Profile* profile) { std::u16string license = l10n_util::GetStringFUTF16( - IDS_BRAVE_VERSION_UI_LICENSE, base::ASCIIToUTF16(kBraveLicenseUrl), + IDS_BRAVE_VERSION_UI_LICENSE, kBraveLicenseUrl, base::ASCIIToUTF16(chrome::kChromeUICreditsURL), - base::ASCIIToUTF16(kBraveBuildInstructionsUrl), - base::ASCIIToUTF16(kBraveReleaseTagPrefix) + + kBraveBuildInstructionsUrl, + kBraveReleaseTagPrefix + base::UTF8ToUTF16( version_info::GetBraveVersionWithoutChromiumMajorVersion())); html_source->AddString("aboutProductLicense", license); diff --git a/chromium_src/chrome/browser/webauthn/chrome_authenticator_request_delegate.cc b/chromium_src/chrome/browser/webauthn/chrome_authenticator_request_delegate.cc deleted file mode 100644 index 0e32e16cd64b..000000000000 --- a/chromium_src/chrome/browser/webauthn/chrome_authenticator_request_delegate.cc +++ /dev/null @@ -1,21 +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/. - -#include "chrome/browser/webauthn/chrome_authenticator_request_delegate.h" - -#if defined(OS_APPLE) -#include "base/mac/foundation_util.h" - -#define BRAVE_WEBAUTHN_KEYCHAIN_ACCESS_GROUP \ - const std::vector& kBraveKeyChainAccessParts = { \ - "KL8N8XSYF4", base::mac::BaseBundleID(), "webauthn"}; \ - return TouchIdAuthenticatorConfig{ \ - base::JoinString(kBraveKeyChainAccessParts, "."), \ - std::move(metadata_secret)}; -#else -#define BRAVE_WEBAUTHN_KEYCHAIN_ACCESS_GROUP void(0) -#endif - -#include "../../../../../chrome/browser/webauthn/chrome_authenticator_request_delegate.cc" diff --git a/chromium_src/chrome/common/chrome_constants.cc b/chromium_src/chrome/common/chrome_constants.cc index 104c1a0694a6..90299ac93a15 100644 --- a/chromium_src/chrome/common/chrome_constants.cc +++ b/chromium_src/chrome/common/chrome_constants.cc @@ -129,12 +129,12 @@ const base::FilePath::CharType kPreferencesFilename[] = FPL("Preferences"); const base::FilePath::CharType kPreviewsOptOutDBFilename[] = FPL("previews_opt_out.db"); const base::FilePath::CharType kQueryTileStorageDirname[] = FPL("Query Tiles"); -const base::FilePath::CharType kVideoTutorialsStorageDirname[] = - FPL("Video Tutorials"); const base::FilePath::CharType kReadmeFilename[] = FPL("README"); const base::FilePath::CharType kSecurePreferencesFilename[] = FPL("Secure Preferences"); const base::FilePath::CharType kServiceStateFileName[] = FPL("Service State"); +const base::FilePath::CharType kSegmentationPlatformStorageDirName[] = + FPL("Segmentation Platform"); const base::FilePath::CharType kSingletonCookieFilename[] = FPL("SingletonCookie"); const base::FilePath::CharType kSingletonLockFilename[] = FPL("SingletonLock"); @@ -144,6 +144,8 @@ const base::FilePath::CharType kSupervisedUserSettingsFilename[] = FPL("Managed Mode Settings"); const base::FilePath::CharType kThemePackFilename[] = FPL("Cached Theme.pak"); const base::FilePath::CharType kTrustTokenFilename[] = FPL("Trust Tokens"); +const base::FilePath::CharType kVideoTutorialsStorageDirname[] = + FPL("Video Tutorials"); const base::FilePath::CharType kWebAppDirname[] = FPL("Web Applications"); // Only use if the ENABLE_REPORTING build flag is true const base::FilePath::CharType kReportingAndNelStoreFilename[] = diff --git a/chromium_src/chrome/common/url_constants.cc b/chromium_src/chrome/common/url_constants.cc index a8926ff45c5b..1fb48acb4310 100644 --- a/chromium_src/chrome/common/url_constants.cc +++ b/chromium_src/chrome/common/url_constants.cc @@ -176,6 +176,10 @@ const char kSafeBrowsingHelpCenterURL[] = const char kSafetyTipHelpCenterURL[] = "https://support.brave.com/"; + +const char kSearchHistoryUrlInClearBrowsingData[] = + "https://support.brave.com/"; + const char kSeeMoreSecurityTipsURL[] = "https://support.brave.com/"; diff --git a/chromium_src/chrome/installer/util/shell_util.cc b/chromium_src/chrome/installer/util/shell_util.cc index dbf8594212fb..2251b82ba139 100644 --- a/chromium_src/chrome/installer/util/shell_util.cc +++ b/chromium_src/chrome/installer/util/shell_util.cc @@ -3,6 +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/. */ +#include "base/strings/stringprintf.h" #define BRAVE_IPFS L"ipfs" #define BRAVE_IPNS L"ipns" diff --git a/chromium_src/components/bookmarks/browser/bookmark_model_unittest.cc b/chromium_src/components/bookmarks/browser/bookmark_model_unittest.cc index f3a3a774c519..ef146bbedfec 100644 --- a/chromium_src/components/bookmarks/browser/bookmark_model_unittest.cc +++ b/chromium_src/components/bookmarks/browser/bookmark_model_unittest.cc @@ -17,13 +17,11 @@ TEST_F(BookmarkModelTest, BraveMigrateOtherNodeFolder) { model_->AddFolder(model_->bookmark_bar_node(), model_->bookmark_bar_node()->children().size(), model_->other_node()->GetTitledUrlNodeTitle()); - model_->AddFolder(model_->bookmark_bar_node(), 0, ASCIIToUTF16("A")); - const BookmarkNode* folder = - model_->AddFolder(other_node_folder, 0, ASCIIToUTF16("B")); - model_->AddURL(folder, 0, ASCIIToUTF16("B1"), GURL("https://B1.com")); + model_->AddFolder(model_->bookmark_bar_node(), 0, u"A"); + const BookmarkNode* folder = model_->AddFolder(other_node_folder, 0, u"B"); + model_->AddURL(folder, 0, u"B1", GURL("https://B1.com")); - model_->AddURL(other_node_folder, 1, ASCIIToUTF16("C.com"), - GURL("https://C.com")); + model_->AddURL(other_node_folder, 1, u"C.com", GURL("https://C.com")); // After migration, it should be // -- Bookmarks // |-- A @@ -34,13 +32,11 @@ TEST_F(BookmarkModelTest, BraveMigrateOtherNodeFolder) { BraveMigrateOtherNodeFolder(model_.get()); ASSERT_EQ(model_->other_node()->children().size(), 2u); ASSERT_EQ(model_->bookmark_bar_node()->children().size(), 1u); - EXPECT_EQ(model_->bookmark_bar_node()->children()[0]->GetTitle(), - ASCIIToUTF16("A")); - EXPECT_EQ(model_->other_node()->children()[0]->GetTitle(), ASCIIToUTF16("B")); + EXPECT_EQ(model_->bookmark_bar_node()->children()[0]->GetTitle(), u"A"); + EXPECT_EQ(model_->other_node()->children()[0]->GetTitle(), u"B"); EXPECT_EQ(model_->other_node()->children()[0]->children()[0]->GetTitle(), - ASCIIToUTF16("B1")); - EXPECT_EQ(model_->other_node()->children()[1]->GetTitle(), - ASCIIToUTF16("C.com")); + u"B1"); + EXPECT_EQ(model_->other_node()->children()[1]->GetTitle(), u"C.com"); // Empty folder model_->AddFolder(model_->bookmark_bar_node(), @@ -56,9 +52,9 @@ TEST_F(BookmarkModelTest, BraveMigrateOtherNodeFolderNotExist) { BraveMigrateOtherNodeFolder(model_.get()); ASSERT_EQ(model_->other_node()->children().size(), 0u); - const BookmarkNode* folder = model_->AddFolder(model_->bookmark_bar_node(), 0, - ASCIIToUTF16("Other B")); - model_->AddURL(folder, 0, ASCIIToUTF16("B1"), GURL("https://B1.com")); + const BookmarkNode* folder = + model_->AddFolder(model_->bookmark_bar_node(), 0, u"Other B"); + model_->AddURL(folder, 0, u"B1", GURL("https://B1.com")); BraveMigrateOtherNodeFolder(model_.get()); ASSERT_EQ(model_->bookmark_bar_node()->children().size(), 1u); ASSERT_EQ(model_->other_node()->children().size(), 0u); @@ -102,17 +98,17 @@ TEST_F(BookmarkModelTest, BraveClearSyncV1MetaInfo) { // -- Other Bookmarks // |-- B // | |--B1.com - const BookmarkNode* folder_A = model_->AddFolder( - model_->bookmark_bar_node(), 0, ASCIIToUTF16("A"), &meta_info_map); + const BookmarkNode* folder_A = + model_->AddFolder(model_->bookmark_bar_node(), 0, u"A", &meta_info_map); const BookmarkNode* bookmark_A1 = model_->AddURL( - folder_A, 0, ASCIIToUTF16("A1"), GURL("https://A1.com"), &meta_info_map); + folder_A, 0, u"A1", GURL("https://A1.com"), &meta_info_map); const BookmarkNode* bookmark_C1 = model_->AddURL( - folder_A, 1, ASCIIToUTF16("C1"), GURL("https://C1.com"), &meta_info_map); + folder_A, 1, u"C1", GURL("https://C1.com"), &meta_info_map); model_->SetNodeMetaInfo(bookmark_C1, "brave_meta", "brave_meta_value"); - const BookmarkNode* folder_B = model_->AddFolder( - model_->other_node(), 0, ASCIIToUTF16("B"), &meta_info_map); + const BookmarkNode* folder_B = + model_->AddFolder(model_->other_node(), 0, u"B", &meta_info_map); const BookmarkNode* bookmark_B1 = model_->AddURL( - folder_A, 0, ASCIIToUTF16("B1"), GURL("https://B1.com"), &meta_info_map); + folder_A, 0, u"B1", GURL("https://B1.com"), &meta_info_map); ASSERT_NE(folder_A->GetMetaInfoMap(), nullptr); ASSERT_NE(bookmark_A1->GetMetaInfoMap(), nullptr); ASSERT_NE(bookmark_C1->GetMetaInfoMap(), nullptr); diff --git a/chromium_src/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc b/chromium_src/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc index 9f9314feea17..65724aaf7de2 100644 --- a/chromium_src/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc +++ b/chromium_src/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc @@ -28,7 +28,7 @@ class BraveContentSettingsRegistryBrowserTest : public InProcessBrowserTest { HostContentSettingsMap* private_content_settings() { return HostContentSettingsMapFactory::GetForProfile( - browser()->profile()->GetPrimaryOTRProfile()); + browser()->profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true)); } private: diff --git a/chromium_src/components/content_settings/core/browser/cookie_settings_util.cc b/chromium_src/components/content_settings/core/browser/cookie_settings_util.cc deleted file mode 100644 index 8c3e64af75eb..000000000000 --- a/chromium_src/components/content_settings/core/browser/cookie_settings_util.cc +++ /dev/null @@ -1,26 +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/. */ - -#include "base/build_config.h" - -#if defined(OS_IOS) -#define SettingsAllowSigninCookies SettingsAllowSigninCookies_ChromiumImpl -#define SettingsDeleteSigninCookiesOnExit \ - SettingsDeleteSigninCookiesOnExit_ChromiumImpl -#endif - -#include "../../../../../../components/content_settings/core/browser/cookie_settings_utils.cc" - -#if defined(OS_IOS) -bool SettingsAllowSigninCookies( - const content_settings::CookieSettings* cookie_settings) { - return false; -} - -bool SettingsDeleteSigninCookiesOnExit( - const content_settings::CookieSettings* cookie_settings) { - return true; -} -#endif diff --git a/chromium_src/components/content_settings/core/common/cookie_settings_base.cc b/chromium_src/components/content_settings/core/common/cookie_settings_base.cc index 1b727f96bef5..2ee7890615e8 100644 --- a/chromium_src/components/content_settings/core/common/cookie_settings_base.cc +++ b/chromium_src/components/content_settings/core/common/cookie_settings_base.cc @@ -7,12 +7,12 @@ #include "base/feature_list.h" #include "base/no_destructor.h" -#include "base/optional.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_pattern.h" #include "components/content_settings/core/common/features.h" #include "net/base/features.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -75,7 +75,7 @@ bool BraveIsAllowedThirdParty(const GURL& url, } GURL GetFirstPartyURL(const GURL& site_for_cookies, - const base::Optional& top_frame_origin) { + const absl::optional& top_frame_origin) { return top_frame_origin ? top_frame_origin->GetURL() : site_for_cookies; } bool IsFirstPartyAccessAllowed( @@ -91,7 +91,7 @@ bool IsFirstPartyAccessAllowed( bool CookieSettingsBase::ShouldUseEphemeralStorage( const GURL& url, const GURL& site_for_cookies, - const base::Optional& top_frame_origin) const { + const absl::optional& top_frame_origin) const { if (!base::FeatureList::IsEnabled(net::features::kBraveEphemeralStorage)) return false; @@ -117,13 +117,13 @@ bool CookieSettingsBase::ShouldUseEphemeralStorage( bool CookieSettingsBase::IsEphemeralCookieAccessAllowed( const GURL& url, const GURL& first_party_url) const { - return IsEphemeralCookieAccessAllowed(url, first_party_url, base::nullopt); + return IsEphemeralCookieAccessAllowed(url, first_party_url, absl::nullopt); } bool CookieSettingsBase::IsEphemeralCookieAccessAllowed( const GURL& url, const GURL& site_for_cookies, - const base::Optional& top_frame_origin) const { + const absl::optional& top_frame_origin) const { if (ShouldUseEphemeralStorage(url, site_for_cookies, top_frame_origin)) return true; @@ -133,13 +133,13 @@ bool CookieSettingsBase::IsEphemeralCookieAccessAllowed( bool CookieSettingsBase::IsCookieAccessAllowed( const GURL& url, const GURL& first_party_url) const { - return IsCookieAccessAllowed(url, first_party_url, base::nullopt); + return IsCookieAccessAllowed(url, first_party_url, absl::nullopt); } bool CookieSettingsBase::IsCookieAccessAllowed( const GURL& url, const GURL& site_for_cookies, - const base::Optional& top_frame_origin) const { + const absl::optional& top_frame_origin) const { bool allow = IsChromiumCookieAccessAllowed(url, site_for_cookies, top_frame_origin); diff --git a/chromium_src/components/content_settings/core/common/cookie_settings_base.h b/chromium_src/components/content_settings/core/common/cookie_settings_base.h index 65aa549e33ea..8da2cf8d17ee 100644 --- a/chromium_src/components/content_settings/core/common/cookie_settings_base.h +++ b/chromium_src/components/content_settings/core/common/cookie_settings_base.h @@ -9,17 +9,17 @@ #define BRAVE_COOKIE_SETTINGS_BASE_H \ bool ShouldUseEphemeralStorage( \ const GURL& url, const GURL& site_for_cookies, \ - const base::Optional& top_frame_origin) const; \ + const absl::optional& top_frame_origin) const; \ bool IsEphemeralCookieAccessAllowed(const GURL& url, \ const GURL& first_party_url) const; \ bool IsEphemeralCookieAccessAllowed( \ const GURL& url, const GURL& site_for_cookies, \ - const base::Optional& top_frame_origin) const; \ + const absl::optional& top_frame_origin) const; \ bool IsChromiumCookieAccessAllowed(const GURL& url, \ const GURL& first_party_url) const; \ bool IsChromiumCookieAccessAllowed( \ const GURL& url, const GURL& site_for_cookies, \ - const base::Optional& top_frame_origin) const; + const absl::optional& top_frame_origin) const; #include "../../../../../../components/content_settings/core/common/cookie_settings_base.h" diff --git a/chromium_src/components/os_crypt/key_storage_keyring.cc b/chromium_src/components/os_crypt/key_storage_keyring.cc index 6524b2c7dfe6..5c7aca3b901a 100644 --- a/chromium_src/components/os_crypt/key_storage_keyring.cc +++ b/chromium_src/components/os_crypt/key_storage_keyring.cc @@ -23,11 +23,7 @@ void Dummy(const GnomeKeyringPasswordSchema*, &kSchema, &password_c, "application", GetApplicationName(), nullptr); \ if (false) Dummy( -#define BRAVE_KEY_STORAGE_KEYRING_K_APPLICATION_NAME \ - const char kApplicationName[] = "brave"; - #include "../../../../components/os_crypt/key_storage_keyring.cc" -#undef BRAVE_KEY_STORAGE_KEYRING_K_APPLICATION_NAME #undef BRAVE_KEY_STORAGE_KEYRING_GET_KEY_IMPL namespace { @@ -40,7 +36,7 @@ const char* GetApplicationName() { command_line->HasSwitch("import-brave")) { return "chromium"; } else { - return kApplicationName; + return "brave"; } } diff --git a/chromium_src/components/os_crypt/key_storage_libsecret.cc b/chromium_src/components/os_crypt/key_storage_libsecret.cc index 3ea2fb2c883a..840d570fcc20 100644 --- a/chromium_src/components/os_crypt/key_storage_libsecret.cc +++ b/chromium_src/components/os_crypt/key_storage_libsecret.cc @@ -16,13 +16,8 @@ const char* GetApplicationName(); attrs.Append("application", GetApplicationName()); \ } else // NOLINT -#define BRAVE_KEY_STORAGE_LIBSECRET_K_APPLICATION_NAME \ - const char kApplicationName[] = "brave"; - #include "../../../../components/os_crypt/key_storage_libsecret.cc" -#undef BRAVE_KEY_STORAGE_LIBSECRET_K_APPLICATION_NAME #undef BRAVE_KEY_STORAGE_LIBSECRET_GET_KEY_IMPL - namespace { const char* GetApplicationName() { @@ -33,7 +28,7 @@ const char* GetApplicationName() { command_line->HasSwitch("import-brave")) { return "chromium"; } else { - return kApplicationName; + return "brave"; } } diff --git a/chromium_src/components/os_crypt/key_storage_linux.cc b/chromium_src/components/os_crypt/key_storage_linux.cc new file mode 100644 index 000000000000..16efce678a1a --- /dev/null +++ b/chromium_src/components/os_crypt/key_storage_linux.cc @@ -0,0 +1,19 @@ +/* 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/. */ + +#include "components/os_crypt/key_storage_linux.h" + +#define BRAVE_KEY_STORAGE_LINUX \ + const char KeyStorageLinux::kFolderName[] = "Brave Keys"; \ + const char KeyStorageLinux::kKey[] = "Brave Safe Storage"; + +// clang-format off +#define BRAVE_KEY_STORAGE_LINUX_CREATE_SERVICE_INTERNAL \ + static const base::NoDestructor kDefaultApplicationName("brave"); +// clang-format on + +#include "../../../../components/os_crypt/key_storage_linux.cc" +#undef BRAVE_KEY_STORAGE_LINUX_CREATE_SERVICE_INTERNAL +#undef BRAVE_KEY_STORAGE_LINUX diff --git a/chromium_src/components/os_crypt/keychain_password_mac.mm b/chromium_src/components/os_crypt/keychain_password_mac.mm new file mode 100644 index 000000000000..de421460b917 --- /dev/null +++ b/chromium_src/components/os_crypt/keychain_password_mac.mm @@ -0,0 +1,30 @@ +/* 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/. */ + +#include "components/os_crypt/keychain_password_mac.h" + +#include + +#include "base/command_line.h" + +#define BRAVE_KEYCHAIN_PASSWORD_GET_PASSWORD \ + std::unique_ptr service_name, account_name; \ + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); \ + if (command_line->HasSwitch("import-chrome")) { \ + service_name = std::make_unique("Chrome Safe Storage"); \ + account_name = std::make_unique("Chrome"); \ + } else if (command_line->HasSwitch("import-chromium") || \ + command_line->HasSwitch("import-brave")) { \ + service_name = std::make_unique("Chromium Safe Storage"); \ + account_name = std::make_unique("Chromium"); \ + } else { \ + service_name = std::make_unique( \ + ::KeychainPassword::service_name->c_str()); \ + account_name = std::make_unique( \ + ::KeychainPassword::account_name->c_str()); \ + } + +#include "../../../../components/os_crypt/keychain_password_mac.mm" +#undef BRAVE_KEYCHAIN_PASSWORD_GET_PASSWORD \ No newline at end of file diff --git a/chromium_src/components/os_crypt/os_crypt_mac.mm b/chromium_src/components/os_crypt/os_crypt_mac.mm new file mode 100644 index 000000000000..5e95177dddb1 --- /dev/null +++ b/chromium_src/components/os_crypt/os_crypt_mac.mm @@ -0,0 +1,14 @@ +/* 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/. */ + +#include "components/os_crypt/keychain_password_mac.h" + +#define KeychainPassword \ + *KeychainPassword::service_name = "Brave Safe Storage"; \ + *KeychainPassword::account_name = "Brave"; \ + KeychainPassword + +#include "../../../../components/os_crypt/os_crypt_mac.mm" +#undef KeychainPassword \ No newline at end of file diff --git a/chromium_src/components/permissions/permission_request.cc b/chromium_src/components/permissions/permission_request.cc index ec85533ab90c..20f71cbedea9 100644 --- a/chromium_src/components/permissions/permission_request.cc +++ b/chromium_src/components/permissions/permission_request.cc @@ -6,7 +6,9 @@ #include "components/permissions/permission_request.h" #define PermissionRequest PermissionRequest_ChromiumImpl +#define IsDuplicateOf IsDuplicateOf_ChromiumImpl #include "../../../../components/permissions/permission_request.cc" +#undef IsDuplicateOf #undef PermissionRequest namespace permissions { @@ -19,14 +21,19 @@ bool PermissionRequest::SupportsLifetime() const { return false; } -void PermissionRequest::SetLifetime(base::Optional lifetime) { +void PermissionRequest::SetLifetime(absl::optional lifetime) { DCHECK(SupportsLifetime()); lifetime_ = std::move(lifetime); } -const base::Optional& PermissionRequest::GetLifetime() const { +const absl::optional& PermissionRequest::GetLifetime() const { DCHECK(SupportsLifetime()); return lifetime_; } +bool PermissionRequest::IsDuplicateOf(PermissionRequest* other_request) const { + return PermissionRequest_ChromiumImpl::IsDuplicateOf_ChromiumImpl( + other_request); +} + } // namespace permissions diff --git a/chromium_src/components/permissions/permission_request.h b/chromium_src/components/permissions/permission_request.h index 35ff88fe0c40..f764e3251aa9 100644 --- a/chromium_src/components/permissions/permission_request.h +++ b/chromium_src/components/permissions/permission_request.h @@ -9,7 +9,9 @@ #include "base/time/time.h" #define PermissionRequest PermissionRequest_ChromiumImpl +#define IsDuplicateOf IsDuplicateOf_ChromiumImpl #include "../../../../components/permissions/permission_request.h" +#undef IsDuplicateOf #undef PermissionRequest namespace permissions { @@ -20,11 +22,16 @@ class PermissionRequest : public PermissionRequest_ChromiumImpl { ~PermissionRequest() override; virtual bool SupportsLifetime() const; - void SetLifetime(base::Optional lifetime); - const base::Optional& GetLifetime() const; + void SetLifetime(absl::optional lifetime); + const absl::optional& GetLifetime() const; + + // We rename upstream's IsDuplicateOf() via a define above and re-declare it + // here to workaround the fact that the PermissionRequest_ChromiumImpl rename + // will affect this method's only parameter too, which will break subclasses. + virtual bool IsDuplicateOf(PermissionRequest* other_request) const; private: - base::Optional lifetime_; + absl::optional lifetime_; }; } // namespace permissions diff --git a/chromium_src/components/permissions/permission_request_impl.h b/chromium_src/components/permissions/permission_request_impl.h index 836f5d0cf0b9..203ea326c747 100644 --- a/chromium_src/components/permissions/permission_request_impl.h +++ b/chromium_src/components/permissions/permission_request_impl.h @@ -12,12 +12,13 @@ namespace permissions { -// Make it final to protect from accidental permission lifetime handling issues. -class PermissionRequestImpl final : public PermissionRequestImpl_ChromiumImpl { +class PermissionRequestImpl : public PermissionRequestImpl_ChromiumImpl { public: using PermissionRequestImpl_ChromiumImpl::PermissionRequestImpl_ChromiumImpl; - bool SupportsLifetime() const override; + // Make it final to protect from accidental permission lifetime handling + // issues. + bool SupportsLifetime() const final; }; } // namespace permissions diff --git a/chromium_src/components/sync/driver/sync_session_durations_metrics_recorder.cc b/chromium_src/components/sync/driver/sync_session_durations_metrics_recorder.cc index 96dbb78278ed..258ac28b9880 100644 --- a/chromium_src/components/sync/driver/sync_session_durations_metrics_recorder.cc +++ b/chromium_src/components/sync/driver/sync_session_durations_metrics_recorder.cc @@ -23,6 +23,8 @@ void SyncSessionDurationsMetricsRecorder::OnStateChanged( syncer::SyncService* sync) {} void SyncSessionDurationsMetricsRecorder::OnRefreshTokenUpdatedForAccount( const CoreAccountInfo& account_info) {} +void SyncSessionDurationsMetricsRecorder::OnPrimaryAccountChanged( + const signin::PrimaryAccountChangeEvent& event) {} void SyncSessionDurationsMetricsRecorder::OnRefreshTokenRemovedForAccount( const CoreAccountId& account_id) {} void SyncSessionDurationsMetricsRecorder::OnRefreshTokensLoaded() {} diff --git a/chromium_src/components/translate/core/browser/translate_manager_unittest.cc b/chromium_src/components/translate/core/browser/translate_manager_unittest.cc index 8d3d0309e2c0..a466b07005e3 100644 --- a/chromium_src/components/translate/core/browser/translate_manager_unittest.cc +++ b/chromium_src/components/translate/core/browser/translate_manager_unittest.cc @@ -145,14 +145,6 @@ class TranslateManagerTest : public ::testing::Test { translate_manager_->GetLanguageState()->HasLanguageChanged()); } - void SetLanguageTooOftenDenied(const std::string& language) { - translate_prefs_.UpdateLastDeniedTime(language); - translate_prefs_.UpdateLastDeniedTime(language); - - EXPECT_TRUE(translate_prefs_.IsTooOftenDenied(language)); - EXPECT_FALSE(translate_prefs_.IsTooOftenDenied("other_language")); - } - // Required to instantiate a net::test::MockNetworkChangeNotifier, because it // uses ObserverListThreadSafe. base::test::TaskEnvironment task_environment_; diff --git a/chromium_src/components/update_client/update_checker.cc b/chromium_src/components/update_client/update_checker.cc index cf649295a911..bb8f52c43934 100644 --- a/chromium_src/components/update_client/update_checker.cc +++ b/chromium_src/components/update_client/update_checker.cc @@ -65,7 +65,7 @@ void SequentialUpdateChecker::CheckNext() { } void SequentialUpdateChecker::UpdateResultAvailable( - const base::Optional& results, + const absl::optional& results, ErrorCategory error_category, int error, int retry_after_sec) { @@ -85,8 +85,8 @@ void SequentialUpdateChecker::UpdateResultAvailable( FROM_HERE, base::BindOnce( std::move(update_check_callback_), - error ? base::nullopt - : base::make_optional(results_), + error ? absl::nullopt + : absl::make_optional(results_), error_category, error, retry_after_sec)); else CheckNext(); diff --git a/chromium_src/components/update_client/update_checker.h b/chromium_src/components/update_client/update_checker.h index 05aae2432d48..b61aef1d9798 100644 --- a/chromium_src/components/update_client/update_checker.h +++ b/chromium_src/components/update_client/update_checker.h @@ -14,12 +14,12 @@ #include "base/containers/flat_map.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/threading/thread_checker.h" #include "components/update_client/component.h" #include "components/update_client/configurator.h" #include "components/update_client/persisted_data.h" #include "components/update_client/update_client_errors.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace update_client { @@ -57,7 +57,7 @@ class SequentialUpdateChecker : public UpdateChecker { private: void CheckNext(); void UpdateResultAvailable( - const base::Optional& results, + const absl::optional& results, ErrorCategory error_category, int error, int retry_after_sec); diff --git a/chromium_src/content/browser/browser_context.cc b/chromium_src/content/browser/browser_context.cc index 94a0a7c6a20d..3dd288a4fb16 100644 --- a/chromium_src/content/browser/browser_context.cc +++ b/chromium_src/content/browser/browser_context.cc @@ -8,7 +8,6 @@ #include #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "content/browser/dom_storage/dom_storage_context_wrapper.h" #include "content/browser/dom_storage/session_storage_namespace_impl.h" #include "content/browser/renderer_host/navigation_controller_impl.h" @@ -18,13 +17,14 @@ #include "content/public/browser/session_storage_namespace.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace content { scoped_refptr CreateSessionStorageNamespace( content::StoragePartition* partition, const std::string& namespace_id, - base::Optional clone_from_namespace_id) { + absl::optional clone_from_namespace_id) { content::DOMStorageContextWrapper* context_wrapper = static_cast( partition->GetDOMStorageContext()); diff --git a/chromium_src/content/public/browser/browser_context.h b/chromium_src/content/public/browser/browser_context.h index c8452bcce3e2..0b7fc7fefe90 100644 --- a/chromium_src/content/public/browser/browser_context.h +++ b/chromium_src/content/public/browser/browser_context.h @@ -15,9 +15,9 @@ #include #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "content/common/content_export.h" #include "content/public/browser/tld_ephemeral_lifetime.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace content { @@ -29,7 +29,7 @@ CONTENT_EXPORT scoped_refptr CreateSessionStorageNamespace( content::StoragePartition* partition, const std::string& namespace_id, - base::Optional clone_from_namespace_id); + absl::optional clone_from_namespace_id); CONTENT_EXPORT std::string GetSessionStorageNamespaceId(WebContents*); diff --git a/chromium_src/content/renderer/render_frame_impl.cc b/chromium_src/content/renderer/render_frame_impl.cc new file mode 100644 index 000000000000..7173be9a64e8 --- /dev/null +++ b/chromium_src/content/renderer/render_frame_impl.cc @@ -0,0 +1,14 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +// clang-format off +#define BRAVE_RENDER_FRAME_IMPL_SHOULD_USE_USER_AGENT_OVERRIDE \ + return true; \ + if (false) \ +// clang-format on + +#include "../../../../content/renderer/render_frame_impl.cc" +#undef BRAVE_RENDER_FRAME_IMPL_SHOULD_USE_USER_AGENT_OVERRIDE + diff --git a/chromium_src/ios/chrome/browser/application_context_impl.mm b/chromium_src/ios/chrome/browser/application_context_impl.mm index 56d25ef32ae9..01d562929dbf 100644 --- a/chromium_src/ios/chrome/browser/application_context_impl.mm +++ b/chromium_src/ios/chrome/browser/application_context_impl.mm @@ -19,6 +19,7 @@ #include "base/time/default_tick_clock.h" #include "brave/ios/browser/metrics/ios_brave_metrics_services_manager_client.h" #include "components/breadcrumbs/core/breadcrumb_manager.h" +#include "components/breadcrumbs/core/breadcrumb_persistent_storage_manager.h" #include "components/component_updater/component_updater_service.h" #include "components/gcm_driver/gcm_driver.h" #include "components/history/core/browser/history_service.h" @@ -36,7 +37,6 @@ #include "ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.h" #include "ios/chrome/browser/chrome_paths.h" #import "ios/chrome/browser/crash_report/breadcrumbs/application_breadcrumbs_logger.h" -#include "ios/chrome/browser/crash_report/breadcrumbs/breadcrumb_persistent_storage_manager.h" #include "ios/chrome/browser/history/history_service_factory.h" #include "ios/chrome/browser/ios_chrome_io_thread.h" #include "ios/chrome/browser/policy/browser_policy_connector_ios.h" @@ -307,7 +307,7 @@ void BindNetworkChangeManagerReceiver( return nullptr; } -BreadcrumbPersistentStorageManager* +breadcrumbs::BreadcrumbPersistentStorageManager* ApplicationContextImpl::GetBreadcrumbPersistentStorageManager() { DCHECK(thread_checker_.CalledOnValidThread()); return nullptr; diff --git a/chromium_src/net/base/host_port_pair.cc b/chromium_src/net/base/host_port_pair.cc index 9899a7870812..e13d41327e76 100644 --- a/chromium_src/net/base/host_port_pair.cc +++ b/chromium_src/net/base/host_port_pair.cc @@ -29,13 +29,13 @@ HostPortPair FromStringWithAuthentication(const std::string& str) { std::vector auth_host = base::SplitStringPiece( str, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); HostPortPair host_port_pair = - HostPortPair::FromString(auth_host[1].as_string()); + HostPortPair::FromString(std::string(auth_host[1])); std::vector user_pass = base::SplitStringPiece( str, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); - host_port_pair.set_username(user_pass[0].as_string()); - host_port_pair.set_password(user_pass[1].as_string()); + host_port_pair.set_username(std::string(user_pass[0])); + host_port_pair.set_password(std::string(user_pass[1])); return host_port_pair; } diff --git a/chromium_src/net/cookies/brave_canonical_cookie_unittest.cc b/chromium_src/net/cookies/brave_canonical_cookie_unittest.cc index 9fdfcb6902e4..3ad0426ff79d 100644 --- a/chromium_src/net/cookies/brave_canonical_cookie_unittest.cc +++ b/chromium_src/net/cookies/brave_canonical_cookie_unittest.cc @@ -36,17 +36,17 @@ TEST(BraveCanonicalCookieTest, SetMaxExpiration) { GURL url("https://www.example.com/test"); std::unique_ptr cookie(CanonicalCookie::Create( - url, max_expires_date_cookie, creation_time, base::nullopt)); + url, max_expires_date_cookie, creation_time, absl::nullopt)); EXPECT_TRUE(cookie.get()); EXPECT_EQ(cookie->ExpiryDate(), creation_time + kMaxCookieExpiration); cookie = CanonicalCookie::Create(url, max_age_cookie, creation_time, - base::nullopt); + absl::nullopt); EXPECT_TRUE(cookie.get()); EXPECT_EQ(cookie->ExpiryDate(), creation_time + kMaxCookieExpiration); cookie = CanonicalCookie::Create(url, max_expires_and_max_age_cookie, - creation_time, base::nullopt); + creation_time, absl::nullopt); EXPECT_TRUE(cookie.get()); EXPECT_EQ(cookie->ExpiryDate(), creation_time + kMaxCookieExpiration); } @@ -55,7 +55,7 @@ TEST(BraveCanonicalCookieTest, AllowShorterThanMaxExpiration) { GURL url("https://www.example.com/test"); // Short-lived cookies get to keep their shorter expiration. std::unique_ptr cookie = CanonicalCookie::Create( - url, short_expiration_cookie, creation_time, base::nullopt); + url, short_expiration_cookie, creation_time, absl::nullopt); EXPECT_TRUE(cookie.get()); EXPECT_EQ(cookie->ExpiryDate(), creation_time + TimeDelta::FromDays(2)); } @@ -65,7 +65,7 @@ TEST(BraveCanonicalCookieTest, SetHTTPOnlyMaxExpiration) { // HTTP cookies with 'httponly' work as expected. std::unique_ptr cookie = - CanonicalCookie::Create(url, cookie_line5, creation_time, base::nullopt); + CanonicalCookie::Create(url, cookie_line5, creation_time, absl::nullopt); EXPECT_TRUE(cookie.get()); EXPECT_EQ(cookie->ExpiryDate(), creation_time + kMaxCookieExpiration); } @@ -76,7 +76,7 @@ TEST(BraveCanonicalCookieTest, NoExpirationCookie) { base::Time creation_time = base::Time::Now(); std::unique_ptr cookie(CanonicalCookie::Create( - url, no_expiration_cookie, creation_time, base::nullopt)); + url, no_expiration_cookie, creation_time, absl::nullopt)); EXPECT_TRUE(cookie.get()); EXPECT_EQ(cookie->IsPersistent(), false); } diff --git a/chromium_src/net/cookies/cookie_deletion_info.h b/chromium_src/net/cookies/cookie_deletion_info.h index f43fd85fdad9..f4d180e6ae1b 100644 --- a/chromium_src/net/cookies/cookie_deletion_info.h +++ b/chromium_src/net/cookies/cookie_deletion_info.h @@ -7,7 +7,7 @@ #define BRAVE_CHROMIUM_SRC_NET_COOKIES_COOKIE_DELETION_INFO_H_ #define BRAVE_COOKIE_DELETION_INFO_H \ - base::Optional ephemeral_storage_domain; + absl::optional ephemeral_storage_domain; #include "../../../../net/cookies/cookie_deletion_info.h" diff --git a/chromium_src/net/url_request/redirect_util.cc b/chromium_src/net/url_request/redirect_util.cc index 1d8f38f3a594..fe23c31de4ee 100644 --- a/chromium_src/net/url_request/redirect_util.cc +++ b/chromium_src/net/url_request/redirect_util.cc @@ -18,8 +18,8 @@ void RedirectUtil::UpdateHttpRequest( const GURL& original_url, const std::string& original_method, const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers, + const absl::optional>& removed_headers, + const absl::optional& modified_headers, HttpRequestHeaders* request_headers, bool* should_clear_upload) { UpdateHttpRequest_ChromiumImpl(original_url, diff --git a/chromium_src/net/url_request/redirect_util.h b/chromium_src/net/url_request/redirect_util.h index 3803aa8d2b0c..fd6b57277e44 100644 --- a/chromium_src/net/url_request/redirect_util.h +++ b/chromium_src/net/url_request/redirect_util.h @@ -6,16 +6,14 @@ #ifndef BRAVE_CHROMIUM_SRC_NET_URL_REQUEST_REDIRECT_UTIL_H_ #define BRAVE_CHROMIUM_SRC_NET_URL_REQUEST_REDIRECT_UTIL_H_ -#define UpdateHttpRequest \ - UpdateHttpRequest_ChromiumImpl( \ - const GURL& original_url, \ - const std::string& original_method, \ - const RedirectInfo& redirect_info, \ - const base::Optional>& removed_headers, \ - const base::Optional& modified_headers, \ - HttpRequestHeaders* request_headers, \ - bool* should_clear_upload); \ - NET_EXPORT static void UpdateHttpRequest +#define UpdateHttpRequest \ + UpdateHttpRequest_ChromiumImpl( \ + const GURL& original_url, const std::string& original_method, \ + const RedirectInfo& redirect_info, \ + const absl::optional>& removed_headers, \ + const absl::optional& modified_headers, \ + HttpRequestHeaders* request_headers, bool* should_clear_upload); \ + NET_EXPORT static void UpdateHttpRequest #include "../../../../net/url_request/redirect_util.h" #undef UpdateHttpRequest diff --git a/chromium_src/services/network/public/cpp/DEPS b/chromium_src/services/network/public/cpp/DEPS new file mode 100644 index 000000000000..7d96b9ea5aef --- /dev/null +++ b/chromium_src/services/network/public/cpp/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+../../../../../../services/network", +] diff --git a/chromium_src/third_party/blink/common/loader/network_utils.cc b/chromium_src/services/network/public/cpp/url_util.cc similarity index 50% rename from chromium_src/third_party/blink/common/loader/network_utils.cc rename to chromium_src/services/network/public/cpp/url_util.cc index 28b0de798dc5..b2b2dda9b55c 100644 --- a/chromium_src/third_party/blink/common/loader/network_utils.cc +++ b/chromium_src/services/network/public/cpp/url_util.cc @@ -1,16 +1,23 @@ -/* Copyright (c) 2020 The Brave Authors. All rights reserved. +/* 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/. */ -#include "third_party/blink/public/common/loader/network_utils.h" +#include "services/network/public/cpp/url_util.h" + +#include "base/feature_list.h" +#include "build/build_config.h" +#include "net/net_buildflags.h" +#include "services/network/public/cpp/features.h" +#include "services/network/public/cpp/is_potentially_trustworthy.h" +#include "url/gurl.h" +#include "url/url_constants.h" #define IsURLHandledByNetworkService IsURLHandledByNetworkService_ChromiumImpl -#include "../../../../../../third_party/blink/common/loader/network_utils.cc" +#include "../../../../../../services/network/public/cpp/url_util.cc" #undef IsURLHandledByNetworkService -namespace blink { -namespace network_utils { +namespace network { bool IsURLHandledByNetworkService(const GURL& url) { if (url.SchemeIs("ipns") || url.SchemeIs("ipfs")) { @@ -19,5 +26,4 @@ bool IsURLHandledByNetworkService(const GURL& url) { return IsURLHandledByNetworkService_ChromiumImpl(url); } -} // namespace network_utils -} // namespace blink +} // namespace network diff --git a/chromium_src/third_party/blink/renderer/DEPS b/chromium_src/third_party/blink/renderer/DEPS index dfc61c3e4d2d..44f3b4326e5c 100644 --- a/chromium_src/third_party/blink/renderer/DEPS +++ b/chromium_src/third_party/blink/renderer/DEPS @@ -13,8 +13,8 @@ include_rules = [ "+../../../../../../../third_party/blink/renderer/modules/mediastream", "+../../../../../../../third_party/blink/renderer/modules/quota", "+../../../../../../../third_party/blink/renderer/modules/storage", - "+../../../../../../third_party/blink/renderer/modules/webgl", "+../../../../../../../third_party/blink/renderer/modules/webaudio", + "+../../../../../../../third_party/blink/renderer/modules/webgl", "+../../../../../../../../third_party/blink/renderer/modules/canvas/canvas2d", "+../../../../../../../third_party/blink/renderer/platform/graphics", "+mojo/public/cpp/bindings", diff --git a/chromium_src/third_party/blink/renderer/core/execution_context/navigator_base.h b/chromium_src/third_party/blink/renderer/core/execution_context/navigator_base.h index 7e652db6d1d2..c39bc99bc328 100644 --- a/chromium_src/third_party/blink/renderer/core/execution_context/navigator_base.h +++ b/chromium_src/third_party/blink/renderer/core/execution_context/navigator_base.h @@ -13,8 +13,6 @@ #include "third_party/blink/renderer/core/loader/frame_loader.h" #define BRAVE_NAVIGATOR_BASE_USER_AGENT \ - if (!GetExecutionContext()) \ - return String(); \ if (blink::WebContentSettingsClient* settings = \ brave::GetContentSettingsClientFor(GetExecutionContext())) { \ if (!settings->AllowFingerprinting(true)) { \ diff --git a/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc b/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc index be725bb3879c..3146cf89afae 100644 --- a/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc +++ b/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc @@ -14,10 +14,12 @@ if (ExecutionContext* context = ExecutionContext::From(script_state)) { \ if (WebContentSettingsClient* settings = \ brave::GetContentSettingsClientFor(context)) { \ + SkPixmap image_data_pixmap = image_data->GetSkPixmap(); \ brave::BraveSessionCache::From(*context).PerturbPixels( \ settings, \ - static_cast(data_array->BaseAddress()), \ - data_array->byteLength()); \ + static_cast( \ + image_data_pixmap.writable_addr()), \ + image_data_pixmap.computeByteSize()); \ } \ } @@ -42,16 +44,6 @@ bool AllowFingerprintingFromScriptState(blink::ScriptState* script_state) { namespace blink { -ImageData* BaseRenderingContext2D::getImageData( - int sx, - int sy, - int sw, - int sh, - ExceptionState& exception_state) { - NOTREACHED(); - return nullptr; -} - ImageData* BaseRenderingContext2D::getImageData( int sx, int sy, @@ -85,17 +77,6 @@ ImageData* BaseRenderingContext2D::getImageDataInternal_Unused( return nullptr; } -ImageData* BaseRenderingContext2D::getImageData( - ScriptState* script_state, - int sx, - int sy, - int sw, - int sh, - ExceptionState& exception_state) { - return getImageDataInternal(script_state, sx, sy, sw, sh, nullptr, - exception_state); -} - ImageData* BaseRenderingContext2D::getImageData( ScriptState* script_state, int sx, diff --git a/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h b/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h index 00b1356f9140..c4f0b8d15cd0 100644 --- a/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h +++ b/chromium_src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h @@ -16,12 +16,8 @@ ImageDataSettings*, ExceptionState&); \ ImageData* getImageDataInternal(int sx, int sy, int sw, int sh, \ ImageDataSettings*, ExceptionState&); \ - ImageData* getImageData(ScriptState*, int sx, int sy, int sw, int sh, \ - ExceptionState&); \ ImageData* getImageData(ScriptState*, int sx, int sy, int sw, int sh, \ ImageDataSettings*, ExceptionState&); \ - ImageData* getImageData_Unused(int sx, int sy, int sw, int sh, \ - ExceptionState&); \ ImageData* getImageData_Unused(int sx, int sy, int sw, int sh, \ ImageDataSettings*, ExceptionState&); \ \ diff --git a/chromium_src/third_party/blink/renderer/modules/storage/dom_window_storage.cc b/chromium_src/third_party/blink/renderer/modules/storage/dom_window_storage.cc index b2946e8c8274..b89068288f34 100644 --- a/chromium_src/third_party/blink/renderer/modules/storage/dom_window_storage.cc +++ b/chromium_src/third_party/blink/renderer/modules/storage/dom_window_storage.cc @@ -227,7 +227,8 @@ StorageArea* BraveDOMWindowStorage::ephemeralLocalStorage() { controller->ClearAreasIfNeeded(); auto storage_area = base::MakeRefCounted( CachedStorageArea::AreaType::kSessionStorage, window->GetSecurityOrigin(), - controller->TaskRunner(), namespaces->local_storage()); + controller->TaskRunner(), namespaces->local_storage(), + /*is_session_storage_for_prerendering=*/false); // Ephemeral localStorage never persists stored data, which is also how // sessionStorage works. Due to this, when opening up a new ephemeral diff --git a/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc b/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc index 55c327326983..143a927a3400 100644 --- a/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc +++ b/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc @@ -35,7 +35,7 @@ bool AllowFingerprintingForHost(blink::CanvasRenderingContextHost* host) { #define BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT \ if (!AllowFingerprintingForHost(Host())) \ - return base::nullopt; + return absl::nullopt; #define BRAVE_WEBGL_RENDERING_CONTEXT_BASE_ZERO \ if (!AllowFingerprintingForHost(Host())) \ @@ -88,11 +88,11 @@ namespace blink { // If fingerprinting is disallowed, claim that the only supported extension is // WebGLDebugRendererInfo. -base::Optional> +absl::optional> WebGLRenderingContextBase::getSupportedExtensions() { - base::Optional> real_extensions = + absl::optional> real_extensions = getSupportedExtensions_ChromiumImpl(); - if (real_extensions == base::nullopt) + if (real_extensions == absl::nullopt) return real_extensions; if (AllowFingerprintingForHost(Host())) return real_extensions; diff --git a/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h b/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h index aaf4bcf6931e..fb698c5897af 100644 --- a/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h +++ b/chromium_src/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h @@ -12,9 +12,9 @@ #define getSupportedExtensions \ getSupportedExtensions_ChromiumImpl(); \ - base::Optional> getSupportedExtensions + absl::optional> getSupportedExtensions -#include "../../../../../../third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h" +#include "../../../../../../../third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h" #undef getSupportedExtensions #undef getExtension diff --git a/chromium_src/ui/native_theme/native_theme.h b/chromium_src/ui/native_theme/native_theme.h index 3c58c668cdcf..5ea4abdf2266 100644 --- a/chromium_src/ui/native_theme/native_theme.h +++ b/chromium_src/ui/native_theme/native_theme.h @@ -6,17 +6,14 @@ #ifndef BRAVE_CHROMIUM_SRC_UI_NATIVE_THEME_NATIVE_THEME_H_ #define BRAVE_CHROMIUM_SRC_UI_NATIVE_THEME_NATIVE_THEME_H_ -#define BRAVE_UI_NATIVE_THEME_NATIVE_THEME_H_ \ - friend void SetUseDarkColors(bool dark_mode); \ - friend void ReCalcAndSetPreferredColorScheme(); \ - static NativeTheme* BraveGetInstanceForNativeUi(); - #define GetSystemButtonPressedColor \ GetSystemButtonPressedColor_ChromiumImpl(SkColor base_color) const; \ + friend void SetUseDarkColors(bool dark_mode); \ + friend void ReCalcAndSetPreferredColorScheme(); \ + static NativeTheme* BraveGetInstanceForNativeUi(); \ virtual SkColor GetSystemButtonPressedColor #include "../../../../ui/native_theme/native_theme.h" #undef GetSystemButtonPressedColor -#undef BRAVE_UI_NATIVE_THEME_NATIVE_THEME_H_ #endif // BRAVE_CHROMIUM_SRC_UI_NATIVE_THEME_NATIVE_THEME_H_ diff --git a/chromium_src/ui/views/controls/button/md_text_button.cc b/chromium_src/ui/views/controls/button/md_text_button.cc index 71c2244c32c4..e85477a08e1d 100644 --- a/chromium_src/ui/views/controls/button/md_text_button.cc +++ b/chromium_src/ui/views/controls/button/md_text_button.cc @@ -76,6 +76,18 @@ MdTextButton::MdTextButton(PressedCallback callback, SetCornerRadius(100); views::HighlightPathGenerator::Install( this, std::make_unique()); + views::InkDrop::UseInkDropForFloodFillRipple(ink_drop(), + /*highlight_on_hover=*/false, + /*highlight_on_focus=*/true); + ink_drop()->SetCreateHighlightCallback(base::BindRepeating( + [](Button* host) { + const SkColor fill_color = SK_ColorTRANSPARENT; + gfx::RectF boundsF(host->GetLocalBounds()); + return std::make_unique( + boundsF.size(), static_cast(host)->GetCornerRadius(), + boundsF.CenterPoint(), fill_color); + }, + this)); } MdTextButton::~MdTextButton() = default; @@ -107,26 +119,6 @@ void MdTextButton::OnPaintBackground(gfx::Canvas* canvas) { } } -std::unique_ptr MdTextButton::CreateInkDrop() { - // We don't need a highlight on hover, the hover color - // is handled by the OnPaintBackground and brave-style doesn't - // have a shadow. Plus, it's very difficult (impossible?) to create - // a drop-shadow when clipping the ink drop to the rounded button. - std::unique_ptr ink_drop = InkDropHostView::CreateInkDrop(); - ink_drop->SetShowHighlightOnFocus(true); - ink_drop->SetShowHighlightOnHover(false); - return ink_drop; -} - -std::unique_ptr MdTextButton::CreateInkDropHighlight() - const { - // Blank ink drop highlight, not needed - const SkColor fill_color = SK_ColorTRANSPARENT; - gfx::RectF boundsF(GetLocalBounds()); - return std::make_unique(boundsF.size(), GetCornerRadius(), - boundsF.CenterPoint(), fill_color); -} - } // namespace views namespace { diff --git a/chromium_src/ui/views/controls/button/md_text_button.h b/chromium_src/ui/views/controls/button/md_text_button.h index ccd84eb7d7ed..9a26c8ccbe1c 100644 --- a/chromium_src/ui/views/controls/button/md_text_button.h +++ b/chromium_src/ui/views/controls/button/md_text_button.h @@ -37,11 +37,6 @@ class VIEWS_EXPORT MdTextButton : public MdTextButtonBase { int button_context = style::CONTEXT_BUTTON_MD); ~MdTextButton() override; - // InkDrop - std::unique_ptr CreateInkDrop() override; - std::unique_ptr CreateInkDropHighlight() - const override; - SkPath GetHighlightPath() const; protected: diff --git a/common/BUILD.gn b/common/BUILD.gn index f99fa5d752e6..c854e8b6fc72 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -163,6 +163,7 @@ source_set("common") { deps += [ "//brave/components/resources", + "//chrome/common:constants", "//components/resources", "//content/public/common", "//third_party/widevine/cdm:buildflags", diff --git a/common/importer/chrome_importer_utils.cc b/common/importer/chrome_importer_utils.cc index edda4edae3f1..e7d9232ee055 100644 --- a/common/importer/chrome_importer_utils.cc +++ b/common/importer/chrome_importer_utils.cc @@ -37,7 +37,7 @@ bool HasImportableExtensions(const base::FilePath& secured_preference_path) { std::string secured_preference_content; base::ReadFileToString(secured_preference_path, &secured_preference_content); - base::Optional secured_preference = + absl::optional secured_preference = base::JSONReader::Read(secured_preference_content); if (auto* extensions = secured_preference->FindPath( kChromeExtensionsListPath)) { @@ -84,8 +84,8 @@ base::ListValue* GetChromeSourceProfiles( } else { std::string local_state_content; base::ReadFileToString(local_state_path, &local_state_content); - base::Optional local_state = - base::JSONReader::Read(local_state_content); + absl::optional local_state = + base::JSONReader::Read(local_state_content); const base::DictionaryValue* local_state_dict; const base::DictionaryValue* profile_dict; const base::DictionaryValue* info_cache; diff --git a/common/importer/chrome_importer_utils_unittest.cc b/common/importer/chrome_importer_utils_unittest.cc index 8f9e3534e276..674796a03036 100644 --- a/common/importer/chrome_importer_utils_unittest.cc +++ b/common/importer/chrome_importer_utils_unittest.cc @@ -30,7 +30,7 @@ TEST(ChromeImporterUtilsTest, BasicTest) { std::string secured_preference_content; base::ReadFileToString(secured_preference_path, &secured_preference_content); - base::Optional secured_preference = + absl::optional secured_preference = base::JSONReader::Read(secured_preference_content); auto* extensions = secured_preference->FindPath(kChromeExtensionsListPath); auto extensions_list = diff --git a/common/resource_bundle_helper.cc b/common/resource_bundle_helper.cc index 3f9175afc57b..51d22800b4bc 100644 --- a/common/resource_bundle_helper.cc +++ b/common/resource_bundle_helper.cc @@ -9,10 +9,10 @@ #include "base/command_line.h" #include "base/path_service.h" -#include "chrome/common/chrome_paths.h" #include "ui/base/resource/resource_bundle.h" #if !defined(OS_IOS) +#include "chrome/common/chrome_paths.h" #include "content/public/common/content_switches.h" #endif diff --git a/components/api_request_helper/BUILD.gn b/components/api_request_helper/BUILD.gn index b2bef21173fb..76a74cb44d30 100644 --- a/components/api_request_helper/BUILD.gn +++ b/components/api_request_helper/BUILD.gn @@ -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/. -source_set("api_request_helper") { +static_library("api_request_helper") { sources = [ "api_request_helper.cc", "api_request_helper.h", diff --git a/components/arc_strings.grdp b/components/arc_strings.grdp index 2c9b490f55df..17029db70d7f 100644 --- a/components/arc_strings.grdp +++ b/components/arc_strings.grdp @@ -14,16 +14,25 @@ Don't ask me again for this app - + Phone - + Tablet - - Desktop + + Maximized - - Resize Settings + + Settings + + + This app is designed for mobile + + + It may behave unexpectedly if resized. You can now limit the ability to resize apps in $1Settings. + + + Settings diff --git a/components/autofill_assistant_strings.grdp b/components/autofill_assistant_strings.grdp index fb19253a497f..607bd616e0f0 100644 --- a/components/autofill_assistant_strings.grdp +++ b/components/autofill_assistant_strings.grdp @@ -1,7 +1,7 @@ - + Continue diff --git a/components/autofill_payments_strings.grdp b/components/autofill_payments_strings.grdp index 9c6375116cf3..a396549b813d 100644 --- a/components/autofill_payments_strings.grdp +++ b/components/autofill_payments_strings.grdp @@ -94,6 +94,9 @@ Confirm + + Save to Brave sync chain + @@ -223,7 +226,7 @@ Saved on this device only - + {NUM_CARDS, plural, =1 {This card and its billing address will be saved. You'll be able to use it when signed in to $1user@gmail.com.} other {These cards and their billing addresses will be saved. You'll be able to use them when signed in to $1user@gmail.com.}} @@ -393,7 +396,7 @@ Update card - + CVC @@ -471,7 +474,7 @@ From Brave Pay - + Use a virtual card number... @@ -492,6 +495,22 @@ Cancel + + Virtual card number + + + Virtual number: + + + Month/Year: + + + CVC: + + + + View virtual card details + @@ -530,4 +549,14 @@ See details + + + + + Your virtual card number is applied. + + + View virtual card + + diff --git a/components/autofill_strings.grdp b/components/autofill_strings.grdp index fa179f2a551f..4f39e30a323b 100644 --- a/components/autofill_strings.grdp +++ b/components/autofill_strings.grdp @@ -186,17 +186,17 @@ ''' • ''' - + Exp: $106/$217 - + $106/$217 - + $1Visa ••••5679, expires on $206/17 - + Expires on $106/17 @@ -317,4 +317,87 @@ + + + + Save + + + Update + + + New + + + Old + + + + + Save address? + + + Update address? + + + Cancel + + + Edit address + + + Edit address + + + + + + Save Address? + + + Save… + + + Update Address? + + + Update… + + + Save Address + + + Update Address + + + + + + Save address? + + + No thanks + + + Edit address + + + Update address? + + + No thanks + + + Edit address + + + Save + + + Update + + + Cancel + + diff --git a/components/binance/browser/BUILD.gn b/components/binance/browser/BUILD.gn index 1660a731a30c..b92999291cdb 100644 --- a/components/binance/browser/BUILD.gn +++ b/components/binance/browser/BUILD.gn @@ -7,16 +7,14 @@ declare_args() { binance_client_id = "" } -source_set("browser") { - public_deps = [ - "buildflags" - ] +static_library("browser") { + public_deps = [ "buildflags" ] sources = [ "binance_json_parser.cc", "binance_json_parser.h", "binance_service.cc", "binance_service.h", - "regions.h" + "regions.h", ] deps = [ @@ -37,9 +35,6 @@ source_set("browser") { configs += [ ":binance_config" ] } - config("binance_config") { - defines = [ - "BINANCE_CLIENT_ID=\"$binance_client_id\"" - ] + defines = [ "BINANCE_CLIENT_ID=\"$binance_client_id\"" ] } diff --git a/components/binance/browser/binance_json_parser.cc b/components/binance/browser/binance_json_parser.cc index b257d02b2f63..130c41bb3b54 100644 --- a/components/binance/browser/binance_json_parser.cc +++ b/components/binance/browser/binance_json_parser.cc @@ -29,7 +29,7 @@ bool BinanceJSONParser::GetTokensFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; return false; @@ -71,7 +71,7 @@ bool BinanceJSONParser::GetAccountBalancesFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; @@ -136,7 +136,7 @@ bool BinanceJSONParser::GetQuoteInfoFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; return false; @@ -184,7 +184,7 @@ bool BinanceJSONParser::GetDepositInfoFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; @@ -240,7 +240,7 @@ bool BinanceJSONParser::GetConfirmStatusFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; return false; @@ -308,7 +308,7 @@ bool BinanceJSONParser::GetConvertAssetsFromJSON(const std::string& json, base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; @@ -362,7 +362,7 @@ bool BinanceJSONParser::RevokeTokenFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; return false; @@ -409,7 +409,7 @@ bool BinanceJSONParser::GetCoinNetworksFromJSON( base::JSONReader::ValueWithError value_with_error = base::JSONReader::ReadAndReturnValueWithError( json, base::JSONParserOptions::JSON_PARSE_RFC); - base::Optional& records_v = value_with_error.value; + absl::optional& records_v = value_with_error.value; if (!records_v) { LOG(ERROR) << "Invalid response, could not parse JSON, JSON is: " << json; diff --git a/components/binance/browser/binance_service.cc b/components/binance/browser/binance_service.cc index ee39fa731c0f..d70a01383a10 100644 --- a/components/binance/browser/binance_service.cc +++ b/components/binance/browser/binance_service.cc @@ -81,9 +81,8 @@ BinanceService::BinanceService(content::BrowserContext* context) oauth_host_(oauth_host), gateway_host_(gateway_host), context_(context), - url_loader_factory_( - content::BrowserContext::GetDefaultStoragePartition(context_) - ->GetURLLoaderFactoryForBrowserProcess()), + url_loader_factory_(context_->GetDefaultStoragePartition() + ->GetURLLoaderFactoryForBrowserProcess()), weak_factory_(this) { LoadTokensFromPrefs(); } @@ -208,8 +207,7 @@ bool BinanceService::OAuthRequest(const GURL &url, network::SimpleURLLoader::RetryMode::RETRY_NEVER); auto iter = url_loaders_.insert(url_loaders_.begin(), std::move(url_loader)); - auto* default_storage_partition = - content::BrowserContext::GetDefaultStoragePartition(context_); + auto* default_storage_partition = context_->GetDefaultStoragePartition(); auto* url_loader_factory = default_storage_partition->GetURLLoaderFactoryForBrowserProcess().get(); diff --git a/components/blocked_content_strings.grdp b/components/blocked_content_strings.grdp index 367c926f63f1..3871f2d96f03 100644 --- a/components/blocked_content_strings.grdp +++ b/components/blocked_content_strings.grdp @@ -2,10 +2,10 @@ - + Always show - + {NUM_POPUPS,plural,=1{Pop-up blocked} other{# pop-ups blocked}} diff --git a/components/brave_adblock_ui/brave_adblock.html b/components/brave_adblock_ui/brave_adblock.html index 8860441e184f..e0669f82a661 100644 --- a/components/brave_adblock_ui/brave_adblock.html +++ b/components/brave_adblock_ui/brave_adblock.html @@ -5,12 +5,9 @@ Ad Block - - - - + diff --git a/components/brave_adblock_ui/brave_adblock.tsx b/components/brave_adblock_ui/brave_adblock.tsx index 9b10ca95c663..f993a35e97a5 100644 --- a/components/brave_adblock_ui/brave_adblock.tsx +++ b/components/brave_adblock_ui/brave_adblock.tsx @@ -14,45 +14,42 @@ import App from './components/app' import store from './store' import * as adblockActions from './actions/adblock_actions' -window.cr.define('brave_adblock', function () { - 'use strict' - - function getCustomFilters () { - const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) - actions.getCustomFilters() - } - - function getRegionalLists () { - const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) - actions.getRegionalLists() - } - - function initialize () { - getCustomFilters() - getRegionalLists() - render( - - - , - document.getElementById('root')) - window.i18nTemplate.process(window.document, window.loadTimeData) - } - - function onGetCustomFilters (customFilters: string) { - const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) - actions.onGetCustomFilters(customFilters) - } - - function onGetRegionalLists (regionalLists: AdBlock.FilterList[]) { - const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) - actions.onGetRegionalLists(regionalLists) - } - - return { - initialize, - onGetCustomFilters, - onGetRegionalLists - } -}) - -document.addEventListener('DOMContentLoaded', window.brave_adblock.initialize) +function getCustomFilters () { + const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) + actions.getCustomFilters() +} + +function getRegionalLists () { + const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) + actions.getRegionalLists() +} + +function initialize () { + getCustomFilters() + getRegionalLists() + render( + + + , + document.getElementById('root')) +} + +function onGetCustomFilters (customFilters: string) { + const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) + actions.onGetCustomFilters(customFilters) +} + +function onGetRegionalLists (regionalLists: AdBlock.FilterList[]) { + const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) + actions.onGetRegionalLists(regionalLists) +} + +// Expose functions to Page Handlers. +// TODO(petemill): Use event listeners instead. +// @ts-ignore +window.brave_adblock = { + onGetCustomFilters, + onGetRegionalLists +} + +document.addEventListener('DOMContentLoaded', initialize) diff --git a/components/brave_adblock_ui/components/adBlockItemList.tsx b/components/brave_adblock_ui/components/adBlockItemList.tsx index 3a48620015fb..d1a4efbdbcde 100644 --- a/components/brave_adblock_ui/components/adBlockItemList.tsx +++ b/components/brave_adblock_ui/components/adBlockItemList.tsx @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' +import { getLocale } from '../../common/locale' // Components import { AdBlockItem } from './adBlockItem' @@ -28,13 +29,15 @@ export class AdBlockItemList extends React.Component { return (
+ > + {getLocale('additionalFiltersTitle')} +
+ > + {getLocale('additionalFiltersWarning')} +
{regionalLists}
diff --git a/components/brave_adblock_ui/components/customFilters.tsx b/components/brave_adblock_ui/components/customFilters.tsx index 21be3a3fc0d3..3267d87587f8 100644 --- a/components/brave_adblock_ui/components/customFilters.tsx +++ b/components/brave_adblock_ui/components/customFilters.tsx @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' +import { getLocale } from '../../common/locale' interface Props { actions: any, @@ -22,13 +23,15 @@ export class CustomFilters extends React.Component { return (
+ > + {getLocale('customFiltersTitle')} +
+ > + {getLocale('customFiltersInstructions')} +