diff --git a/android/java/apk_for_test.flags b/android/java/apk_for_test.flags index fdf39330a50e..38fdcf3311b9 100644 --- a/android/java/apk_for_test.flags +++ b/android/java/apk_for_test.flags @@ -83,7 +83,8 @@ } -keep class org.chromium.chrome.browser.toolbar.ToolbarManager { - *** mBottomControlsCoordinator; + *** mBottomControlsCoordinatorSupplier; + *** mCallbackController; *** mBrowserControlsSizer; *** mFullscreenManager; *** mActivityTabProvider; diff --git a/android/java/org/chromium/chrome/browser/app/BraveActivity.java b/android/java/org/chromium/chrome/browser/app/BraveActivity.java index 29c7397480b6..eaa06d3da09f 100644 --- a/android/java/org/chromium/chrome/browser/app/BraveActivity.java +++ b/android/java/org/chromium/chrome/browser/app/BraveActivity.java @@ -70,6 +70,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.tab.Tab; import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabLaunchType; @@ -150,7 +151,7 @@ public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) { // Handle items replaced by Brave. if (id == R.id.info_menu_id && currentTab != null) { ShareDelegate shareDelegate = (ShareDelegate) getShareDelegateSupplier().get(); - shareDelegate.share(currentTab, false); + shareDelegate.share(currentTab, false, ShareOrigin.OVERFLOW_MENU); return true; } @@ -504,9 +505,8 @@ private void handleBraveSetDefaultBrowserDialog() { View layout = inflater.inflate(R.layout.brave_set_default_browser_dialog, (ViewGroup) findViewById(R.id.brave_set_default_browser_toast_container)); - Toast toast = new Toast(context); + Toast toast = new Toast(context, layout); toast.setDuration(Toast.LENGTH_LONG); - toast.setView(layout); toast.setGravity(Gravity.TOP, 0, 40); toast.show(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(BRAVE_BLOG_URL)); diff --git a/android/java/org/chromium/chrome/browser/preferences/website/BraveShieldsContentSettings.java b/android/java/org/chromium/chrome/browser/preferences/website/BraveShieldsContentSettings.java index 3fe46850634d..404c9ae5bd45 100644 --- a/android/java/org/chromium/chrome/browser/preferences/website/BraveShieldsContentSettings.java +++ b/android/java/org/chromium/chrome/browser/preferences/website/BraveShieldsContentSettings.java @@ -16,14 +16,14 @@ @JNINamespace("chrome::android") public class BraveShieldsContentSettings { - static public final String RESOURCE_IDENTIFIER_ADS = "ads"; + static public final String RESOURCE_IDENTIFIER_ADS = "shieldsAds"; static public final String RESOURCE_IDENTIFIER_TRACKERS = "trackers"; static public final String RESOURCE_IDENTIFIER_ADS_TRACKERS = "ads_trackers"; static public final String RESOURCE_IDENTIFIER_DATA_SAVED = "data_saved"; static public final String RESOURCE_IDENTIFIER_HTTP_UPGRADABLE_RESOURCES = "httpUpgradableResources"; static public final String RESOURCE_IDENTIFIER_BRAVE_SHIELDS = "braveShields"; static public final String RESOURCE_IDENTIFIER_FINGERPRINTING = "fingerprinting"; - static public final String RESOURCE_IDENTIFIER_COOKIES = "cookies"; + static public final String RESOURCE_IDENTIFIER_COOKIES = "shieldsCookies"; static public final String RESOURCE_IDENTIFIER_REFERRERS = "referrers"; static public final String RESOURCE_IDENTIFIER_JAVASCRIPTS = "javascript"; diff --git a/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java b/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java index 61d7c1409f79..cb622a0884e7 100644 --- a/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java +++ b/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java @@ -20,6 +20,7 @@ import org.chromium.chrome.browser.layouts.LayoutStateProvider; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.share.ShareDelegate; +import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration; import org.chromium.chrome.features.start_surface.StartSurface; @@ -37,12 +38,13 @@ public BraveTabbedRootUiCoordinator(ChromeActivity activity, Supplier contextualSearchManagerSupplier, ObservableSupplier tabModelSelectorSupplier, OneshotSupplier startSurfaceSupplier, - OneshotSupplier layoutStateProviderOneshotSupplier) { + OneshotSupplier layoutStateProviderOneshotSupplier, + Supplier startSurfaceParentTabSupplier) { super(activity, onOmniboxFocusChangedListener, intentMetadataOneshotSupplier, shareDelegateSupplier, tabProvider, ephemeralTabCoordinatorSupplier, profileSupplier, bookmarkBridgeSupplier, overviewModeBehaviorSupplier, contextualSearchManagerSupplier, tabModelSelectorSupplier, startSurfaceSupplier, - layoutStateProviderOneshotSupplier); + layoutStateProviderOneshotSupplier, startSurfaceParentTabSupplier); } @Override diff --git a/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java b/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java index 47d53081d402..782df4dc9b9b 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java +++ b/android/java/org/chromium/chrome/browser/toolbar/BraveToolbarManager.java @@ -10,12 +10,15 @@ import android.view.View.OnClickListener; import android.view.ViewStub; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.Callback; +import org.chromium.base.CallbackController; import org.chromium.base.supplier.ObservableSupplier; +import org.chromium.base.supplier.ObservableSupplierImpl; import org.chromium.base.supplier.OneshotSupplier; import org.chromium.base.supplier.Supplier; import org.chromium.chrome.R; @@ -25,7 +28,7 @@ import org.chromium.chrome.browser.browser_controls.BrowserControlsSizer; import org.chromium.chrome.browser.compositor.CompositorViewHolder; import org.chromium.chrome.browser.compositor.Invalidator; -import org.chromium.chrome.browser.compositor.layouts.LayoutManager; +import org.chromium.chrome.browser.compositor.layouts.LayoutManagerImpl; import org.chromium.chrome.browser.findinpage.FindToolbarManager; import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.homepage.HomepageManager; @@ -64,7 +67,8 @@ import java.util.List; public class BraveToolbarManager extends ToolbarManager { - private BottomControlsCoordinator mBottomControlsCoordinator; + private ObservableSupplierImpl mBottomControlsCoordinatorSupplier; + private CallbackController mCallbackController; private BrowserControlsSizer mBrowserControlsSizer; private FullscreenManager mFullscreenManager; private ActivityTabProvider mActivityTabProvider; @@ -110,7 +114,8 @@ public BraveToolbarManager(AppCompatActivity activity, BrowserControlsSizer cont Supplier modalDialogManagerSupplier, NightModeStateProvider nightModeStateProvider, StatusBarColorController statusBarColorController, AppMenuDelegate appMenuDelegate, - ActivityLifecycleDispatcher activityLifecycleDispatcher) { + ActivityLifecycleDispatcher activityLifecycleDispatcher, + @NonNull Supplier startSurfaceParentTabSupplier) { super(activity, controlsSizer, fullscreenManager, controlContainer, compositorViewHolder, urlFocusChangedCallback, themeColorProvider, tabObscuringHandler, shareDelegateSupplier, identityDiscController, buttonDataProviders, tabProvider, @@ -121,15 +126,18 @@ public BraveToolbarManager(AppCompatActivity activity, BrowserControlsSizer cont intentMetadataOneshotSupplier, promoShownOneshotSupplier, windowAndroid, isInOverviewModeSupplier, isCustomTab, modalDialogManagerSupplier, nightModeStateProvider, statusBarColorController, appMenuDelegate, - activityLifecycleDispatcher); + activityLifecycleDispatcher, startSurfaceParentTabSupplier); mOmniboxFocusStateSupplier = omniboxFocusStateSupplier; mLayoutStateProviderSupplier = layoutStateProviderSupplier; mActivity = activity; mBraveHomepageStateListener = () -> { - assert (mBottomControlsCoordinator instanceof BraveBottomControlsCoordinator); - ((BraveBottomControlsCoordinator) mBottomControlsCoordinator).updateHomeButtonState(); + assert (mBottomControlsCoordinatorSupplier != null); + assert (mBottomControlsCoordinatorSupplier.get() + instanceof BraveBottomControlsCoordinator); + ((BraveBottomControlsCoordinator) mBottomControlsCoordinatorSupplier.get()) + .updateHomeButtonState(); }; HomepageManager.getInstance().addListener(mBraveHomepageStateListener); } @@ -143,19 +151,18 @@ public void enableBottomControls() { } viewStub.setOnInflateListener((stub, inflated) -> { mRootBottomView = inflated; }); assert (mActivity instanceof ChromeActivity); - mBottomControlsCoordinator = - new BraveBottomControlsCoordinator(mLayoutStateProviderSupplier, - BottomTabSwitcherActionMenuCoordinator.createOnLongClickListener( - id -> ((ChromeActivity) mActivity).onOptionsItemSelected(id, null)), - mBrowserControlsSizer, mFullscreenManager, - mActivity.findViewById(R.id.bottom_controls_stub), mActivityTabProvider, - mAppThemeColorProvider, mShareDelegateSupplier, - mMenuButtonCoordinator.getMenuButtonHelperSupplier(), - mShowStartSurfaceSupplier, mToolbarTabController::openHomepage, - (reason) - -> setUrlBarFocus(true, reason), - mScrimCoordinator, mOmniboxFocusStateSupplier); - ((BraveBottomControlsCoordinator) mBottomControlsCoordinator).setRootView(mRootBottomView); + mBottomControlsCoordinatorSupplier.set(new BraveBottomControlsCoordinator( + mLayoutStateProviderSupplier, + BottomTabSwitcherActionMenuCoordinator.createOnLongClickListener( + id -> ((ChromeActivity) mActivity).onOptionsItemSelected(id, null)), + mActivityTabProvider, mBrowserControlsSizer, mFullscreenManager, + mActivity.findViewById(R.id.bottom_controls_stub), mAppThemeColorProvider, + mShareDelegateSupplier, mMenuButtonCoordinator.getMenuButtonHelperSupplier(), + mToolbarTabController::openHomepage, + mCallbackController.makeCancelable((reason) -> setUrlBarFocus(true, reason)), + mScrimCoordinator, mOmniboxFocusStateSupplier)); + ((BraveBottomControlsCoordinator) mBottomControlsCoordinatorSupplier.get()) + .setRootView(mRootBottomView); boolean isBottomToolbarVisible = BottomToolbarConfiguration.isBottomToolbarEnabled() && mActivity.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE; @@ -163,14 +170,14 @@ public void enableBottomControls() { } @Override - public void initializeWithNative(LayoutManager layoutManager, + public void initializeWithNative(LayoutManagerImpl layoutManager, OnClickListener tabSwitcherClickHandler, OnClickListener newTabClickHandler, OnClickListener bookmarkClickHandler, OnClickListener customTabsBackClickHandler, Supplier showStartSurfaceSupplier) { super.initializeWithNative(layoutManager, tabSwitcherClickHandler, newTabClickHandler, bookmarkClickHandler, customTabsBackClickHandler, showStartSurfaceSupplier); - if (mBottomControlsCoordinator != null) { + if (mBottomControlsCoordinatorSupplier.get() != null) { ApiCompatibilityUtils.setAccessibilityTraversalBefore( mLocationBar.getContainerView(), R.id.bottom_toolbar); } @@ -196,7 +203,7 @@ public void destroy() { protected void onOrientationChange(int newOrientation) { if (mActionModeController != null) mActionModeController.showControlsOnOrientationChange(); - if (mBottomControlsCoordinator != null + if (mBottomControlsCoordinatorSupplier.get() != null && BottomToolbarConfiguration.isBottomToolbarEnabled()) { boolean isBottomToolbarVisible = newOrientation != Configuration.ORIENTATION_LANDSCAPE; setBottomToolbarVisible(isBottomToolbarVisible); @@ -227,8 +234,8 @@ protected void updateBookmarkButtonStatus() { currentTab == null || bridge == null || bridge.isEditBookmarksEnabled(); mToolbar.updateBookmarkButton(isBookmarked, editingAllowed); - if (mBottomControlsCoordinator instanceof BraveBottomControlsCoordinator) { - ((BraveBottomControlsCoordinator) mBottomControlsCoordinator) + if (mBottomControlsCoordinatorSupplier.get() instanceof BraveBottomControlsCoordinator) { + ((BraveBottomControlsCoordinator) mBottomControlsCoordinatorSupplier.get()) .updateBookmarkButton(isBookmarked, editingAllowed); } } @@ -245,7 +252,7 @@ private void setBottomToolbarVisible(boolean visible) { if (mToolbar instanceof BraveTopToolbarCoordinator) { ((BraveTopToolbarCoordinator) mToolbar).onBottomToolbarVisibilityChanged(visible); } - mBottomControlsCoordinator.setBottomControlsVisible(visible); + mBottomControlsCoordinatorSupplier.get().setBottomControlsVisible(visible); } public boolean isBottomToolbarVisible() { 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 ec5cf16bcbeb..2a923db76a65 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java @@ -35,6 +35,7 @@ import org.chromium.chrome.browser.omnibox.OmniboxFocusReason; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.share.ShareDelegate; +import org.chromium.chrome.browser.share.ShareDelegateImpl.ShareOrigin; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider; import org.chromium.chrome.browser.tasks.ReturnToChromeExperimentsUtil; @@ -78,7 +79,6 @@ class BottomToolbarCoordinator implements View.OnLongClickListener { private final Callback mShareDelegateSupplierCallback; private ObservableSupplierImpl mShareButtonListenerSupplier = new ObservableSupplierImpl<>(); - private final Supplier mShowStartSurfaceCallable; private CallbackController mCallbackController = new CallbackController(); ObservableSupplier mMenuButtonHelperSupplier; private BottomControlsMediator mBottomControlsMediator; @@ -98,8 +98,6 @@ class BottomToolbarCoordinator implements View.OnLongClickListener { * @param themeColorProvider The {@link ThemeColorProvider} for the bottom toolbar. * @param shareDelegateSupplier The supplier for the {@link ShareDelegate} the bottom controls * should use to share content. - * @param showStartSurfaceCallable The action that opens the start surface, returning true if - * the start surface is shown. * @param openHomepageAction The action that opens the homepage. * @param setUrlBarFocusAction The function that sets Url bar focus. The first argument is * @param overviewModeBehaviorSupplier Supplier for the overview mode manager. @@ -108,8 +106,7 @@ class BottomToolbarCoordinator implements View.OnLongClickListener { BottomToolbarCoordinator(ScrollingBottomViewResourceFrameLayout scrollingBottomView, ViewStub stub, ActivityTabProvider tabProvider, OnLongClickListener tabsSwitcherLongClickListner, ThemeColorProvider themeColorProvider, - ObservableSupplier shareDelegateSupplier, - Supplier showStartSurfaceCallable, Runnable openHomepageAction, + ObservableSupplier shareDelegateSupplier, Runnable openHomepageAction, Callback setUrlBarFocusAction, OneshotSupplier layoutStateProviderSupplier, ObservableSupplier menuButtonHelperSupplier, @@ -119,18 +116,11 @@ class BottomToolbarCoordinator implements View.OnLongClickListener { layoutStateProviderSupplier.onAvailable( mCallbackController.makeCancelable(this::setLayoutStateProvider)); - mShowStartSurfaceCallable = showStartSurfaceCallable; final OnClickListener homeButtonListener = v -> { openHomepageAction.run(); }; final OnClickListener searchAcceleratorListener = v -> { - // Only switch to HomePage when overview is showing. - if (mLayoutStateProvider != null - && mLayoutStateProvider.isLayoutVisible(LayoutType.TAB_SWITCHER) - && mShowStartSurfaceCallable != null) { - mShowStartSurfaceCallable.get(); - } setUrlBarFocusAction.onResult(OmniboxFocusReason.ACCELERATOR_TAP); }; @@ -340,7 +330,7 @@ private void onShareDelegateAvailable(ShareDelegate shareDelegate) { } Tab tab = mTabProvider.get(); - shareDelegate.share(tab, /*shareDirectly=*/false); + shareDelegate.share(tab, /*shareDirectly=*/false, ShareOrigin.TOP_TOOLBAR); }; mShareButtonListenerSupplier.set(shareButtonListener); diff --git a/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java index dfc02b15de37..c8b74687bc32 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java @@ -22,7 +22,7 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.browser_controls.BrowserControlsSizer; -import org.chromium.chrome.browser.compositor.layouts.LayoutManager; +import org.chromium.chrome.browser.compositor.layouts.LayoutManagerImpl; import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.layouts.LayoutStateProvider; import org.chromium.chrome.browser.share.ShareDelegate; @@ -44,7 +44,6 @@ public class BraveBottomControlsCoordinator extends BottomControlsCoordinator { private ThemeColorProvider mThemeColorProvider; private ObservableSupplier mShareDelegateSupplier; private ObservableSupplier mMenuButtonHelperSupplier; - private Supplier mShowStartSurfaceCallable; private Runnable mOpenHomepageAction; private Callback mSetUrlBarFocusAction; private OneshotSupplier mLayoutStateProviderSupplier; @@ -52,24 +51,22 @@ public class BraveBottomControlsCoordinator extends BottomControlsCoordinator { public BraveBottomControlsCoordinator( OneshotSupplier layoutStateProviderSupplier, - OnLongClickListener tabSwitcherLongclickListener, BrowserControlsSizer controlsSizer, - FullscreenManager fullscreenManager, ViewStub stub, ActivityTabProvider tabProvider, + OnLongClickListener tabSwitcherLongclickListener, ActivityTabProvider tabProvider, + BrowserControlsSizer controlsSizer, FullscreenManager fullscreenManager, ViewStub stub, ThemeColorProvider themeColorProvider, ObservableSupplier shareDelegateSupplier, ObservableSupplier menuButtonHelperSupplier, - Supplier showStartSurfaceCallable, Runnable openHomepageAction, - Callback setUrlBarFocusAction, ScrimCoordinator scrimCoordinator, + Runnable openHomepageAction, Callback setUrlBarFocusAction, + ScrimCoordinator scrimCoordinator, ObservableSupplier omniboxFocusStateSupplier) { - super(controlsSizer, fullscreenManager, stub, tabProvider, themeColorProvider, - shareDelegateSupplier, menuButtonHelperSupplier, showStartSurfaceCallable, - openHomepageAction, setUrlBarFocusAction, scrimCoordinator, - omniboxFocusStateSupplier); + super(controlsSizer, fullscreenManager, stub, themeColorProvider, shareDelegateSupplier, + menuButtonHelperSupplier, openHomepageAction, setUrlBarFocusAction, + scrimCoordinator, omniboxFocusStateSupplier); mTabSwitcherLongclickListener = tabSwitcherLongclickListener; mTabProvider = tabProvider; mThemeColorProvider = themeColorProvider; mShareDelegateSupplier = shareDelegateSupplier; - mShowStartSurfaceCallable = showStartSurfaceCallable; mOpenHomepageAction = openHomepageAction; mSetUrlBarFocusAction = setUrlBarFocusAction; mLayoutStateProviderSupplier = layoutStateProviderSupplier; @@ -83,7 +80,7 @@ public void setRootView(View root) { @Override public void initializeWithNative(Activity activity, ResourceManager resourceManager, - LayoutManager layoutManager, OnClickListener tabSwitcherListener, + LayoutManagerImpl layoutManager, OnClickListener tabSwitcherListener, OnClickListener newTabClickListener, WindowAndroid windowAndroid, TabCountProvider tabCountProvider, IncognitoStateProvider incognitoStateProvider, ViewGroup topToolbarRoot, Runnable closeAllTabsAction) { @@ -95,8 +92,8 @@ public void initializeWithNative(Activity activity, ResourceManager resourceMana mBottomToolbarCoordinator = new BottomToolbarCoordinator(mRoot, mRoot.findViewById(R.id.bottom_toolbar_stub), mTabProvider, mTabSwitcherLongclickListener, mThemeColorProvider, mShareDelegateSupplier, - mShowStartSurfaceCallable, mOpenHomepageAction, mSetUrlBarFocusAction, - mLayoutStateProviderSupplier, mMenuButtonHelperSupplier, mMediator); + mOpenHomepageAction, mSetUrlBarFocusAction, mLayoutStateProviderSupplier, + mMenuButtonHelperSupplier, mMediator); mBottomToolbarCoordinator.initializeWithNative(tabSwitcherListener, newTabClickListener, tabCountProvider, incognitoStateProvider, topToolbarRoot, closeAllTabsAction); diff --git a/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java b/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java index 4c0c72846b7a..e1889684bd80 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java +++ b/android/java/org/chromium/chrome/browser/toolbar/top/BraveTopToolbarCoordinator.java @@ -25,6 +25,7 @@ import org.chromium.chrome.browser.user_education.UserEducationHelper; import org.chromium.chrome.features.start_surface.StartSurface; import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration; +import org.chromium.ui.resources.ResourceManager; import java.util.List; @@ -47,14 +48,15 @@ public BraveTopToolbarCoordinator(ToolbarControlContainer controlContainer, ObservableSupplier homeButtonVisibilitySupplier, ObservableSupplier identityDiscStateSupplier, Callback invalidatorCallback, Supplier identityDiscButtonSupplier, - OneshotSupplier startSurfaceSupplier, Runnable tabOrModelChangeRunnable) { + OneshotSupplier startSurfaceSupplier, Runnable tabOrModelChangeRunnable, + Supplier resourceManagerSupplier) { super(controlContainer, toolbarLayout, toolbarDataProvider, tabController, userEducationHelper, buttonDataProviders, layoutStateProviderSupplier, normalThemeColorProvider, overviewThemeColorProvider, browsingModeMenuButtonCoordinator, overviewModeMenuButtonCoordinator, appMenuButtonHelperSupplier, tabModelSelectorSupplier, homeButtonVisibilitySupplier, identityDiscStateSupplier, invalidatorCallback, identityDiscButtonSupplier, - startSurfaceSupplier, tabOrModelChangeRunnable); + startSurfaceSupplier, tabOrModelChangeRunnable, resourceManagerSupplier); mBraveToolbarLayout = toolbarLayout; diff --git a/android/java/res/layout/binance_deposit_layout.xml b/android/java/res/layout/binance_deposit_layout.xml index e8316ca8e733..d71910331986 100644 --- a/android/java/res/layout/binance_deposit_layout.xml +++ b/android/java/res/layout/binance_deposit_layout.xml @@ -36,7 +36,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:padding="8dp" - android:tint="@android:color/white" + app:tint="@android:color/white" app:srcCompat="@drawable/ic_back" /> + app:tint="@color/shield_back_button_tint"/> diff --git a/android/java/res/layout/highlight_layout.xml b/android/java/res/layout/highlight_layout.xml index 3b43598b681e..1483431a5a01 100644 --- a/android/java/res/layout/highlight_layout.xml +++ b/android/java/res/layout/highlight_layout.xml @@ -1,6 +1,7 @@ @@ -31,7 +32,7 @@ android:layout_gravity="end|top" android:padding="16dp" android:src="@drawable/btn_close" - android:tint="@color/onboarding_text_color"/> + app:tint="@color/onboarding_text_color"/> diff --git a/android/java/res/xml/manage_sync_preferences.xml b/android/java/res/xml/manage_sync_preferences.xml index 59d4bcc09e61..8a9148a6e49c 100644 --- a/android/java/res/xml/manage_sync_preferences.xml +++ b/android/java/res/xml/manage_sync_preferences.xml @@ -59,7 +59,7 @@ diff --git a/android/javatests/org/chromium/chrome/browser/BytecodeTest.java b/android/javatests/org/chromium/chrome/browser/BytecodeTest.java index a96c24065dd1..947d6938b7b2 100644 --- a/android/javatests/org/chromium/chrome/browser/BytecodeTest.java +++ b/android/javatests/org/chromium/chrome/browser/BytecodeTest.java @@ -151,7 +151,9 @@ public void testFieldsExist() throws Exception { fieldExists("org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator", "mMediator")); Assert.assertTrue(fieldExists("org/chromium/chrome/browser/toolbar/ToolbarManager", - "mBottomControlsCoordinator")); + "mBottomControlsCoordinatorSupplier")); + Assert.assertTrue(fieldExists( + "org/chromium/chrome/browser/toolbar/ToolbarManager", "mCallbackController")); Assert.assertTrue(fieldExists( "org/chromium/chrome/browser/toolbar/ToolbarManager", "mBrowserControlsSizer")); Assert.assertTrue(fieldExists( diff --git a/app/generated_resources.grd b/app/generated_resources.grd index f6f33be95239..ef464d706d99 100644 --- a/app/generated_resources.grd +++ b/app/generated_resources.grd @@ -1069,6 +1069,9 @@ are declared in tools/grit/grit_rule.gni. Move tab to new window + + Toggle Commander + @@ -1146,6 +1149,9 @@ are declared in tools/grit/grit_rule.gni. Move Tab to New Window + + Toggle Commander + @@ -1194,7 +1200,7 @@ are declared in tools/grit/grit_rule.gni. R&eopen closed window - &Name window... + Name &window... @@ -1229,7 +1235,7 @@ are declared in tools/grit/grit_rule.gni. R&eopen Closed Window - &Name Window... + Name &Window... @@ -3880,6 +3886,9 @@ are declared in tools/grit/grit_rule.gni. Identify and eject storage devices + + View and manage your tab groups + Read a list of your most frequently visited websites @@ -4750,6 +4759,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Update password for $1example.com? + + Save password to your Brave sync chain? + + + Save username to your Brave sync chain? + Passwords are saved in your Brave sync chain so you can use them on any device @@ -4947,6 +4962,11 @@ Keep your key file in a safe place. You will need it to create new versions of y Choose sites to clear + + + Lacros is an experimental browser. Please report any issues with Help > "Report an issue..." + + You are using an unsupported command-line flag: $1--no-sandbox. Stability and security will suffer. @@ -6987,6 +7007,17 @@ Keep your key file in a safe place. You will need it to create new versions of y This will reset your startup page, new tab page, search engine, and pinned tabs. It will also disable all extensions and clear temporary data like cookies. Your bookmarks, history and saved passwords will not be cleared. + + This action will: + <br><br> + • Reset Brave settings and Brave shortcuts + <br> + • Disable extensions + <br> + • Delete cookies and other temporary site data + <br><br> + Bookmarks, history, and saved passwords won't be affected. + $1SuperDuper PC Cleaner Pro wants to reset your settings. @@ -7827,9 +7858,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Could not load $1Flash - - Flash Player will no longer be supported after December 2020. - @@ -8037,12 +8065,21 @@ Please help our engineers fix this problem. Tell us what happened right before y Password sync isn't working + + Make sure you can always access your sync data + + + Make sure you can always access your saved passwords + Sign in again Enter passphrase + + Fix now + Fix now @@ -8209,6 +8246,9 @@ Please help our engineers fix this problem. Tell us what happened right before y This page could not be translated + + Choose the language to translate the page to + Options @@ -8844,6 +8884,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Location + + This site will ask again next time. + Location is turned off in Mac System Preferences @@ -9459,12 +9502,6 @@ Please help our engineers fix this problem. Tell us what happened right before y - - Register - - - Manage - {NUM_PRINTER, plural, =1 {New printer on your network} @@ -9481,101 +9518,10 @@ Please help our engineers fix this problem. Tell us what happened right before y Add to Cloud Print - - Devices - - - User: - - - Confirm registration - - - Adding printer... - - - Could not complete registration - - - You must confirm registration on your printer to finish this process - check it now. - - - Adding the printer to your account - this may take a moment... - - - An error has occurred. Please check your printer and try again. - - - Printer on Google Cloud Print - - - Device on Brave Cloud Devices - - - No other available devices. - - - One other available device. - - - $1 other available devices. - - - Loading - - - Add Devices - - - Looks like there are no devices available to register on the network. If your device is on and connected to the internet, try registering it using instructions in its instruction manual. - - - Could not load devices. - - - Try again - - - You need to sign in to Brave to see your devices - - - You need to sign in to Brave to register new devices - - - sign in - - - New devices - - - My devices - - - - You can add classic printers connected to your computer to $1Google Cloud Print. - - - Classic printers - - Don't show this again - - Printer registration has been canceled. - - - Printer registration has timed out. In order to register a printer, you must confirm registration on the printer. - - - - - Cloud printing will no longer be supported after December 31. <a href="$1https://google.com/" target="_blank">Learn more</a> - - - Cloud printing will no longer be supported after December 31. Contact your administrator. - @@ -9683,6 +9629,30 @@ Please help our engineers fix this problem. Tell us what happened right before y Expanded + + Tab moved right + + + Tab moved left + + + Tab moved to start of tabstrip + + + Tab moved to end of tabstrip + + + Tab moved into unnamed group - $1Brave Search and 3 other tabs + + + Tab moved into group $1 - $2Brave Search and 3 other tabs + + + Tab removed from unnamed group - $1Brave Search and 3 other tabs + + + Tab removed from group $1 - $2Brave Search and 3 other tabs + diff --git a/app/generated_resources_override.grd b/app/generated_resources_override.grd index 37de14b9e665..d101381449d9 100644 --- a/app/generated_resources_override.grd +++ b/app/generated_resources_override.grd @@ -819,9 +819,8 @@ are declared in tools/grit/grit_rule.gni. - - + diff --git a/app/global_media_controls_strings.grdp b/app/global_media_controls_strings.grdp index 6b4b449a2c40..8722884bdda8 100644 --- a/app/global_media_controls_strings.grdp +++ b/app/global_media_controls_strings.grdp @@ -20,4 +20,7 @@ Live Caption (English only) + + Downloading... $117% + diff --git a/app/media_router_strings.grdp b/app/media_router_strings.grdp index bc854eb53f2e..9e2e57953865 100644 --- a/app/media_router_strings.grdp +++ b/app/media_router_strings.grdp @@ -111,6 +111,9 @@ Source not supported + + Available for specific video sites + diff --git a/app/nearby_share_strings.grdp b/app/nearby_share_strings.grdp index 8aa497da601d..da6ffae79836 100644 --- a/app/nearby_share_strings.grdp +++ b/app/nearby_share_strings.grdp @@ -14,11 +14,17 @@ - - No contacts are available. To use Nearby Share with your contacts, add the email address linked with their Brave sync chain to your contacts. + + Unable to download contact list. Please check your network connection, or <a href="#" id="tryAgainLink">try again</a>. - - No available contacts + + Downloading contact list... + + + To use Nearby Share with these contacts, add the email address linked with their Brave sync chain to your contacts. + + + No reachable contacts Profiles who have chosen to be visible to you when their screen is unlocked and devices near you when Nearby Share is open @@ -66,6 +72,9 @@ Nearby Share + + Scanning for nearby devices... + @@ -108,6 +117,24 @@ $1Josh's $2Bravebook + + Can't share + + + The device you're sharing with didn't respond + + + The device you’re trying to share with did not accept + + + Something went wrong + + + Time out + + + Unsupported file type + {COUNT, plural, =1 {1 app} other {# apps}} @@ -152,6 +179,10 @@ Receive from this device? + + + $13 Files + diff --git a/app/os_settings_search_tag_strings.grdp b/app/os_settings_search_tag_strings.grdp index f9bf6cbb70df..d93689587cc1 100644 --- a/app/os_settings_search_tag_strings.grdp +++ b/app/os_settings_search_tag_strings.grdp @@ -752,15 +752,12 @@ - + Linux - + Crostini - - Developers - Linux shared folders @@ -1025,6 +1022,9 @@ Fullscreen magnifier + + Magnifier follows keyboard focus + Docked magnifier diff --git a/app/os_settings_strings.grdp b/app/os_settings_strings.grdp index 54f8c28a16ca..7845081b73f1 100644 --- a/app/os_settings_strings.grdp +++ b/app/os_settings_strings.grdp @@ -794,6 +794,9 @@ Enable fullscreen magnifier + + Zoomed in screen follows keyboard focus + Fullscreen zoom level: @@ -974,30 +977,6 @@ $11.5s - - Please press a switch key to assign. - - - Press '$1backspace' again to confirm and exit. - - - '$1backspace' is already assigned. Press '$1backspace' again to remove assignment and exit. - - - Keys do not match. '$1enter' was pressed. '$2backspace' was pressed before. Press any key to exit. - - - Open a dialog to assign a switch key - - - '$1enter' is already assigned to the '$2Select' action. Press any key to exit. - - - Unrecognized key. Press any key to exit. - - - No switches assigned - Text-to-Speech @@ -1188,11 +1167,11 @@ - - Developers + + Linux (Beta) - - Linux development environment + + Linux Manage shared folders @@ -2248,6 +2227,24 @@ Looking for a mobile network. <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> + + eSIM + + + SIM + + + Instant Tethering + + + No available eSIM profiles. Download a new profile <a href="#" id="cellularEsimLink">here</a> + + + No available SIM profiles. Setup a new profile <a href="#" id="cellularPsimLink">here.</a> + + + No device detected <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> + @@ -2315,38 +2312,74 @@ Send and receive text messages from your $1Bravebook. <a target="_blank" rel="noopener noreferrer" href="$2https://google.com/">Learn more</a> - + Phone Hub - + Notifications - - Task Continuation + + Recent Brave tabs - - Make the best of your Android phone on your your $1Bravebook + + Extend the best of your Android phone to your $1Bravebook - - View your phones notifications on your $1Bravebook + + View notifications from your chat apps on your $1Bravebook - - View your active Brave tabs in Phone Hub + + View recent Brave tabs from your phone - - Turn on notifications on Android phone + + Turn on notifications on your phone - - Connecting to your Phone + + Receive notifications from your phone on your $1Bravebook - - Make sure your phone is nearby, unlocked and has Bluetooth and Wi-Fi turned on. Turn on notifications toggle under Google Play Services>Bravebook Phone Hub from your phone. + + Complete setup on your phone - + + Make sure your phone is nearby, unlocked, and has Bluetooth and Wi-Fi turned on. Follow steps on your phone to complete setup. + + + Connecting to your phone + + + Make sure your phone is nearby, unlocked, and has Bluetooth and Wi-Fi turned on. + + Notifications turned on - You will receive your phone notifications on your Bravebook + You can now receive notifications from your phone on your $1Bravebook. Dismissing notifications on your $1Bravebook will also dismiss them on your phone. Make sure your phone is nearby and has Bluetooth and Wi-Fi turned on. + + + Could not establish connection + + + We were unable to establish a connection with your phone. Make sure your phone is nearby, unlocked, and has Bluetooth and Wi-Fi turned on. + + + Connection lost with your phone + + + We were unable to maintain a connection with your phone. Make sure your phone is nearby, unlocked, and has Bluetooth and Wi-Fi turned on. + + + Could not set up notifications syncing + + + Notification syncing is not supported for phones in a work profile. <a target="_blank" rel="noopener noreferrer" href="$1https://google.com/">Learn more</a> + + + Notification syncing is not supported for phones in a work profile + + + Get started + + + Try again Wi-Fi Sync @@ -2480,6 +2513,11 @@ Enter your password to configure security and sign-in + + + Kerberos + + Advanced @@ -2676,6 +2714,9 @@ + + Reset settings + Powerwash diff --git a/app/printing_strings.grdp b/app/printing_strings.grdp index fa4d6ab86ed9..47be3ba04a57 100644 --- a/app/printing_strings.grdp +++ b/app/printing_strings.grdp @@ -415,28 +415,4 @@ The $1Google Cloud Print connector process has crashed. Restart? - - - - - This printer won't be supported after December. <a href="$1https://google.com/" target="_blank">Learn more</a> - - - This printer won't be supported after December. Contact your admin. - - - Not supported after December - - - Warning - - - - This option won't be supported after December. <a href="$1https://google.com/" target="_blank">Learn more</a> - - - This option won't be supported after December. Contact your admin. - - - diff --git a/app/profiles_strings.grdp b/app/profiles_strings.grdp index ef7e54bc4fde..256ec14e0691 100644 --- a/app/profiles_strings.grdp +++ b/app/profiles_strings.grdp @@ -77,10 +77,21 @@ Profiles + + Profiles + Add Profile... + + Add Profile... + + + + + Add profile... + Accounts and sync @@ -143,6 +154,9 @@ Other profiles + + Other profiles + Your accounts @@ -157,6 +171,9 @@ Other Profiles + + Other Profiles + Your Accounts @@ -167,11 +184,11 @@ Manage Profiles - - Edit profile, $1Jane Doe + + Manage profiles - - Edit profile, $1Jane Doe, $2jane.doe@gmail.com + + Customize profile Guest @@ -331,6 +348,9 @@ Sun and clouds + + Default avatar + Cat diff --git a/app/profiles_strings_override.grdp b/app/profiles_strings_override.grdp index df4d1a09f615..09f33ceb1b71 100644 --- a/app/profiles_strings_override.grdp +++ b/app/profiles_strings_override.grdp @@ -23,7 +23,9 @@ Add Profile... - + + + Other profiles @@ -40,12 +42,6 @@ Manage Profiles - - Edit profile, $1Jane Doe - - - Edit profile, $1Jane Doe, $2jane.doe@gmail.com - Profile $11 diff --git a/app/settings_strings.grdp b/app/settings_strings.grdp index dbff0f38abd5..0a8129e7c1e7 100644 --- a/app/settings_strings.grdp +++ b/app/settings_strings.grdp @@ -957,33 +957,10 @@ Notifications will be disabled - + Printing - - Show notifications when new printers are detected on the network - - - Manage Cloud Print devices - - - - Printers - - - - Google Cloud Print - - - Google Cloud Print will no longer be supported after December 31 - - - Google Cloud Print will no longer be supported after December 31. <a target="_blank" rel="noopener noreferrer" href="$1">Learn more</a> - - - Google Cloud Print will no longer be supported after December 31. Contact your administrator. - @@ -1304,25 +1281,25 @@ Brave can check your computer for harmful software - Brave didn't find known harmful software on your computer. Last checked: a moment ago. + Brave didn't find harmful software on your computer • Checked just now {NUM_MINS, plural, - =1 {Brave didn't find known harmful software on your computer. Last checked: 1 minute ago.} - other {Brave didn't find known harmful software on your computer. Last checked: {NUM_MINS} minutes ago.}} + =1 {Brave didn't find harmful software on your computer • Checked 1 minute ago} + other {Brave didn't find harmful software on your computer • Checked {NUM_MINS} minutes ago}} {NUM_HOURS, plural, - =1 {Brave didn't find known harmful software on your computer. Last checked: 1 hour ago.} - other {Brave didn't find known harmful software on your computer. Last checked: {NUM_HOURS} hours ago.}} + =1 {Brave didn't find harmful software on your computer • Checked 1 hour ago} + other {Brave didn't find harmful software on your computer • Checked {NUM_HOURS} hours ago}} - Brave didn't find known harmful software on your computer. Last checked: yesterday. + Brave didn't find harmful software on your computer • Checked yesterday {NUM_DAYS, plural, - =1 {Brave didn't find known harmful software on your computer. Last checked: 1 day ago.} - other {Brave didn't find known harmful software on your computer. Last checked: {NUM_DAYS} days ago.}} + =1 {Brave didn't find harmful software on your computer • Checked 1 day ago} + other {Brave didn't find harmful software on your computer • Checked {NUM_DAYS} days ago}} Brave found harmful software on your computer @@ -1334,10 +1311,10 @@ Brave is removing harmful software from your computer... - <a target="_blank" rel="noopener noreferrer" href="$1">Your administrator</a> has disabled Brave's check for harmful software + <a target="_blank" rel="noopener noreferrer" href="$1">Your administrator</a> has turned off checking for harmful software - An error occurred while Brave was checking your computer for harmful software + Something went wrong. Click for more details. @@ -1556,6 +1533,9 @@ + + Reset settings? + Reset settings @@ -1986,21 +1966,6 @@ Not allowed to play sound - - Sites usually use plugins for features like streaming videos or installing apps - - - Sites can ask to use a plugin to access your computer (recommended) - - - Block plugins from accessing your computer - - - Allowed to use a plugin to access your computer - - - Not allowed to use a plugin to access your computer - Sites usually connect to USB devices for features like printing a document or saving to a storage device @@ -2222,9 +2187,6 @@ Recent activity - - Unsandboxed plugin access - MIDI devices @@ -2426,15 +2388,6 @@ Do not allow any site to download multiple files automatically - - Ask when a site wants to use a plugin to access your computer - - - Ask when a site wants to use a plugin to access your computer (recommended) - - - Do not allow any site to use a plugin to access your computer - Window placement @@ -2887,6 +2840,24 @@ Show desktop shortcut + + Customize profile + + + Name your profile + + + Pick a theme color + + + Pick an avatar + + + Create desktop shortcut + + + Create a desktop shortcut on your device to access directly to this profile + diff --git a/app/settings_strings_override.grdp b/app/settings_strings_override.grdp index c85e59650daf..3cc28e215d6b 100644 --- a/app/settings_strings_override.grdp +++ b/app/settings_strings_override.grdp @@ -46,8 +46,6 @@ - - diff --git a/browser/brave_content_browser_client_browsertest.cc b/browser/brave_content_browser_client_browsertest.cc index 26f7c9907830..6b7850154f13 100644 --- a/browser/brave_content_browser_client_browsertest.cc +++ b/browser/brave_content_browser_client_browsertest.cc @@ -24,6 +24,7 @@ #include "chrome/test/base/in_process_browser_test.h" #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/prefs/pref_service.h" #include "content/public/browser/navigation_entry.h" #include "content/public/test/browser_test.h" @@ -543,8 +544,8 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientReferrerTest, // Allow referrers for certain URL. content_settings()->SetContentSettingCustomScope( ContentSettingsPattern::FromString(kDocumentUrl.GetOrigin().spec() + "*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kReferrers, CONTENT_SETTING_ALLOW); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_REFERRERS, + CONTENT_SETTING_ALLOW); referrer = kReferrer.Clone(); client()->MaybeHideReferrer(browser()->profile(), kRequestUrl, kDocumentUrl, true, "GET", &referrer); diff --git a/browser/browsing_data/BUILD.gn b/browser/browsing_data/BUILD.gn index f8da5608b668..f9ca6eeaa4c4 100644 --- a/browser/browsing_data/BUILD.gn +++ b/browser/browsing_data/BUILD.gn @@ -8,8 +8,6 @@ source_set("browsing_data") { "brave_browsing_data_remover_delegate.h", "brave_clear_browsing_data.cc", "brave_clear_browsing_data.h", - "counters/brave_site_settings_counter.cc", - "counters/brave_site_settings_counter.h", ] deps = [ diff --git a/browser/browsing_data/brave_browsing_data_remover_delegate.cc b/browser/browsing_data/brave_browsing_data_remover_delegate.cc index e68abfcfedb7..6967b996b230 100644 --- a/browser/browsing_data/brave_browsing_data_remover_delegate.cc +++ b/browser/browsing_data/brave_browsing_data_remover_delegate.cc @@ -75,19 +75,18 @@ void BraveBrowsingDataRemoverDelegate::ClearShieldsSettings( auto* map = HostContentSettingsMapFactory::GetForProfile(profile_); auto* provider = static_cast(map->GetPrefProvider()); - for (const auto& resource_id : content_settings::GetShieldsResourceIDs()) { + for (const auto& content_type : + content_settings::GetShieldsContentSettingsTypes()) { ContentSettingsForOneType settings; - ContentSettingsType content_type = ContentSettingsType::PLUGINS; - map->GetSettingsForOneType(content_type, resource_id, &settings); + map->GetSettingsForOneType(content_type, &settings); for (const ContentSettingPatternSource& setting : settings) { base::Time last_modified = provider->GetWebsiteSettingLastModified( - setting.primary_pattern, setting.secondary_pattern, content_type, - resource_id); + setting.primary_pattern, setting.secondary_pattern, content_type); if (last_modified >= begin_time && (last_modified < end_time || end_time.is_null())) { provider->SetWebsiteSetting(setting.primary_pattern, setting.secondary_pattern, content_type, - resource_id, nullptr, {}); + nullptr, {}); } } } diff --git a/browser/browsing_data/brave_browsing_data_remover_delegate_unittest.cc b/browser/browsing_data/brave_browsing_data_remover_delegate_unittest.cc index e79630379424..32f782c06dc2 100644 --- a/browser/browsing_data/brave_browsing_data_remover_delegate_unittest.cc +++ b/browser/browsing_data/brave_browsing_data_remover_delegate_unittest.cc @@ -16,6 +16,7 @@ #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/content_settings/core/common/content_settings_types.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -38,10 +39,10 @@ class BraveBrowsingDataRemoverDelegateTest : public testing::Test { int GetShieldsSettingsCount() { int shields_settings_count = 0; - for (const auto& resource_id : content_settings::GetShieldsResourceIDs()) { + for (const auto& content_type : + content_settings::GetShieldsContentSettingsTypes()) { ContentSettingsForOneType settings; - ContentSettingsType content_type = ContentSettingsType::PLUGINS; - map()->GetSettingsForOneType(content_type, resource_id, &settings); + map()->GetSettingsForOneType(content_type, &settings); shields_settings_count += settings.size(); } return shields_settings_count; @@ -65,18 +66,17 @@ TEST_F(BraveBrowsingDataRemoverDelegateTest, ShieldsSettingsClearTest) { // JAVASCRIPT type instead of PLUGINS type. // Last one is PLUGINS type but it's flash resource not shields resource. map()->SetContentSettingDefaultScope( - kBraveURL, GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_ALLOW); + kBraveURL, GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, + CONTENT_SETTING_ALLOW); map()->SetContentSettingDefaultScope( - kBatURL, GURL(), ContentSettingsType::PLUGINS, - brave_shields::kFingerprintingV2, CONTENT_SETTING_ALLOW); + kBatURL, GURL(), ContentSettingsType::BRAVE_FINGERPRINTING_V2, + CONTENT_SETTING_ALLOW); map()->SetContentSettingCustomScope( brave_shields::GetPatternFromURL(kGoogleURL), - ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_BLOCK); + ContentSettingsPattern::Wildcard(), ContentSettingsType::JAVASCRIPT, + CONTENT_SETTING_BLOCK); map()->SetContentSettingDefaultScope( - kAbcURL, GURL(), ContentSettingsType::PLUGINS, - "", CONTENT_SETTING_ALLOW); + kAbcURL, GURL(), ContentSettingsType::PLUGINS, CONTENT_SETTING_ALLOW); const base::Time kNow = base::Time::Now(); const base::Time k1DaysOld = kNow - base::TimeDelta::FromDays(1); diff --git a/browser/browsing_data/counters/brave_site_settings_counter.cc b/browser/browsing_data/counters/brave_site_settings_counter.cc deleted file mode 100644 index d974f10c7f46..000000000000 --- a/browser/browsing_data/counters/brave_site_settings_counter.cc +++ /dev/null @@ -1,79 +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 "brave/browser/browsing_data/counters/brave_site_settings_counter.h" - -#include -#include - -#include "brave/components/content_settings/core/browser/brave_content_settings_pref_provider.h" -#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" -#include "components/browsing_data/core/pref_names.h" -#include "components/content_settings/core/browser/content_settings_registry.h" -#include "components/content_settings/core/common/content_settings_pattern.h" - -BraveSiteSettingsCounter::BraveSiteSettingsCounter( - HostContentSettingsMap* map, - content::HostZoomMap* zoom_map, - ProtocolHandlerRegistry* handler_registry, - PrefService* pref_service) - : SiteSettingsCounter(map, zoom_map, handler_registry, pref_service), - map_(map) {} - -BraveSiteSettingsCounter::~BraveSiteSettingsCounter() = default; - -int BraveSiteSettingsCounter::CountShieldsSettings() { - std::set hosts; - int empty_host_pattern = 0; - base::Time period_start = GetPeriodStart(); - base::Time period_end = GetPeriodEnd(); - - auto iterate_content_settings_list = - [&](ContentSettingsType content_type, - const ContentSettingsForOneType& content_settings_list, - const std::string& resource_identifier) { - for (const auto& content_setting : content_settings_list) { - // We don't care other source except preference because all shields - // settings are stored in pref storage. - if (content_setting.source != "preference") - continue; - - base::Time last_modified; - DCHECK_EQ(ContentSettingsType::PLUGINS, content_type); - // Fetching last time for specific resource ids. - last_modified = - map_->GetPrefProvider()->GetWebsiteSettingLastModified( - content_setting.primary_pattern, - content_setting.secondary_pattern, - ContentSettingsType::PLUGINS, - resource_identifier); - if (last_modified >= period_start && last_modified < period_end) { - if (content_setting.primary_pattern.GetHost().empty()) - empty_host_pattern++; - else - hosts.insert(content_setting.primary_pattern.GetHost()); - } - } - }; - - auto* registry = content_settings::ContentSettingsRegistry::GetInstance(); - for (const content_settings::ContentSettingsInfo* info : *registry) { - ContentSettingsType type = info->website_settings_info()->type(); - ContentSettingsForOneType content_settings_list; - if (type == ContentSettingsType::PLUGINS) { - for (const auto& id : content_settings::GetShieldsResourceIDs()) { - map_->GetSettingsForOneType(type, id, &content_settings_list); - iterate_content_settings_list(type, content_settings_list, id); - } - continue; - } - } - - return hosts.size() + empty_host_pattern; -} - -void BraveSiteSettingsCounter::ReportResult(ResultInt value) { - SiteSettingsCounter::ReportResult(value + CountShieldsSettings()); -} diff --git a/browser/browsing_data/counters/brave_site_settings_counter.h b/browser/browsing_data/counters/brave_site_settings_counter.h deleted file mode 100644 index 77c45357d292..000000000000 --- a/browser/browsing_data/counters/brave_site_settings_counter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2020 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BRAVE_BROWSER_BROWSING_DATA_COUNTERS_BRAVE_SITE_SETTINGS_COUNTER_H_ -#define BRAVE_BROWSER_BROWSING_DATA_COUNTERS_BRAVE_SITE_SETTINGS_COUNTER_H_ - -#include "chrome/browser/browsing_data/counters/site_settings_counter.h" - -// This class adds shieldss settings count -class BraveSiteSettingsCounter : public SiteSettingsCounter { - public: - BraveSiteSettingsCounter(HostContentSettingsMap* map, - content::HostZoomMap* zoom_map, - ProtocolHandlerRegistry* handler_registry, - PrefService* pref_service); - ~BraveSiteSettingsCounter() override; - BraveSiteSettingsCounter(const BraveSiteSettingsCounter&) = delete; - BraveSiteSettingsCounter& operator=(const BraveSiteSettingsCounter&) = delete; - - private: - // SiteSettingsCounter overrides: - void ReportResult(ResultInt value) override; - - int CountShieldsSettings(); - - scoped_refptr map_; -}; - -#endif // BRAVE_BROWSER_BROWSING_DATA_COUNTERS_BRAVE_SITE_SETTINGS_COUNTER_H_ diff --git a/browser/browsing_data/counters/brave_site_settings_counter_unittest.cc b/browser/browsing_data/counters/brave_site_settings_counter_unittest.cc deleted file mode 100644 index a2f07698226f..000000000000 --- a/browser/browsing_data/counters/brave_site_settings_counter_unittest.cc +++ /dev/null @@ -1,107 +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 "brave/browser/browsing_data/counters/brave_site_settings_counter.h" - -#include -#include -#include - -#include "base/bind.h" -#include "base/test/simple_test_clock.h" -#include "brave/components/brave_shields/browser/brave_shields_util.h" -#include "brave/components/brave_shields/common/brave_shield_constants.h" -#include "chrome/browser/content_settings/host_content_settings_map_factory.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" -#include "chrome/browser/custom_handlers/test_protocol_handler_registry_delegate.h" -#include "chrome/test/base/testing_profile.h" -#include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/prefs/pref_service.h" -#include "content/public/test/browser_task_environment.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "url/gurl.h" - -#if !defined(OS_ANDROID) -#include "content/public/browser/host_zoom_map.h" -#endif - -class BraveSiteSettingsCounterTest : public testing::Test { - public: - void SetUp() override { - profile_ = std::make_unique(); - map_ = HostContentSettingsMapFactory::GetForProfile(profile()); -#if !defined(OS_ANDROID) - auto* zoom_map = - content::HostZoomMap::GetDefaultForBrowserContext(profile()); -#else - content::HostZoomMap* zoom_map = nullptr; -#endif - handler_registry_ = std::make_unique( - profile(), std::make_unique()); - counter_ = std::make_unique( - map(), zoom_map, handler_registry_.get(), profile_->GetPrefs()); - counter_->Init(profile()->GetPrefs(), - browsing_data::ClearBrowsingDataTab::ADVANCED, - base::BindRepeating(&BraveSiteSettingsCounterTest::Callback, - base::Unretained(this))); - } - - Profile* profile() { return profile_.get(); } - - HostContentSettingsMap* map() { return map_.get(); } - - BraveSiteSettingsCounter* counter() { return counter_.get(); } - - browsing_data::BrowsingDataCounter::ResultInt GetResult() { - DCHECK(finished_); - return result_; - } - - void Callback( - std::unique_ptr result) { - DCHECK(result->Finished()); - finished_ = result->Finished(); - - result_ = static_cast( - result.get()) - ->Value(); - } - - private: - content::BrowserTaskEnvironment task_environment_; - std::unique_ptr profile_; - - scoped_refptr map_; - std::unique_ptr handler_registry_; - std::unique_ptr counter_; - bool finished_; - browsing_data::BrowsingDataCounter::ResultInt result_; -}; - -// Tests that the counter correctly counts each setting. -TEST_F(BraveSiteSettingsCounterTest, Count) { - const GURL kBraveURL("https://www.brave.com"); - const GURL kBatURL("https://basicattentiontoken.org"); - const GURL kGoogleURL("https://www.google.com"); - const GURL kAbcURL("https://www.abc.com"); - // Check below four settings for different host are counted properly. - map()->SetContentSettingDefaultScope( - kBraveURL, GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_ALLOW); - map()->SetContentSettingDefaultScope( - kBatURL, GURL(), ContentSettingsType::PLUGINS, - brave_shields::kFingerprintingV2, CONTENT_SETTING_ALLOW); - map()->SetContentSettingCustomScope( - brave_shields::GetPatternFromURL(kGoogleURL), - ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_BLOCK); - map()->SetContentSettingDefaultScope( - kAbcURL, GURL(), ContentSettingsType::PLUGINS, - "", CONTENT_SETTING_ALLOW); - - counter()->Restart(); - EXPECT_EQ(4, GetResult()); -} diff --git a/browser/component_updater/brave_component_installer.cc b/browser/component_updater/brave_component_installer.cc index db041f163d6b..8d39ad1e2aec 100644 --- a/browser/component_updater/brave_component_installer.cc +++ b/browser/component_updater/brave_component_installer.cc @@ -9,7 +9,7 @@ #include "base/base64.h" #include "base/bind.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/json/json_string_value_serializer.h" diff --git a/browser/content_settings/BUILD.gn b/browser/content_settings/BUILD.gn index dfdaa34a3652..135b786a725c 100644 --- a/browser/content_settings/BUILD.gn +++ b/browser/content_settings/BUILD.gn @@ -9,13 +9,19 @@ source_set("content_settings") { sources = [ "brave_content_settings_manager_delegate.cc", "brave_content_settings_manager_delegate.h", + "brave_global_value_map.cc", + "brave_global_value_map.h", ] deps = [ "//base", "//brave/components/brave_shields/browser", + "//brave/components/content_settings/core/browser", + # "//chrome/browser" # dep cycle "//components/content_settings/common:mojom", + "//components/content_settings/core/browser", + "//components/content_settings/core/common", "//content/public/browser", ] } diff --git a/browser/content_settings/brave_global_value_map.cc b/browser/content_settings/brave_global_value_map.cc new file mode 100644 index 000000000000..7b9cd9ac4f1f --- /dev/null +++ b/browser/content_settings/brave_global_value_map.cc @@ -0,0 +1,37 @@ +/* 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 "brave/browser/content_settings/brave_global_value_map.h" + +#include + +#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" +#include "components/content_settings/core/browser/content_settings_rule.h" +#include "components/content_settings/core/common/content_settings.h" + +namespace content_settings { + +BraveGlobalValueMap::BraveGlobalValueMap() {} + +BraveGlobalValueMap::~BraveGlobalValueMap() {} + +std::unique_ptr BraveGlobalValueMap::GetRuleIterator( + ContentSettingsType content_type) const { + if (content_settings::IsShieldsContentSettingsType(content_type)) + return nullptr; + return GlobalValueMap::GetRuleIterator(content_type); +} + +void BraveGlobalValueMap::SetContentSetting(ContentSettingsType content_type, + ContentSetting setting) { + return GlobalValueMap::SetContentSetting(content_type, setting); +} + +ContentSetting BraveGlobalValueMap::GetContentSetting( + ContentSettingsType content_type) const { + return GlobalValueMap::GetContentSetting(content_type); +} + +} // namespace content_settings diff --git a/browser/content_settings/brave_global_value_map.h b/browser/content_settings/brave_global_value_map.h new file mode 100644 index 000000000000..17db74078dd7 --- /dev/null +++ b/browser/content_settings/brave_global_value_map.h @@ -0,0 +1,37 @@ +/* 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_BROWSER_CONTENT_SETTINGS_BRAVE_GLOBAL_VALUE_MAP_H_ +#define BRAVE_BROWSER_CONTENT_SETTINGS_BRAVE_GLOBAL_VALUE_MAP_H_ + +#include + +#include "components/content_settings/core/browser/content_settings_global_value_map.h" +#include "components/content_settings/core/browser/content_settings_provider.h" +#include "components/content_settings/core/common/content_settings_types.h" + +namespace content_settings { + +class RuleIterator; + +class BraveGlobalValueMap : public GlobalValueMap { + public: + BraveGlobalValueMap(); + ~BraveGlobalValueMap(); + + // Returns nullptr to indicate the RuleIterator is empty. + std::unique_ptr GetRuleIterator( + ContentSettingsType content_type) const; + void SetContentSetting(ContentSettingsType content_type, + ContentSetting setting); + ContentSetting GetContentSetting(ContentSettingsType content_type) const; + + private: + DISALLOW_COPY_AND_ASSIGN(BraveGlobalValueMap); +}; + +} // namespace content_settings + +#endif // BRAVE_BROWSER_CONTENT_SETTINGS_BRAVE_GLOBAL_VALUE_MAP_H_ diff --git a/browser/extensions/api/brave_shields_api_browsertest.cc b/browser/extensions/api/brave_shields_api_browsertest.cc index 5d4c82d9bc71..98074eee7aea 100644 --- a/browser/extensions/api/brave_shields_api_browsertest.cc +++ b/browser/extensions/api/brave_shields_api_browsertest.cc @@ -63,7 +63,7 @@ class BraveShieldsAPIBrowserTest : public InProcessBrowserTest { void BlockScripts() { content_settings_->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_BLOCK); + ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_BLOCK); } bool NavigateToURLUntilLoadStop(const std::string& origin, @@ -231,7 +231,7 @@ IN_PROC_BROWSER_TEST_F(BraveShieldsAPIBrowserTest, ContentSetting setting = HostContentSettingsMapFactory::GetForProfile(browser()->profile()) ->GetContentSetting(GetBraveURL(), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + ContentSettingsType::JAVASCRIPT); EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); } @@ -240,46 +240,25 @@ IN_PROC_BROWSER_TEST_F(BraveShieldsAPIBrowserTest, PRE_ShieldSettingsPersistTest) { HostContentSettingsMapFactory::GetForProfile(browser()->profile()) ->SetContentSettingDefaultScope( - GetBraveURL(), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_ALLOW); + GetBraveURL(), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, + CONTENT_SETTING_ALLOW); ContentSetting setting = HostContentSettingsMapFactory::GetForProfile(browser()->profile()) - ->GetContentSetting(GetBraveURL(), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + ->GetContentSetting( + GetBraveURL(), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); } IN_PROC_BROWSER_TEST_F(BraveShieldsAPIBrowserTest, ShieldSettingsPersistTest) { ContentSetting setting = HostContentSettingsMapFactory::GetForProfile(browser()->profile()) - ->GetContentSetting(GetBraveURL(), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); - EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); -} - -// Checks flash configuration isn't persisted across the sessions. -IN_PROC_BROWSER_TEST_F(BraveShieldsAPIBrowserTest, PRE_FlashPersistTest) { - HostContentSettingsMapFactory::GetForProfile(browser()->profile()) - ->SetContentSettingDefaultScope(GetBraveURL(), GURL(), - ContentSettingsType::PLUGINS, - std::string(), CONTENT_SETTING_ALLOW); - - ContentSetting setting = - HostContentSettingsMapFactory::GetForProfile(browser()->profile()) - ->GetContentSetting(GetBraveURL(), GURL(), - ContentSettingsType::PLUGINS, std::string()); + ->GetContentSetting( + GetBraveURL(), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(setting, CONTENT_SETTING_ALLOW); } -IN_PROC_BROWSER_TEST_F(BraveShieldsAPIBrowserTest, FlashPersistTest) { - ContentSetting setting = - HostContentSettingsMapFactory::GetForProfile(browser()->profile()) - ->GetContentSetting(GetBraveURL(), GURL(), - ContentSettingsType::PLUGINS, std::string()); - EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); -} - } // namespace extensions diff --git a/browser/greaselion/greaselion_tab_helper.cc b/browser/greaselion/greaselion_tab_helper.cc index 023659c7e548..e99cf94513d8 100644 --- a/browser/greaselion/greaselion_tab_helper.cc +++ b/browser/greaselion/greaselion_tab_helper.cc @@ -8,7 +8,7 @@ #include #include -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/strings/utf_string_conversions.h" #include "brave/browser/brave_browser_process_impl.h" #include "brave/browser/greaselion/greaselion_service_factory.h" diff --git a/browser/ipfs/content_browser_client_helper_unittest.cc b/browser/ipfs/content_browser_client_helper_unittest.cc index 164432d257b0..3c65f475cdc1 100644 --- a/browser/ipfs/content_browser_client_helper_unittest.cc +++ b/browser/ipfs/content_browser_client_helper_unittest.cc @@ -8,7 +8,7 @@ #include #include -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/scoped_feature_list.h" #include "brave/components/ipfs/features.h" #include "brave/components/ipfs/ipfs_constants.h" diff --git a/browser/net/brave_proxying_web_socket.cc b/browser/net/brave_proxying_web_socket.cc index e2bede4a2ee1..16d4347b01d8 100644 --- a/browser/net/brave_proxying_web_socket.cc +++ b/browser/net/brave_proxying_web_socket.cc @@ -179,6 +179,10 @@ void BraveProxyingWebSocket::ContinueToHeadersReceived() { OnHeadersReceivedComplete(net::OK); } +void BraveProxyingWebSocket::OnFailure(const std::string& message, + int32_t net_error, + int32_t response_code) {} + void BraveProxyingWebSocket::OnConnectionEstablished( mojo::PendingRemote websocket, mojo::PendingReceiver client_receiver, diff --git a/browser/net/brave_proxying_web_socket.h b/browser/net/brave_proxying_web_socket.h index 564f05dd01e6..00047e2d22cd 100644 --- a/browser/net/brave_proxying_web_socket.h +++ b/browser/net/brave_proxying_web_socket.h @@ -76,6 +76,9 @@ class BraveProxyingWebSocket : public network::mojom::WebSocketHandshakeClient, // network::mojom::WebSocketHandshakeClient methods: void OnOpeningHandshakeStarted( network::mojom::WebSocketHandshakeRequestPtr request) override; + void OnFailure(const std::string& message, + int32_t net_error, + int32_t response_code) override; void OnConnectionEstablished( mojo::PendingRemote websocket, mojo::PendingReceiver client_receiver, diff --git a/browser/profiles/BUILD.gn b/browser/profiles/BUILD.gn index e26321bd01ff..bcc1e49f3c22 100644 --- a/browser/profiles/BUILD.gn +++ b/browser/profiles/BUILD.gn @@ -32,6 +32,7 @@ source_set("profiles") { "//brave/components/brave_ads/browser", "//brave/components/brave_rewards/browser", "//brave/components/brave_sync:prefs", + "//brave/components/content_settings/core/browser", "//brave/components/ntp_background_images/common", "//brave/components/tor", "//brave/content:browser", @@ -43,8 +44,6 @@ source_set("profiles") { ] if (enable_tor) { - deps += [ - "//brave/browser/tor", - ] + deps += [ "//brave/browser/tor" ] } } diff --git a/browser/profiles/brave_profile_manager.cc b/browser/profiles/brave_profile_manager.cc index 9f85cd181439..9bf85015d7c5 100644 --- a/browser/profiles/brave_profile_manager.cc +++ b/browser/profiles/brave_profile_manager.cc @@ -19,6 +19,7 @@ #include "brave/components/brave_shields/browser/ad_block_service.h" #include "brave/components/brave_shields/browser/brave_shields_util.h" #include "brave/components/brave_wallet/buildflags/buildflags.h" +#include "brave/components/content_settings/core/browser/brave_content_settings_pref_provider.h" #include "brave/components/ipfs/buildflags/buildflags.h" #include "brave/components/tor/tor_constants.h" #include "brave/content/browser/webui/brave_shared_resources_data_source.h" @@ -73,6 +74,12 @@ BraveProfileManager::~BraveProfileManager() { } void BraveProfileManager::InitProfileUserPrefs(Profile* profile) { + // migrate obsolete plugin prefs to temporary migration pref because otherwise + // they get deleteed by PrefProvider before we can migrate them in + // BravePrefProvider + content_settings::BravePrefProvider::CopyPluginSettingsForMigration( + profile->GetPrefs()); + ProfileManager::InitProfileUserPrefs(profile); brave::RecordInitialP3AValues(profile); brave::SetDefaultSearchVersion(profile, profile->IsNewProfile()); diff --git a/browser/resources/settings/brandcode_config_fetcher_unittest.cc b/browser/resources/settings/brandcode_config_fetcher_unittest.cc index e05fc2b96fc1..2d6cda7bd80e 100644 --- a/browser/resources/settings/brandcode_config_fetcher_unittest.cc +++ b/browser/resources/settings/brandcode_config_fetcher_unittest.cc @@ -6,7 +6,7 @@ #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h" #include "base/run_loop.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/task_environment.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" diff --git a/browser/resources/settings/brave_overrides/basic_page.js b/browser/resources/settings/brave_overrides/basic_page.js index 3671ad287ac8..3d6e69d939ac 100644 --- a/browser/resources/settings/brave_overrides/basic_page.js +++ b/browser/resources/settings/brave_overrides/basic_page.js @@ -237,9 +237,9 @@ RegisterPolymerTemplateModifications({ // Move privacy to before autofill const sectionPrivacy = getSectionElement(actualTemplate.content, 'privacy') sectionAutofill.insertAdjacentElement('beforebegin', sectionPrivacy) - // Move help tips after printing - const sectionPrinting = getSectionElement(advancedSubSectionsTemplate.content, 'printing') - sectionPrinting.insertAdjacentElement('afterend', sectionHelpTips) + // Move help tips after downloads + const sectionDownloads = getSectionElement(advancedSubSectionsTemplate.content, 'downloads') + sectionDownloads.insertAdjacentElement('afterend', sectionHelpTips) } } }) diff --git a/browser/resources/settings/brave_overrides/settings_menu.js b/browser/resources/settings/brave_overrides/settings_menu.js index 6ebad54b4189..34260f1665e9 100644 --- a/browser/resources/settings/brave_overrides/settings_menu.js +++ b/browser/resources/settings/brave_overrides/settings_menu.js @@ -224,8 +224,8 @@ RegisterPolymerTemplateModifications({ const privacyEl = getMenuElement(templateContent, '/privacy') autofillEl.insertAdjacentElement('beforebegin', privacyEl) // Move helptips to advanced - const printingEl = getMenuElement(templateContent, '/printing') - printingEl.insertAdjacentElement('afterend', helpTipsEl) + const downloadsEl = getMenuElement(templateContent, '/downloads') + downloadsEl.insertAdjacentElement('afterend', helpTipsEl) // Allow Accessibility to be removed :-( const a11yEl = getMenuElement(templateContent, '/accessibility') a11yEl.setAttribute('hidden', '[[!pageVisibility.a11y]') diff --git a/browser/resources/settings/reset_report_uploader_unittest.cc b/browser/resources/settings/reset_report_uploader_unittest.cc index 83ca109450b4..1b28b9f2cf92 100644 --- a/browser/resources/settings/reset_report_uploader_unittest.cc +++ b/browser/resources/settings/reset_report_uploader_unittest.cc @@ -5,7 +5,7 @@ #include "chrome/browser/profile_resetter/reset_report_uploader.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/task_environment.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" diff --git a/browser/tor/tor_navigation_throttle_unittest.cc b/browser/tor/tor_navigation_throttle_unittest.cc index efb13af22e0f..8894cdc0dc0d 100644 --- a/browser/tor/tor_navigation_throttle_unittest.cc +++ b/browser/tor/tor_navigation_throttle_unittest.cc @@ -5,7 +5,7 @@ #include -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "brave/browser/tor/tor_profile_manager.h" #include "brave/browser/tor/tor_profile_service_factory.h" #include "brave/components/tor/mock_tor_launcher_factory.h" diff --git a/browser/tor/tor_profile_manager_browsertest.cc b/browser/tor/tor_profile_manager_browsertest.cc index 65558f0bd5dd..cde694619f0c 100644 --- a/browser/tor/tor_profile_manager_browsertest.cc +++ b/browser/tor/tor_profile_manager_browsertest.cc @@ -81,13 +81,13 @@ class TorProfileManagerTest : public InProcessBrowserTest { ContentSetting setting) { content_settings->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", setting); + ContentSettingsType::JAVASCRIPT, setting); } ContentSetting GetScriptSetting(HostContentSettingsMap* content_settings, const GURL& primary_url) { - return content_settings->GetContentSetting( - primary_url, GURL(), ContentSettingsType::JAVASCRIPT, ""); + return content_settings->GetContentSetting(primary_url, GURL(), + ContentSettingsType::JAVASCRIPT); } MockTorLauncherFactory* GetTorLauncherFactory() { diff --git a/browser/tor/tor_profile_manager_unittest.cc b/browser/tor/tor_profile_manager_unittest.cc index b9694b497f23..ad2943970f90 100644 --- a/browser/tor/tor_profile_manager_unittest.cc +++ b/browser/tor/tor_profile_manager_unittest.cc @@ -5,7 +5,7 @@ #include -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "brave/browser/tor/tor_profile_manager.h" #include "brave/browser/translate/buildflags/buildflags.h" #include "brave/common/pref_names.h" diff --git a/browser/ui/android/strings/android_chrome_strings.grd b/browser/ui/android/strings/android_chrome_strings.grd index 34d1cd95b375..9cf26c6a194f 100644 --- a/browser/ui/android/strings/android_chrome_strings.grd +++ b/browser/ui/android/strings/android_chrome_strings.grd @@ -320,10 +320,10 @@ CHAR-LIMIT guidelines: Brave services - + Allow Brave sign-in - + Show Brave sign-in prompts when you sign in to your Brave sync chain @@ -1647,9 +1647,6 @@ Your Brave account may have other forms of browsing history like searches and ac Settings - - Sign out and turn off sync - Credit cards and addresses using Brave Pay @@ -2130,6 +2127,9 @@ To change this setting, <resetlink>reset sync

Preview page <new>New</new> + + Read later <new>New</new> + Fast page @@ -2230,6 +2230,9 @@ To change this setting, <resetlink>reset sync

<link>Load original page</link> from %1$sgoogle.com + + You are viewing a preview of this page + @@ -2944,6 +2947,9 @@ Data from your Private session will only be cleared from Brave when you Group tabs + + Track prices + Get image descriptions @@ -2954,13 +2960,10 @@ Data from your Private session will only be cleared from Brave when you - Add to: + Add to - - Add to Bookmarks - - - Add to Downloads + + Home screen @@ -3032,6 +3035,21 @@ Data from your Private session will only be cleared from Brave when you Can’t find that bookmark. Check your spelling or add a new bookmark. + + Add to + + + List of bookmark folders + + + List of bookmark folders opened at half height + + + List of bookmark folders opened at full height + + + List of bookmark folders is closed + Edit bookmark @@ -3070,6 +3088,9 @@ Data from your Private session will only be cleared from Brave when you Ready for offline + + Added to reading list + Mark as read @@ -3080,17 +3101,36 @@ Data from your Private session will only be cleared from Brave when you - You have %1$d5 pages + {READING_LIST_REMINDER_NOTIFICATION_SUBTITLE, plural, + =1 {You have %1$d1 page} + other {You have %1$d8 pages}} - %1$d5 unread pages + {READING_LIST_UNREAD_PAGE_COUNT, plural, + =1 {%1$d1 unread page} + other {%1$d8 unread pages}} + + + No unread pages Save this page for later and get a reminder + + Save pages for later and get a reminder + Find your reading list in Bookmarks + + You’ll find your reading list here + + + You can save pages to your reading list to find them again + + + You can save pages to your reading list to find them again or read offline + @@ -3195,9 +3235,6 @@ Data from your Private session will only be cleared from Brave when you Brave can’t update. More options - - Site information - Start voice search @@ -3942,15 +3979,31 @@ Data from your Private session will only be cleared from Brave when you + Brave Assistant in Brave - - Assistant Triggered Checkout + + Helps you complete tasks, such as checkout, throughout the web - + + Web Assistance + + + Get help with tasks on the web + + To help you complete tasks, Brave will receive the URLs and contents of sites on which you use Assistant, as well as information you submit through Assistant + + Proactive Help + + + Assistant will appear when it detects that it can help you on supported websites + + + To use this setting <link>Make searches and browsing better</link> must be turned on + Show your Brave activity in Digital Wellbeing? @@ -4264,6 +4317,40 @@ Data from your Private session will only be cleared from Brave when you Wi-Fi is used when available + + + + Get a better voice experience on the web + + + Brave Assistant can complete actions across websites for you + + + To help you complete tasks, Brave will receive the URLs and contents of sites on which you use Assistant, as well as information you submit through Assistant. This information may be stored in your Brave account. You can turn off Assistant in Brave settings. + + + Assistant voice search consent ui + + + Assistant voice search consent ui opened at half height + + + Assistant voice search consent ui opened at full height + + + Assistant voice search consent ui closed + + + + + Voice assistance + + + Enhanced voice search + + + Brave Assistant provides a better voice experience for searching the web and engaging with sites you have open. Brave Assistant will receive the URL and contents of sites you use with it. + diff --git a/browser/ui/browser_commands.cc b/browser/ui/browser_commands.cc index 6a98a9706c46..ed4b77f1ab9b 100644 --- a/browser/ui/browser_commands.cc +++ b/browser/ui/browser_commands.cc @@ -5,6 +5,7 @@ #include "brave/browser/ui/browser_commands.h" +#include "base/files/file_path.h" #include "brave/components/speedreader/buildflags.h" #include "brave/components/tor/buildflags/buildflags.h" #include "chrome/browser/browser_process.h" @@ -15,6 +16,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/user_manager.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" @@ -63,9 +65,8 @@ void NewTorConnectionForSite(Browser* browser) { } void AddNewProfile() { - profiles::CreateAndSwitchToNewProfile( - ProfileManager::CreateCallback(), - ProfileMetrics::ADD_NEW_USER_MENU); + UserManager::Show(/*profile_path_to_focus=*/base::FilePath(), + profiles::USER_MANAGER_OPEN_CREATE_USER_PAGE); } void OpenGuestProfile() { diff --git a/browser/ui/content_settings/brave_autoplay_content_setting_bubble_model.cc b/browser/ui/content_settings/brave_autoplay_content_setting_bubble_model.cc index 1a801f602a23..54638a301e26 100644 --- a/browser/ui/content_settings/brave_autoplay_content_setting_bubble_model.cc +++ b/browser/ui/content_settings/brave_autoplay_content_setting_bubble_model.cc @@ -88,7 +88,7 @@ void BraveAutoplayContentSettingBubbleModel::SetRadioGroup() { HostContentSettingsMap* map = HostContentSettingsMapFactory::GetForProfile(GetProfile()); std::unique_ptr value = - map->GetWebsiteSetting(url, url, content_type(), std::string(), &info); + map->GetWebsiteSetting(url, url, content_type(), &info); setting = content_settings::ValueToContentSetting(value.get()); setting_source = info.source; 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 ef8aec9e3ff7..8f90b31e4dd5 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 @@ -52,9 +52,13 @@ class BraveRewardsActionStubViewHighlightPathGenerator } // namespace -BraveRewardsActionStubView::BraveRewardsActionStubView(Profile* profile, +BraveRewardsActionStubView::BraveRewardsActionStubView( + Profile* profile, BraveRewardsActionStubView::Delegate* delegate) - : LabelButton(this, base::string16()), + : LabelButton( + base::BindRepeating(&BraveRewardsActionStubView::ButtonPressed, + base::Unretained(this)), + base::string16()), profile_(profile), delegate_(delegate) { SetInkDropMode(InkDropMode::ON); @@ -115,8 +119,7 @@ SkPath BraveRewardsActionStubView::GetHighlightPath() const { return path; } -void BraveRewardsActionStubView::ButtonPressed( - Button* sender, const ui::Event& event) { +void BraveRewardsActionStubView::ButtonPressed() { // We only show the default badge text once, so once the button // is clicked then change it back. We consider pressing the button // as an action to 'dismiss' the badge notification. 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 5943ffc1e268..ee4b55121f1b 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 @@ -17,8 +17,7 @@ class Profile; // A button to take the place of an extension that will be loaded in the future. // Call SetImage with the BraveActionIconWithBadgeImageSource // Call highlight etc from ToolbarActionView -class BraveRewardsActionStubView : public views::LabelButton, - public views::ButtonListener { +class BraveRewardsActionStubView : public views::LabelButton { public: class Delegate { public: @@ -31,9 +30,6 @@ class BraveRewardsActionStubView : public views::LabelButton, explicit BraveRewardsActionStubView(Profile* profile, Delegate* delegate); ~BraveRewardsActionStubView() override; - // views::ButtonListener - void ButtonPressed(Button* sender, const ui::Event& event) override; - // views::LabelButton: std::unique_ptr CreateDefaultBorder() const override; @@ -45,6 +41,7 @@ class BraveRewardsActionStubView : public views::LabelButton, private: gfx::Size CalculatePreferredSize() const override; + void ButtonPressed(); StringPrefMember badge_text_pref_; Profile* profile_; diff --git a/browser/ui/views/location_bar/onion_location_view.cc b/browser/ui/views/location_bar/onion_location_view.cc index fa4530c33f51..46cdce131496 100644 --- a/browser/ui/views/location_bar/onion_location_view.cc +++ b/browser/ui/views/location_bar/onion_location_view.cc @@ -75,11 +75,11 @@ class HighlightPathGenerator : public views::HighlightPathGenerator { DISALLOW_COPY_AND_ASSIGN(HighlightPathGenerator); }; -class OnionLocationButtonView : public views::LabelButton, - public views::ButtonListener { +class OnionLocationButtonView : public views::LabelButton { public: explicit OnionLocationButtonView(Profile* profile) - : LabelButton(this, + : LabelButton(base::BindRepeating(&OnionLocationButtonView::ButtonPressed, + base::Unretained(this)), l10n_util::GetStringUTF16(IDS_LOCATION_BAR_OPEN_IN_TOR)), profile_(profile) { if (profile->IsTor()) @@ -106,13 +106,6 @@ class OnionLocationButtonView : public views::LabelButton, ~OnionLocationButtonView() override {} - // views::ButtonListener - void ButtonPressed(Button* sender, const ui::Event& event) override { - TorProfileManager::SwitchToTorProfile( - profile_, - base::BindRepeating(&OnTorProfileCreated, GURL(onion_location_))); - } - void SetOnionLocation(GURL location) { onion_location_ = location; } private: @@ -127,6 +120,12 @@ class OnionLocationButtonView : public views::LabelButton, views::CreateRoundedRectBackground(kOpenInTorBg, height() / 2)); } + void ButtonPressed() { + TorProfileManager::SwitchToTorProfile( + profile_, + base::BindRepeating(&OnTorProfileCreated, GURL(onion_location_))); + } + GURL onion_location_; Profile* profile_; diff --git a/browser/ui/views/profiles/brave_profile_menu_view.cc b/browser/ui/views/profiles/brave_profile_menu_view.cc index 9467a82111a8..6751350994a2 100644 --- a/browser/ui/views/profiles/brave_profile_menu_view.cc +++ b/browser/ui/views/profiles/brave_profile_menu_view.cc @@ -16,6 +16,7 @@ #include "chrome/browser/profiles/profile_manager.h" #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/grit/generated_resources.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" diff --git a/browser/ui/views/tabs/brave_new_tab_button.cc b/browser/ui/views/tabs/brave_new_tab_button.cc index cfd6d2f26be5..5787e5e9e08d 100644 --- a/browser/ui/views/tabs/brave_new_tab_button.cc +++ b/browser/ui/views/tabs/brave_new_tab_button.cc @@ -4,6 +4,9 @@ * you can obtain one at http://mozilla.org/MPL/2.0/. */ #include "brave/browser/ui/views/tabs/brave_new_tab_button.h" + +#include + #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/views/tabs/new_tab_button.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" @@ -39,10 +42,11 @@ SkPath BraveNewTabButton::GetBorderPath(const gfx::Point& origin, SkPath path; const gfx::Rect contents_bounds = GetContentsBounds(); - const gfx::Rect path_rect(scaled_origin.x(), - extend_to_top ? 0 : scaled_origin.y(), - contents_bounds.width() * scale, - scaled_origin.y() + contents_bounds.height() * scale); + const gfx::Rect path_rect( + scaled_origin.x(), extend_to_top ? 0 : scaled_origin.y(), + contents_bounds.width() * scale, + (extend_to_top ? scaled_origin.y() : 0) + + std::min(contents_bounds.width(), contents_bounds.height()) * scale); path.addRoundRect(RectToSkRect(path_rect), radius, radius); path.close(); return path; diff --git a/browser/ui/views/translate/brave_translate_bubble_view_unittest.cc b/browser/ui/views/translate/brave_translate_bubble_view_unittest.cc index b383c2a015f0..09a0b698fb7e 100644 --- a/browser/ui/views/translate/brave_translate_bubble_view_unittest.cc +++ b/browser/ui/views/translate/brave_translate_bubble_view_unittest.cc @@ -3,10 +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 "base/test/scoped_feature_list.h" #include "brave/browser/ui/views/translate/brave_translate_bubble_view.h" +#include "base/test/scoped_feature_list.h" #include "chrome/test/views/chrome_views_test_base.h" #include "ui/events/keycodes/dom/dom_code.h" +#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/label_button.h" namespace { @@ -197,7 +198,8 @@ class BraveTranslateBubbleViewTest : public ChromeViewsTestBase { } void PressButton(TranslateBubbleView::ButtonID id) { - views::LabelButton button(nullptr, base::ASCIIToUTF16("dummy")); + views::LabelButton button(views::Button::PressedCallback(), + base::ASCIIToUTF16("dummy")); button.SetID(id); bubble_->ButtonPressed(id); diff --git a/browser/widevine/widevine_permission_request.cc b/browser/widevine/widevine_permission_request.cc index f0bea1c57199..988f05edbcd0 100644 --- a/browser/widevine/widevine_permission_request.cc +++ b/browser/widevine/widevine_permission_request.cc @@ -39,7 +39,7 @@ GURL WidevinePermissionRequest::GetOrigin() const { return web_contents_->GetVisibleURL(); } -void WidevinePermissionRequest::PermissionGranted() { +void WidevinePermissionRequest::PermissionGranted(bool is_one_time) { #if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) EnableWidevineCdmComponent(web_contents_); #endif diff --git a/browser/widevine/widevine_permission_request.h b/browser/widevine/widevine_permission_request.h index 858b43370af5..9e0c4cc9c080 100644 --- a/browser/widevine/widevine_permission_request.h +++ b/browser/widevine/widevine_permission_request.h @@ -29,7 +29,7 @@ class WidevinePermissionRequest : public permissions::PermissionRequest { permissions::PermissionRequest::IconId GetIconId() const override; base::string16 GetMessageTextFragment() const override; GURL GetOrigin() const override; - void PermissionGranted() override; + void PermissionGranted(bool is_one_time) override; void PermissionDenied() override; void Cancelled() override; void RequestFinished() override; diff --git a/build/android/bytecode/java/org/brave/bytecode/BraveToolbarManagerClassAdapter.java b/build/android/bytecode/java/org/brave/bytecode/BraveToolbarManagerClassAdapter.java index 66ea403988dd..b0c88f805ac0 100644 --- a/build/android/bytecode/java/org/brave/bytecode/BraveToolbarManagerClassAdapter.java +++ b/build/android/bytecode/java/org/brave/bytecode/BraveToolbarManagerClassAdapter.java @@ -15,8 +15,11 @@ public class BraveToolbarManagerClassAdapter extends BraveClassVisitor { public BraveToolbarManagerClassAdapter(ClassVisitor visitor) { super(visitor); - deleteField(sBraveToolbarManagerClassName, "mBottomControlsCoordinator"); - makeProtectedField(sToolbarManagerClassName, "mBottomControlsCoordinator"); + deleteField(sBraveToolbarManagerClassName, "mBottomControlsCoordinatorSupplier"); + makeProtectedField(sToolbarManagerClassName, "mBottomControlsCoordinatorSupplier"); + + deleteField(sBraveToolbarManagerClassName, "mCallbackController"); + makeProtectedField(sToolbarManagerClassName, "mCallbackController"); deleteField(sBraveToolbarManagerClassName, "mBrowserControlsSizer"); makeProtectedField(sToolbarManagerClassName, "mBrowserControlsSizer"); diff --git a/build/commands/lib/config.js b/build/commands/lib/config.js index 51c3dd2c2090..010cd39b200e 100755 --- a/build/commands/lib/config.js +++ b/build/commands/lib/config.js @@ -369,6 +369,7 @@ Config.prototype.buildArgs = function () { args.ios_enable_search_widget_extension = false args.ios_enable_share_extension = false args.ios_enable_credential_provider_extension = false + args.ios_enable_widget_kit_extension = false delete args.safebrowsing_api_endpoint delete args.updater_prod_endpoint diff --git a/build/mac/config.gni b/build/mac/config.gni index 292b97902264..9bd31e99503b 100644 --- a/build/mac/config.gni +++ b/build/mac/config.gni @@ -1,4 +1,5 @@ declare_args() { + # find with `security find-identity -v -p codesigning` mac_signing_identifier = "" mac_installer_signing_identifier = "" diff --git a/chromium_src/chrome/browser/browsing_data/counters/browsing_data_counter_factory.cc b/chromium_src/chrome/browser/browsing_data/counters/browsing_data_counter_factory.cc deleted file mode 100644 index d4a23af6a13e..000000000000 --- a/chromium_src/chrome/browser/browsing_data/counters/browsing_data_counter_factory.cc +++ /dev/null @@ -1,10 +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 "brave/browser/browsing_data/counters/brave_site_settings_counter.h" - -#define SiteSettingsCounter BraveSiteSettingsCounter -#include "../../../../../../chrome/browser/browsing_data/counters/browsing_data_counter_factory.cc" -#undef SiteSettingsCounter diff --git a/chromium_src/chrome/browser/content_settings/content_settings_supervised_provider.h b/chromium_src/chrome/browser/content_settings/content_settings_supervised_provider.h new file mode 100644 index 000000000000..fd407f906f2a --- /dev/null +++ b/chromium_src/chrome/browser/content_settings/content_settings_supervised_provider.h @@ -0,0 +1,15 @@ +/* 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_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ + +#include "brave/browser/content_settings/brave_global_value_map.h" + +#define GlobalValueMap BraveGlobalValueMap +#include "../../../../../chrome/browser/content_settings/content_settings_supervised_provider.h" +#undef GlobalValueMap + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_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 3597c655d4cd..7738043b383f 100644 --- a/chromium_src/chrome/browser/profiles/profile_avatar_icon_util.cc +++ b/chromium_src/chrome/browser/profiles/profile_avatar_icon_util.cc @@ -26,15 +26,15 @@ const IconResourceInfo* GetBraveDefaultAvatarIconResourceInfo( size_t GetBraveAvatarIconStartIndex(); -#define BRAVE_GET_DEFAULT_AVATAR_ICON_RESOURCE_INFO \ - size_t brave_start_index = \ - kDefaultAvatarIconsCount - kBraveDefaultAvatarIconsCount; \ - if (index >= brave_start_index) { \ - size_t brave_icon_index = index - brave_start_index; \ - const IconResourceInfo* brave_icon = \ - GetBraveDefaultAvatarIconResourceInfo(brave_icon_index); \ - if (brave_icon) \ - return brave_icon; \ +#define BRAVE_GET_DEFAULT_AVATAR_ICON_RESOURCE_INFO \ + size_t brave_start_index = \ + kDefaultAvatarIconsCount - kBraveDefaultAvatarIconsCount; \ + if (index >= brave_start_index) { \ + size_t brave_icon_index = index - brave_start_index; \ + const IconResourceInfo* brave_icon = \ + GetBraveDefaultAvatarIconResourceInfo(brave_icon_index); \ + if (brave_icon) \ + return brave_icon; \ } #define BRAVE_GET_MODERN_AVATAR_ICON_START_INDEX \ @@ -43,15 +43,15 @@ size_t GetBraveAvatarIconStartIndex(); } // namespace profiles // Override some functions (see implementations for details). -#define GetDefaultProfileAvatarIconsAndLabels \ - GetDefaultProfileAvatarIconsAndLabels_ChromiumImpl +#define GetCustomProfileAvatarIconsAndLabels \ + GetCustomProfileAvatarIconsAndLabels_ChromiumImpl #define IsDefaultAvatarIconUrl IsDefaultAvatarIconUrl_ChromiumImpl #define GetGuestAvatar GetGuestAvatar_ChromiumImpl #include "../../../../../chrome/browser/profiles/profile_avatar_icon_util.cc" #undef BRAVE_GET_DEFAULT_AVATAR_ICON_RESOURCE_INFO #undef BRAVE_GET_MODERN_AVATAR_ICON_START_INDEX -#undef GetDefaultProfileAvatarIconsAndLabels +#undef GetCustomProfileAvatarIconsAndLabels #undef IsDefaultAvatarIconUrl #undef GetGuestAvatar @@ -155,15 +155,15 @@ const IconResourceInfo* GetBraveDefaultAvatarIconResourceInfo( #endif } -std::unique_ptr GetDefaultProfileAvatarIconsAndLabels( +std::unique_ptr GetCustomProfileAvatarIconsAndLabels( size_t selected_avatar_idx) { - auto avatars = GetDefaultProfileAvatarIconsAndLabels_ChromiumImpl( - selected_avatar_idx); + auto avatars = + GetCustomProfileAvatarIconsAndLabels_ChromiumImpl(selected_avatar_idx); #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) // Insert the 'placeholder' item, so it is still selectable // in the Settings and Profile Manager WebUI. std::unique_ptr avatar_info( - new base::DictionaryValue()); + new base::DictionaryValue()); avatar_info->SetString("url", profiles::GetPlaceholderAvatarIconUrl()); avatar_info->SetString( "label", l10n_util::GetStringUTF16(IDS_BRAVE_AVATAR_LABEL_PLACEHOLDER)); 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 add441aaadfc..e04708644ed7 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 @@ -26,7 +26,7 @@ TEST(ProfileUtilTest, BraveAvatarIconChoices) { // are brave's and include the placeholder so that // it can be re-selected, unlike chromium. std::unique_ptr avatars( - profiles::GetDefaultProfileAvatarIconsAndLabels(0)); + profiles::GetCustomProfileAvatarIconsAndLabels(0)); const size_t expected_selectable_avatar_count = profiles::kBraveDefaultAvatarIconsCount + 1; diff --git a/chromium_src/chrome/browser/profiles/profile_window.cc b/chromium_src/chrome/browser/profiles/profile_window.cc deleted file mode 100644 index 26335126bc1e..000000000000 --- a/chromium_src/chrome/browser/profiles/profile_window.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 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 "chrome/browser/profiles/profile_window.h" - -#define CreateAndSwitchToNewProfile CreateAndSwitchToNewProfile_ChromiumImpl -#include "../../../../../chrome/browser/profiles/profile_window.cc" -#undef CreateAndSwitchToNewProfile - -#include "base/bind.h" -#include "base/threading/sequenced_task_runner_handle.h" -#include "chrome/browser/profiles/profile_attributes_storage.h" -#include "chrome/browser/profiles/profile_avatar_icon_util.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/profiles/profile_metrics.h" - -namespace profiles { - -void CreateAndSwitchToNewProfile(ProfileManager::CreateCallback callback, - ProfileMetrics::ProfileAdd metric) { - ProfileAttributesStorage& storage = - g_browser_process->profile_manager()->GetProfileAttributesStorage(); - - int avatar_index = storage.ChooseAvatarIconIndexForNewProfile(); - ProfileManager::CreateMultiProfileAsync( - storage.ChooseNameForNewProfile(avatar_index), - profiles::GetDefaultAvatarIconUrl(avatar_index), - base::Bind(&profiles::OpenBrowserWindowForProfile, callback, true, true, - false)); - ProfileMetrics::LogProfileAddNewUser(metric); -} - -} // namespace profiles diff --git a/chromium_src/chrome/browser/profiles/profile_window_browsertest.cc b/chromium_src/chrome/browser/profiles/profile_window_browsertest.cc deleted file mode 100644 index 561ca578ece4..000000000000 --- a/chromium_src/chrome/browser/profiles/profile_window_browsertest.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 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 - -#include "chrome/browser/browser_process.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_avatar_icon_util.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/profiles/profile_window.h" -#include "chrome/browser/profiles/profile_metrics.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "content/public/test/browser_test.h" -#include "content/public/test/test_utils.h" - -using BraveProfileWindowTest = InProcessBrowserTest; - -namespace { - -// An observer that returns back to test code after a new profile is -// initialized. -void OnUnblockOnProfileCreation(base::RunLoop* run_loop, - Profile* profile, - Profile::CreateStatus status) { - if (status == Profile::CREATE_STATUS_INITIALIZED) - run_loop->Quit(); -} - -} // namespace - -// Test that the browser command for creating new profiles -// performs the random avatar lookup, and it gets applied to the profile. -IN_PROC_BROWSER_TEST_F(BraveProfileWindowTest, - NewProfileGetsRandomNonPlaceholderAvatar) { - // Create 2 additional profiles. - base::RunLoop run_loop; - profiles::CreateAndSwitchToNewProfile( - base::Bind(&OnUnblockOnProfileCreation, &run_loop), - ProfileMetrics::ADD_NEW_USER_MENU); - run_loop.Run(); - base::RunLoop run_loop2; - profiles::CreateAndSwitchToNewProfile( - base::Bind(&OnUnblockOnProfileCreation, &run_loop2), - ProfileMetrics::ADD_NEW_USER_MENU); - run_loop2.Run(); - // Check new profiles have non-placeholder avatar and are all unique - ProfileManager* profile_manager = g_browser_process->profile_manager(); - std::vector all_profiles = ProfileManager::GetLastOpenedProfiles(); - size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); - std::vector new_profile_avatars; - for (Profile* profile : all_profiles) { - if (profile->GetPath().BaseName() != - profile_manager->GetInitialProfileDir()) { - size_t icon_index = - profile->GetPrefs()->GetInteger(prefs::kProfileAvatarIndex); - ASSERT_NE(icon_index, placeholder_avatar_index); - // already seen? - bool icon_duplicate_found = (std::find( - new_profile_avatars.begin(), - new_profile_avatars.end(), - icon_index) != new_profile_avatars.end()); - ASSERT_NE(icon_duplicate_found, true); - new_profile_avatars.push_back(icon_index); - } - } -} diff --git a/chromium_src/chrome/browser/search/instant_service.cc b/chromium_src/chrome/browser/search/instant_service.cc index a78c86b1c455..fb8a8bf531f9 100644 --- a/chromium_src/chrome/browser/search/instant_service.cc +++ b/chromium_src/chrome/browser/search/instant_service.cc @@ -9,9 +9,7 @@ class AlwaysGoogleSearchProviderObserver : public SearchProviderObserver { public: using SearchProviderObserver::SearchProviderObserver; - // This is not override because base is not virtual, but that's ok if we - // reference this derived class. - bool is_google() { return true; } + bool is_google() override { return true; } }; #define SearchProviderObserver AlwaysGoogleSearchProviderObserver diff --git a/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc b/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc index c14bfb1bd030..b2c21b18fda2 100644 --- a/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc +++ b/chromium_src/chrome/browser/ui/page_info/chrome_page_info_delegate.cc @@ -6,10 +6,11 @@ #include "chrome/browser/profiles/profile.h" #include "../../../../../../chrome/browser/ui/page_info/chrome_page_info_delegate.cc" +#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" bool ChromePageInfoDelegate::BraveShouldShowPermission( ContentSettingsType type) { - if ((type == ContentSettingsType::PLUGINS || + if ((content_settings::IsShieldsContentSettingsType(type) || type == ContentSettingsType::GEOLOCATION) && GetProfile()->IsTor()) { return false; diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc b/chromium_src/chrome/browser/ui/views/frame/tab_strip_region_view.cc similarity index 81% rename from chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc rename to chromium_src/chrome/browser/ui/views/frame/tab_strip_region_view.cc index 050c41d0a962..a0b8f631582e 100644 --- a/chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chromium_src/chrome/browser/ui/views/frame/tab_strip_region_view.cc @@ -6,5 +6,5 @@ #include "brave/browser/ui/views/tabs/brave_new_tab_button.h" #define NewTabButton BraveNewTabButton -#include "../../../../../../../chrome/browser/ui/views/tabs/tab_strip.cc" +#include "../../../../../../../chrome/browser/ui/views/frame/tab_strip_region_view.cc" #undef NewTabButton diff --git a/chromium_src/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chromium_src/chrome/browser/ui/webui/settings/site_settings_helper.cc index 248e2463a9ed..d709a9f7c351 100644 --- a/chromium_src/chrome/browser/ui/webui/settings/site_settings_helper.cc +++ b/chromium_src/chrome/browser/ui/webui/settings/site_settings_helper.cc @@ -6,11 +6,26 @@ #define HasRegisteredGroupName HasRegisteredGroupName_ChromiumImpl #define ContentSettingsTypeToGroupName \ ContentSettingsTypeToGroupName_ChromiumImpl + +// clang-format off +#define BRAVE_CONTENT_SETTINGS_TYPE_GROUP_NAMES_LIST \ + {ContentSettingsType::BRAVE_ADS, nullptr}, \ + {ContentSettingsType::BRAVE_COSMETIC_FILTERING, nullptr}, \ + {ContentSettingsType::BRAVE_TRACKERS, nullptr}, \ + {ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, nullptr}, \ + {ContentSettingsType::BRAVE_FINGERPRINTING_V2, nullptr}, \ + {ContentSettingsType::BRAVE_SHIELDS, nullptr}, \ + {ContentSettingsType::BRAVE_REFERRERS, nullptr}, \ + {ContentSettingsType::BRAVE_COOKIES, nullptr}, +// clang-format on + #define BRAVE_SITE_SETTINGS_HELPER_CONTENT_SETTINGS_TYPE_FROM_GROUP_NAME \ if (name == "autoplay") \ return ContentSettingsType::AUTOPLAY; #include "../../../../../../../chrome/browser/ui/webui/settings/site_settings_helper.cc" + +#undef BRAVE_CONTENT_SETTINGS_TYPE_GROUP_NAMES_LIST #undef BRAVE_SITE_SETTINGS_HELPER_CONTENT_SETTINGS_TYPE_FROM_GROUP_NAME #undef ContentSettingsTypeToGroupName #undef HasRegisteredGroupName 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 3cbd64da3ef2..9f9314feea17 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 @@ -10,6 +10,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings_pattern.h" +#include "components/content_settings/core/common/content_settings_types.h" #include "content/public/test/browser_test.h" const GURL& GetBraveURL() { @@ -37,15 +38,13 @@ class BraveContentSettingsRegistryBrowserTest : public InProcessBrowserTest { IN_PROC_BROWSER_TEST_F(BraveContentSettingsRegistryBrowserTest, WithoutWildcardContentSetting) { ContentSetting brave_url_shields_setting = - content_settings()->GetContentSetting( - GetBraveURL(), GetBraveURL(), ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + content_settings()->GetContentSetting(GetBraveURL(), GetBraveURL(), + ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_DEFAULT, brave_url_shields_setting); ContentSetting brave_url_shields_setting_private = private_content_settings()->GetContentSetting( - GetBraveURL(), GetBraveURL(), ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + GetBraveURL(), GetBraveURL(), ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_DEFAULT, brave_url_shields_setting_private); } @@ -55,21 +54,16 @@ IN_PROC_BROWSER_TEST_F(BraveContentSettingsRegistryBrowserTest, ContentSettingsPattern::FromURL(GetBraveURL()); content_settings()->SetContentSettingCustomScope( - brave_url_pattern, - brave_url_pattern, - ContentSettingsType::PLUGINS, - brave_shields::kBraveShields, + brave_url_pattern, brave_url_pattern, ContentSettingsType::BRAVE_SHIELDS, CONTENT_SETTING_ALLOW); ContentSetting brave_url_shields_setting = - content_settings()->GetContentSetting( - GetBraveURL(), GetBraveURL(), ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + content_settings()->GetContentSetting(GetBraveURL(), GetBraveURL(), + ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_ALLOW, brave_url_shields_setting); ContentSetting brave_url_shields_setting_private = private_content_settings()->GetContentSetting( - GetBraveURL(), GetBraveURL(), ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + GetBraveURL(), GetBraveURL(), ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_ALLOW, brave_url_shields_setting_private); } diff --git a/chromium_src/components/content_settings/core/browser/content_settings_pref.cc b/chromium_src/components/content_settings/core/browser/content_settings_pref.cc new file mode 100644 index 000000000000..d31204d23d24 --- /dev/null +++ b/chromium_src/components/content_settings/core/browser/content_settings_pref.cc @@ -0,0 +1,19 @@ +/* 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 "build/build_config.h" + +#if !defined(OS_IOS) +#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" + +#define BRAVE_SET_WEBSITE_SETTING \ + content_settings::IsShieldsContentSettingsType(content_type_) || +#else +#define BRAVE_SET_WEBSITE_SETTING +#endif + +#include "../../../../../../components/content_settings/core/browser/content_settings_pref.cc" + +#undef BRAVE_SET_WEBSITE_SETTING diff --git a/chromium_src/components/content_settings/core/browser/content_settings_registry.cc b/chromium_src/components/content_settings/core/browser/content_settings_registry.cc index a31f0ed155e1..497a3600a133 100644 --- a/chromium_src/components/content_settings/core/browser/content_settings_registry.cc +++ b/chromium_src/components/content_settings/core/browser/content_settings_registry.cc @@ -7,8 +7,46 @@ #include "../../../../../../components/content_settings/core/browser/content_settings_registry.cc" #undef BRAVE_INIT +#include "brave/components/brave_shields/common/brave_shield_constants.h" namespace content_settings { +namespace { + +const struct { + const char* name; + ContentSettingsType type; +} kBraveContentSettingstypes[] = { + {brave_shields::kAds, ContentSettingsType::BRAVE_ADS}, + {brave_shields::kCosmeticFiltering, + ContentSettingsType::BRAVE_COSMETIC_FILTERING}, + {brave_shields::kTrackers, ContentSettingsType::BRAVE_TRACKERS}, + {brave_shields::kHTTPUpgradableResources, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES}, + {brave_shields::kFingerprintingV2, + ContentSettingsType::BRAVE_FINGERPRINTING_V2}, + {brave_shields::kBraveShields, ContentSettingsType::BRAVE_SHIELDS}, + {brave_shields::kReferrers, ContentSettingsType::BRAVE_REFERRERS}, + {brave_shields::kCookies, ContentSettingsType::BRAVE_COOKIES}, +}; + +} // namespace + +void ContentSettingsRegistry::RegisterBraveContentSettingsTypes( + const ContentSettingsType& type, + const std::string& name) { + Register(type, name, CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::SYNCABLE, + AllowlistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, + CONTENT_SETTING_ASK, + CONTENT_SETTING_DETECT_IMPORTANT_CONTENT), + WebsiteSettingsInfo::SINGLE_ORIGIN_WITH_EMBEDDED_EXCEPTIONS_SCOPE, + WebsiteSettingsRegistry::DESKTOP | + WebsiteSettingsRegistry::PLATFORM_ANDROID, + ContentSettingsInfo::INHERIT_IN_INCOGNITO, + ContentSettingsInfo::PERSISTENT, + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); +} + void ContentSettingsRegistry::BraveInit() { // Add CONTENT_SETTING_ASK for autoplay content_settings_info_.erase(ContentSettingsType::AUTOPLAY); @@ -40,6 +78,10 @@ void ContentSettingsRegistry::BraveInit() { ContentSettingsInfo::EPHEMERAL, ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); + // Register Brave-specific types, defaulting them to CONTENT_SETTING_BLOCK. + for (auto brave_type : kBraveContentSettingstypes) + RegisterBraveContentSettingsTypes(brave_type.type, brave_type.name); + // Disable background sync by default (brave/brave-browser#4709) content_settings_info_.erase(ContentSettingsType::BACKGROUND_SYNC); website_settings_registry_->UnRegister(ContentSettingsType::BACKGROUND_SYNC); diff --git a/chromium_src/components/content_settings/core/browser/content_settings_registry.h b/chromium_src/components/content_settings/core/browser/content_settings_registry.h index bb71264c77d2..f8b63d61626c 100644 --- a/chromium_src/components/content_settings/core/browser/content_settings_registry.h +++ b/chromium_src/components/content_settings/core/browser/content_settings_registry.h @@ -22,8 +22,10 @@ #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" -#define Init \ - Init(); \ +#define Init \ + Init(); \ + void RegisterBraveContentSettingsTypes(const ContentSettingsType& type, \ + const std::string& name); \ void BraveInit #include "../../../../../../components/content_settings/core/browser/content_settings_registry.h" diff --git a/chromium_src/components/content_settings/core/browser/content_settings_utils.cc b/chromium_src/components/content_settings/core/browser/content_settings_utils.cc index 6a575b47aeda..4cbb79452002 100644 --- a/chromium_src/components/content_settings/core/browser/content_settings_utils.cc +++ b/chromium_src/components/content_settings/core/browser/content_settings_utils.cc @@ -6,14 +6,12 @@ #include "base/feature_list.h" #include "brave/components/brave_shields/common/brave_shield_constants.h" -#define BRAVE_GET_RENDER_CONTENT_SETTING_RULES \ - map->GetSettingsForOneType(ContentSettingsType::AUTOPLAY, \ - ResourceIdentifier(), &(rules->autoplay_rules)); \ - map->GetSettingsForOneType(ContentSettingsType::PLUGINS, \ - brave_shields::kFingerprintingV2, \ - &(rules->fingerprinting_rules)); \ - map->GetSettingsForOneType(ContentSettingsType::PLUGINS, \ - brave_shields::kBraveShields, \ +#define BRAVE_GET_RENDER_CONTENT_SETTING_RULES \ + map->GetSettingsForOneType(ContentSettingsType::AUTOPLAY, \ + &(rules->autoplay_rules)); \ + map->GetSettingsForOneType(ContentSettingsType::BRAVE_FINGERPRINTING_V2, \ + &(rules->fingerprinting_rules)); \ + map->GetSettingsForOneType(ContentSettingsType::BRAVE_SHIELDS, \ &(rules->brave_shields_rules)); #include "../../../../../../components/content_settings/core/browser/content_settings_utils.cc" diff --git a/chromium_src/components/content_settings/core/browser/host_content_settings_map.cc b/chromium_src/components/content_settings/core/browser/host_content_settings_map.cc index aedee4e2be13..2481c97d9a72 100644 --- a/chromium_src/components/content_settings/core/browser/host_content_settings_map.cc +++ b/chromium_src/components/content_settings/core/browser/host_content_settings_map.cc @@ -8,12 +8,11 @@ #if defined(OS_IOS) #include "../../../../../../components/content_settings/core/browser/host_content_settings_map.cc" #else -#include "brave/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.h" #include "brave/components/content_settings/core/browser/brave_content_settings_pref_provider.h" -#define EphemeralProvider BraveEphemeralProvider #define PrefProvider BravePrefProvider +#define DefaultProvider BraveDefaultProvider #include "../../../../../../components/content_settings/core/browser/host_content_settings_map.cc" -#undef EphemeralProvider #undef PrefProvider +#undef DefaultProvider #endif diff --git a/chromium_src/components/content_settings/core/common/content_settings.cc b/chromium_src/components/content_settings/core/common/content_settings.cc index 54f595c8cf0d..31062988957d 100644 --- a/chromium_src/components/content_settings/core/common/content_settings.cc +++ b/chromium_src/components/content_settings/core/common/content_settings.cc @@ -3,9 +3,48 @@ * 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/. */ +// Leave a gap between Chromium values and our values in the kHistogramValue +// array so that we don't have to renumber when new content settings types are +// added upstream. +namespace { + +// Do not change the value arbitrarily. This variable is only used for the +// DCHECK in ContentSettingTypeToHistogramValue function below. +constexpr int kBraveValuesStart = 1000; + +constexpr int brave_value(int incr) { + return kBraveValuesStart + incr; +} + +} // namespace + +// clang-format off +#define BRAVE_HISTOGRAM_VALUE_LIST \ + {ContentSettingsType::BRAVE_ADS, brave_value(0)}, \ + {ContentSettingsType::BRAVE_COSMETIC_FILTERING, brave_value(1)}, \ + {ContentSettingsType::BRAVE_TRACKERS, brave_value(2)}, \ + {ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, brave_value(3)}, \ + {ContentSettingsType::BRAVE_FINGERPRINTING_V2, brave_value(4)}, \ + {ContentSettingsType::BRAVE_SHIELDS, brave_value(5)}, \ + {ContentSettingsType::BRAVE_REFERRERS, brave_value(6)}, \ + {ContentSettingsType::BRAVE_COOKIES, brave_value(7)}, +// clang-format on + #define BRAVE_IS_RENDERER_CONTENT_SETTING \ content_type == ContentSettingsType::AUTOPLAY || +#define ContentSettingTypeToHistogramValue \ + ContentSettingTypeToHistogramValue_ChromiumImpl + #include "../../../../../../components/content_settings/core/common/content_settings.cc" +#undef ContentSettingTypeToHistogramValue +#undef BRAVE_HISTOGRAM_VALUE_LIST #undef BRAVE_IS_RENDERER_CONTENT_SETTING + +int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting, + size_t* num_values) { + DCHECK(static_cast(ContentSettingsType::NUM_TYPES) < kBraveValuesStart); + return ContentSettingTypeToHistogramValue_ChromiumImpl(content_setting, + num_values); +} diff --git a/chromium_src/components/content_settings/core/common/content_settings_types.h b/chromium_src/components/content_settings/core/common/content_settings_types.h new file mode 100644 index 000000000000..d9bf879ccf64 --- /dev/null +++ b/chromium_src/components/content_settings/core/common/content_settings_types.h @@ -0,0 +1,25 @@ +/* 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_COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_TYPES_H_ +#define BRAVE_CHROMIUM_SRC_COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_TYPES_H_ + +// clang-format off +#define BRAVE_CONTENT_SETTINGS_TYPES_LIST \ + BRAVE_ADS, \ + BRAVE_COSMETIC_FILTERING, \ + BRAVE_TRACKERS, \ + BRAVE_HTTP_UPGRADABLE_RESOURCES, \ + BRAVE_FINGERPRINTING_V2, \ + BRAVE_SHIELDS, \ + BRAVE_REFERRERS, \ + BRAVE_COOKIES +// clang-format on + +#include "../../../../../../components/content_settings/core/common/content_settings_types.h" + +#undef BRAVE_CONTENT_SETTINGS_TYPES_LIST + +#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_TYPES_H_ diff --git a/chromium_src/components/permissions/permission_request.h b/chromium_src/components/permissions/permission_request_enums.h similarity index 80% rename from chromium_src/components/permissions/permission_request.h rename to chromium_src/components/permissions/permission_request_enums.h index c4b7b4fcf93c..8a7b760d2144 100644 --- a/chromium_src/components/permissions/permission_request.h +++ b/chromium_src/components/permissions/permission_request_enums.h @@ -3,18 +3,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_H_ -#define BRAVE_CHROMIUM_SRC_COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_H_ +#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ENUMS_H_ +#define BRAVE_CHROMIUM_SRC_COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ENUMS_H_ #if defined(BRAVE_CHROMIUM_BUILD) +// clang-format off #define BRAVE_PERMISSION_REQUEST_TYPES \ PERMISSION_AUTOPLAY, \ PERMISSION_WIDEVINE, \ PERMISSION_WALLET, +// clang-format on #else #define BRAVE_PERMISSION_REQUEST_TYPES #endif -#include "../../../../components/permissions/permission_request.h" +#include "../../../../components/permissions/permission_request_enums.h" -#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_H_ +#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ENUMS_H_ diff --git a/chromium_src/ios/chrome/browser/ios_chrome_field_trials.cc b/chromium_src/ios/chrome/browser/ios_chrome_field_trials.cc index 5596be073864..9a68e16dd4e3 100644 --- a/chromium_src/ios/chrome/browser/ios_chrome_field_trials.cc +++ b/chromium_src/ios/chrome/browser/ios_chrome_field_trials.cc @@ -40,6 +40,7 @@ void IOSChromeFieldTrials::SetupFieldTrials() { void IOSChromeFieldTrials::SetupFeatureControllingFieldTrials( bool has_seed, + const base::FieldTrial::EntropyProvider& low_entropy_provider, base::FeatureList* feature_list) { // Add code here to enable field trials that are active at first run. // See http://crrev/c/1128269 for an example. diff --git a/chromium_src/ios/chrome/browser/metrics/ios_chrome_metrics_service_client.mm b/chromium_src/ios/chrome/browser/metrics/ios_chrome_metrics_service_client.mm index b393829a1ddb..d45181b59de5 100644 --- a/chromium_src/ios/chrome/browser/metrics/ios_chrome_metrics_service_client.mm +++ b/chromium_src/ios/chrome/browser/metrics/ios_chrome_metrics_service_client.mm @@ -96,7 +96,7 @@ void DeleteFileMetrics() { // static void IOSChromeMetricsServiceClient::RegisterPrefs( PrefRegistrySimple* registry) { - + metrics::MetricsService::RegisterPrefs(registry); } metrics::MetricsService* IOSChromeMetricsServiceClient::GetMetricsService() { @@ -108,9 +108,7 @@ void DeleteFileMetrics() { } void IOSChromeMetricsServiceClient::SetMetricsClientId( - const std::string& client_id) { - -} + const std::string& client_id) {} int32_t IOSChromeMetricsServiceClient::GetProduct() { return metrics::ChromeUserMetricsExtension::CHROME; @@ -179,9 +177,7 @@ void DeleteFileMetrics() { DeleteFileMetrics(); } -void IOSChromeMetricsServiceClient::RegisterUKMProviders() { - -} +void IOSChromeMetricsServiceClient::RegisterUKMProviders() {} void IOSChromeMetricsServiceClient::CollectFinalHistograms() { DCHECK(thread_checker_.CalledOnValidThread()); @@ -196,11 +192,9 @@ void DeleteFileMetrics() { return false; } -void IOSChromeMetricsServiceClient::OnTabParented(web::WebState* web_state) { -} +void IOSChromeMetricsServiceClient::OnTabParented(web::WebState* web_state) {} -void IOSChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { -} +void IOSChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {} // static metrics::FileMetricsProvider::FilterAction diff --git a/chromium_src/third_party/blink/renderer/modules/webaudio/audio_buffer.cc b/chromium_src/third_party/blink/renderer/modules/webaudio/audio_buffer.cc index 421e479f154e..59f187a34e22 100644 --- a/chromium_src/third_party/blink/renderer/modules/webaudio/audio_buffer.cc +++ b/chromium_src/third_party/blink/renderer/modules/webaudio/audio_buffer.cc @@ -19,7 +19,7 @@ if (WebContentSettingsClient* settings = \ brave::GetContentSettingsClientFor(context)) { \ DOMFloat32Array* destination_array = array.View(); \ - size_t len = destination_array->lengthAsSizeT(); \ + size_t len = destination_array->length(); \ if (len > 0) { \ float* destination = destination_array->Data(); \ brave::AudioFarblingCallback audio_farbling_callback = \ diff --git a/chromium_src/ui/base/webui/web_ui_util.cc b/chromium_src/ui/base/webui/web_ui_util.cc index 7bde1c4cbaa2..084430aaded3 100644 --- a/chromium_src/ui/base/webui/web_ui_util.cc +++ b/chromium_src/ui/base/webui/web_ui_util.cc @@ -6,7 +6,7 @@ #include "ui/base/webui/web_ui_util.h" #include "brave/ui/webui/resources/grit/brave_webui_resources.h" -#include "ui/resources/grit/webui_resources.h" +#include "ui/resources/grit/webui_generated_resources.h" // Replace text_defaults.css with brave's text_defaults.css // which is defined in brave_webui_resources.grd. 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 153f2da017bd..ea0e3b880159 100644 --- a/chromium_src/ui/views/controls/button/md_text_button.cc +++ b/chromium_src/ui/views/controls/button/md_text_button.cc @@ -32,11 +32,6 @@ class BraveTextButtonHighlightPathGenerator namespace views { -MdTextButton::MdTextButton(ButtonListener* listener, - const base::string16& text, - int button_context) - : MdTextButton(PressedCallback(listener, this), text, button_context) {} - MdTextButton::MdTextButton(PressedCallback callback, const base::string16& text, int button_context) 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 3b649002353c..4534dc8448af 100644 --- a/chromium_src/ui/views/controls/button/md_text_button.h +++ b/chromium_src/ui/views/controls/button/md_text_button.h @@ -28,10 +28,7 @@ namespace views { // - No shadow for prominent background class VIEWS_EXPORT MdTextButton : public MdTextButtonBase { public: - explicit MdTextButton(ButtonListener* listener = nullptr, - const base::string16& text = base::string16(), - int button_context = style::CONTEXT_BUTTON_MD); - explicit MdTextButton(PressedCallback callback, + explicit MdTextButton(PressedCallback callback = PressedCallback(), const base::string16& text = base::string16(), int button_context = style::CONTEXT_BUTTON_MD); ~MdTextButton() override; diff --git a/components/assist_ranker/ranker_model_loader_impl_unittest.cc b/components/assist_ranker/ranker_model_loader_impl_unittest.cc index e13c7bc3e06c..97ea93e87daa 100644 --- a/components/assist_ranker/ranker_model_loader_impl_unittest.cc +++ b/components/assist_ranker/ranker_model_loader_impl_unittest.cc @@ -13,7 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/strings/stringprintf.h" #include "base/task/post_task.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h" diff --git a/components/brave_ads/browser/ads_service_browsertest.cc b/components/brave_ads/browser/ads_service_browsertest.cc index 3014dd13c058..092071f148b1 100644 --- a/components/brave_ads/browser/ads_service_browsertest.cc +++ b/components/brave_ads/browser/ads_service_browsertest.cc @@ -10,26 +10,26 @@ #include "base/containers/flat_map.h" #include "base/files/file_util.h" +#include "base/memory/weak_ptr.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" -#include "base/memory/weak_ptr.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "bat/ledger/ledger.h" -#include "brave/common/brave_paths.h" #include "brave/browser/brave_rewards/rewards_service_factory.h" +#include "brave/browser/ui/views/brave_actions/brave_actions_container.h" +#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" +#include "brave/common/brave_paths.h" #include "brave/components/brave_ads/browser/ads_service_factory.h" #include "brave/components/brave_ads/browser/ads_service_impl.h" #include "brave/components/brave_ads/common/pref_names.h" -#include "brave/components/brave_rewards/browser/rewards_service_impl.h" #include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h" // NOLINT #include "brave/components/brave_rewards/browser/rewards_notification_service_observer.h" // NOLINT +#include "brave/components/brave_rewards/browser/rewards_service_impl.h" #include "brave/components/brave_rewards/browser/test/common/rewards_browsertest_util.h" #include "brave/components/brave_rewards/common/pref_names.h" #include "brave/components/l10n/browser/locale_helper_mock.h" -#include "brave/browser/ui/views/brave_actions/brave_actions_container.h" -#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/chrome_constants.h" diff --git a/components/brave_extension/extension/brave_extension/state/shieldsPanelState.ts b/components/brave_extension/extension/brave_extension/state/shieldsPanelState.ts index 8c2c70a82ff5..09df19301eb6 100644 --- a/components/brave_extension/extension/brave_extension/state/shieldsPanelState.ts +++ b/components/brave_extension/extension/brave_extension/state/shieldsPanelState.ts @@ -96,7 +96,7 @@ export const updateResourceBlocked: shieldState.UpdateResourceBlocked = (state, ...tabs[tabId] } - if (blockType === 'ads') { + if (blockType === 'shieldsAds') { tabs[tabId].adsBlockedResources = unique([ ...tabs[tabId].adsBlockedResources, subresource ]) tabs[tabId].adsBlocked = tabs[tabId].adsBlockedResources.length } else if (blockType === 'trackers') { diff --git a/components/brave_extension/extension/brave_extension/types/adblock/adblockTypes.ts b/components/brave_extension/extension/brave_extension/types/adblock/adblockTypes.ts index d8ab3dca6cf0..06522f9bf65f 100644 --- a/components/brave_extension/extension/brave_extension/types/adblock/adblockTypes.ts +++ b/components/brave_extension/extension/brave_extension/types/adblock/adblockTypes.ts @@ -2,7 +2,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/. */ -export type BlockTypes = 'ads' | 'trackers' | 'httpUpgradableResources' | 'javascript' | 'fingerprinting' +export type BlockTypes = 'shieldsAds' | 'trackers' | 'httpUpgradableResources' | 'javascript' | 'fingerprinting' export type BlockOptions = 'allow' | 'block' export type BlockFPOptions = 'allow' | 'block' | 'block_third_party' export type BlockCookiesOptions = 'allow' | 'block' | 'block_third_party' diff --git a/components/brave_extension/extension/brave_extension/types/other/blockTypes.ts b/components/brave_extension/extension/brave_extension/types/other/blockTypes.ts index 9ccd5c4aeca2..d18d59083ab7 100644 --- a/components/brave_extension/extension/brave_extension/types/other/blockTypes.ts +++ b/components/brave_extension/extension/brave_extension/types/other/blockTypes.ts @@ -2,7 +2,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/. */ -export type BlockTypes = 'ads' | 'trackers' | 'httpUpgradableResources' | 'javascript' | 'fingerprinting' +export type BlockTypes = 'shieldsAds' | 'trackers' | 'httpUpgradableResources' | 'javascript' | 'fingerprinting' export type BlockOptions = 'allow' | 'block' export type BlockFPOptions = 'allow' | 'block' | 'block_third_party' export type BlockCookiesOptions = 'allow' | 'block' | 'block_third_party' diff --git a/components/brave_referrals/browser/brave_referrals_service.cc b/components/brave_referrals/browser/brave_referrals_service.cc index 46c6eb01483b..91f779a80480 100644 --- a/components/brave_referrals/browser/brave_referrals_service.cc +++ b/components/brave_referrals/browser/brave_referrals_service.cc @@ -8,7 +8,7 @@ #include #include -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/environment.h" #include "base/files/file_path.h" #include "base/files/file_util.h" diff --git a/components/brave_rewards/browser/test/common/rewards_browsertest_context_helper.cc b/components/brave_rewards/browser/test/common/rewards_browsertest_context_helper.cc index b9a53c59bafe..c9fb9dbdc36c 100644 --- a/components/brave_rewards/browser/test/common/rewards_browsertest_context_helper.cc +++ b/components/brave_rewards/browser/test/common/rewards_browsertest_context_helper.cc @@ -5,7 +5,7 @@ #include -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "brave/browser/extensions/api/brave_action_api.h" #include "brave/browser/ui/views/brave_actions/brave_actions_container.h" #include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" diff --git a/components/brave_rewards/browser/test/common/rewards_browsertest_util.cc b/components/brave_rewards/browser/test/common/rewards_browsertest_util.cc index cd4095ef2a2f..26e49628c1fc 100644 --- a/components/brave_rewards/browser/test/common/rewards_browsertest_util.cc +++ b/components/brave_rewards/browser/test/common/rewards_browsertest_util.cc @@ -8,7 +8,7 @@ #include "base/files/file_util.h" #include "base/path_service.h" #include "base/run_loop.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "bat/ledger/mojom_structs.h" #include "brave/common/brave_paths.h" #include "brave/components/brave_rewards/browser/test/common/rewards_browsertest_util.h" diff --git a/components/brave_rewards/browser/test/rewards_browsertest.cc b/components/brave_rewards/browser/test/rewards_browsertest.cc index 46a9808947ac..e0ff343dc985 100644 --- a/components/brave_rewards/browser/test/rewards_browsertest.cc +++ b/components/brave_rewards/browser/test/rewards_browsertest.cc @@ -7,7 +7,7 @@ #include #include "base/containers/flat_map.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "bat/ledger/internal/uphold/uphold_util.h" #include "brave/browser/brave_rewards/rewards_service_factory.h" #include "brave/common/brave_paths.h" diff --git a/components/brave_rewards/browser/test/rewards_contribution_browsertest.cc b/components/brave_rewards/browser/test/rewards_contribution_browsertest.cc index 615fd420d734..747e89b69131 100644 --- a/components/brave_rewards/browser/test/rewards_contribution_browsertest.cc +++ b/components/brave_rewards/browser/test/rewards_contribution_browsertest.cc @@ -7,7 +7,7 @@ #include #include "base/containers/flat_map.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "brave/browser/brave_rewards/rewards_service_factory.h" #include "brave/common/brave_paths.h" #include "brave/components/brave_rewards/browser/rewards_service_impl.h" diff --git a/components/brave_rewards/browser/test/rewards_database_browsertest.cc b/components/brave_rewards/browser/test/rewards_database_browsertest.cc index 148253d73ef1..2b773c9c1040 100644 --- a/components/brave_rewards/browser/test/rewards_database_browsertest.cc +++ b/components/brave_rewards/browser/test/rewards_database_browsertest.cc @@ -8,7 +8,7 @@ #include "base/path_service.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "bat/ledger/internal/database/database_util.h" #include "bat/ledger/mojom_structs.h" #include "brave/browser/brave_rewards/rewards_service_factory.h" diff --git a/components/brave_rewards/browser/test/rewards_state_browsertest.cc b/components/brave_rewards/browser/test/rewards_state_browsertest.cc index 2d197d7973c6..c97dd3fe0ed1 100644 --- a/components/brave_rewards/browser/test/rewards_state_browsertest.cc +++ b/components/brave_rewards/browser/test/rewards_state_browsertest.cc @@ -8,7 +8,7 @@ #include "base/path_service.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "bat/ledger/mojom_structs.h" #include "brave/browser/brave_rewards/rewards_service_factory.h" #include "brave/common/brave_paths.h" diff --git a/components/brave_shields/browser/base_brave_shields_service.cc b/components/brave_shields/browser/base_brave_shields_service.cc index 1b900a74951a..d5bb6a26271d 100644 --- a/components/brave_shields/browser/base_brave_shields_service.cc +++ b/components/brave_shields/browser/base_brave_shields_service.cc @@ -11,7 +11,7 @@ #include #include "base/bind.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" diff --git a/components/brave_shields/browser/brave_shields_util.cc b/components/brave_shields/browser/brave_shields_util.cc index 137790fa232b..5a4cafa92b28 100644 --- a/components/brave_shields/browser/brave_shields_util.cc +++ b/components/brave_shields/browser/brave_shields_util.cc @@ -17,6 +17,7 @@ #include "brave/components/brave_shields/common/features.h" #include "brave/components/content_settings/core/common/content_settings_util.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/referrer.h" @@ -116,7 +117,7 @@ void SetBraveShieldsEnabled(HostContentSettingsMap* map, map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kBraveShields, + ContentSettingsType::BRAVE_SHIELDS, // this is 'allow_brave_shields' so 'enable' == 'allow' enable ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); @@ -134,16 +135,15 @@ void ResetBraveShieldsEnabled(HostContentSettingsMap* map, const GURL& url) { map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kBraveShields, - CONTENT_SETTING_DEFAULT); + ContentSettingsType::BRAVE_SHIELDS, CONTENT_SETTING_DEFAULT); } bool GetBraveShieldsEnabled(HostContentSettingsMap* map, const GURL& url) { if (url.is_valid() && !url.SchemeIsHTTPOrHTTPS()) return false; - ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::PLUGINS, kBraveShields); + ContentSetting setting = + map->GetContentSetting(url, GURL(), ContentSettingsType::BRAVE_SHIELDS); // see EnableBraveShields - allow and default == true return setting == CONTENT_SETTING_BLOCK ? false : true; @@ -160,21 +160,20 @@ void SetAdControlType(HostContentSettingsMap* map, return; } - map->SetContentSettingCustomScope(primary_pattern, - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kAds, - GetDefaultBlockFromControlType(type)); + map->SetContentSettingCustomScope( + primary_pattern, ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_ADS, GetDefaultBlockFromControlType(type)); map->SetContentSettingCustomScope(primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kTrackers, + ContentSettingsType::BRAVE_TRACKERS, GetDefaultBlockFromControlType(type)); RecordShieldsSettingChanged(local_state); } ControlType GetAdControlType(HostContentSettingsMap* map, const GURL& url) { - ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::PLUGINS, kAds); + ContentSetting setting = + map->GetContentSetting(url, GURL(), ContentSettingsType::BRAVE_ADS); return setting == CONTENT_SETTING_ALLOW ? ControlType::ALLOW : ControlType::BLOCK; @@ -190,17 +189,15 @@ void SetCosmeticFilteringControlType(HostContentSettingsMap* map, return; } - map->SetContentSettingCustomScope(primary_pattern, - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, - kCosmeticFiltering, - GetDefaultBlockFromControlType(type)); + map->SetContentSettingCustomScope( + primary_pattern, ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_COSMETIC_FILTERING, + GetDefaultBlockFromControlType(type)); map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, - kCosmeticFiltering, + ContentSettingsType::BRAVE_COSMETIC_FILTERING, GetDefaultAllowFromControlType(type)); RecordShieldsSettingChanged(local_state); @@ -209,13 +206,11 @@ void SetCosmeticFilteringControlType(HostContentSettingsMap* map, ControlType GetCosmeticFilteringControlType(HostContentSettingsMap* map, const GURL& url) { ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::PLUGINS, kCosmeticFiltering); + url, GURL(), ContentSettingsType::BRAVE_COSMETIC_FILTERING); - ContentSetting fp_setting = map->GetContentSetting( - url, - GURL("https://firstParty/"), - ContentSettingsType::PLUGINS, - kCosmeticFiltering); + ContentSetting fp_setting = + map->GetContentSetting(url, GURL("https://firstParty/"), + ContentSettingsType::BRAVE_COSMETIC_FILTERING); if (setting == CONTENT_SETTING_ALLOW) { return ControlType::ALLOW; @@ -249,33 +244,28 @@ void SetCookieControlType(HostContentSettingsMap* map, map->SetContentSettingCustomScope(primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kReferrers, + ContentSettingsType::BRAVE_REFERRERS, GetDefaultBlockFromControlType(type)); map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, kCookies, - GetDefaultAllowFromControlType(type)); + ContentSettingsType::BRAVE_COOKIES, GetDefaultAllowFromControlType(type)); - map->SetContentSettingCustomScope(primary_pattern, - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kCookies, - GetDefaultBlockFromControlType(type)); + map->SetContentSettingCustomScope( + primary_pattern, ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_COOKIES, GetDefaultBlockFromControlType(type)); RecordShieldsSettingChanged(local_state); } // TODO(bridiver) - convert cookie settings to ContentSettingsType::COOKIES // while maintaining read backwards compat ControlType GetCookieControlType(HostContentSettingsMap* map, const GURL& url) { - ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::PLUGINS, kCookies); + ContentSetting setting = + map->GetContentSetting(url, GURL(), ContentSettingsType::BRAVE_COOKIES); ContentSetting fp_setting = map->GetContentSetting( - url, - GURL("https://firstParty/"), - ContentSettingsType::PLUGINS, - kCookies); + url, GURL("https://firstParty/"), ContentSettingsType::BRAVE_COOKIES); if (setting == CONTENT_SETTING_ALLOW) { return ControlType::ALLOW; @@ -287,8 +277,8 @@ ControlType GetCookieControlType(HostContentSettingsMap* map, const GURL& url) { } bool AllowReferrers(HostContentSettingsMap* map, const GURL& url) { - ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::PLUGINS, kReferrers); + ContentSetting setting = + map->GetContentSetting(url, GURL(), ContentSettingsType::BRAVE_REFERRERS); return setting == CONTENT_SETTING_ALLOW; } @@ -304,16 +294,11 @@ void SetFingerprintingControlType(HostContentSettingsMap* map, // Clear previous value to have only one rule for one pattern. map->SetContentSettingCustomScope( - primary_pattern, - ContentSettingsPattern::FromString("https://balanced/*"), - ContentSettingsType::PLUGINS, - kFingerprintingV2, - CONTENT_SETTING_DEFAULT); - map->SetContentSettingCustomScope(primary_pattern, - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, - kFingerprintingV2, - CONTENT_SETTING_DEFAULT); + primary_pattern, ContentSettingsPattern::FromString("https://balanced/*"), + ContentSettingsType::BRAVE_FINGERPRINTING_V2, CONTENT_SETTING_DEFAULT); + map->SetContentSettingCustomScope( + primary_pattern, ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_FINGERPRINTING_V2, CONTENT_SETTING_DEFAULT); auto content_setting = CONTENT_SETTING_BLOCK; auto secondary_pattern = @@ -324,11 +309,9 @@ void SetFingerprintingControlType(HostContentSettingsMap* map, secondary_pattern = ContentSettingsPattern::Wildcard(); } - map->SetContentSettingCustomScope(primary_pattern, - secondary_pattern, - ContentSettingsType::PLUGINS, - kFingerprintingV2, - content_setting); + map->SetContentSettingCustomScope( + primary_pattern, secondary_pattern, + ContentSettingsType::BRAVE_FINGERPRINTING_V2, content_setting); RecordShieldsSettingChanged(local_state); } @@ -336,8 +319,7 @@ void SetFingerprintingControlType(HostContentSettingsMap* map, ControlType GetFingerprintingControlType(HostContentSettingsMap* map, const GURL& url) { ContentSettingsForOneType fingerprinting_rules; - map->GetSettingsForOneType(ContentSettingsType::PLUGINS, - brave_shields::kFingerprintingV2, + map->GetSettingsForOneType(ContentSettingsType::BRAVE_FINGERPRINTING_V2, &fingerprinting_rules); ContentSetting fp_setting = @@ -359,7 +341,7 @@ void SetHTTPSEverywhereEnabled(HostContentSettingsMap* map, map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kHTTPUpgradableResources, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, // this is 'allow_http_upgradeable_resources' so enabling // httpse will set the value to 'BLOCK' enable ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); @@ -377,13 +359,13 @@ void ResetHTTPSEverywhereEnabled(HostContentSettingsMap* map, map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, kHTTPUpgradableResources, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, CONTENT_SETTING_DEFAULT); } bool GetHTTPSEverywhereEnabled(HostContentSettingsMap* map, const GURL& url) { ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::PLUGINS, kHTTPUpgradableResources); + url, GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); return setting == CONTENT_SETTING_ALLOW ? false : true; } @@ -400,7 +382,7 @@ void SetNoScriptControlType(HostContentSettingsMap* map, map->SetContentSettingCustomScope( primary_pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", + ContentSettingsType::JAVASCRIPT, type == ControlType::ALLOW ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); RecordShieldsSettingChanged(local_state); @@ -408,8 +390,8 @@ void SetNoScriptControlType(HostContentSettingsMap* map, ControlType GetNoScriptControlType(HostContentSettingsMap* map, const GURL& url) { - ContentSetting setting = map->GetContentSetting( - url, GURL(), ContentSettingsType::JAVASCRIPT, ""); + ContentSetting setting = + map->GetContentSetting(url, GURL(), ContentSettingsType::JAVASCRIPT); return setting == CONTENT_SETTING_ALLOW ? ControlType::ALLOW : ControlType::BLOCK; diff --git a/components/brave_shields/browser/brave_shields_util_unittest.cc b/components/brave_shields/browser/brave_shields_util_unittest.cc index cfa617d3cf75..47c00b2b0bbd 100644 --- a/components/brave_shields/browser/brave_shields_util_unittest.cc +++ b/components/brave_shields/browser/brave_shields_util_unittest.cc @@ -105,20 +105,17 @@ TEST_F(BraveShieldsUtilTest, SetBraveShieldsEnabled_ForOrigin) { GURL("http://brave.com")); // setting should apply to origin auto setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should apply to different scheme setting = map->GetContentSetting(GURL("https://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should not apply to default - setting = - map->GetContentSetting(GURL(), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kBraveShields); + setting = map->GetContentSetting(GURL(), GURL(), + ContentSettingsType::BRAVE_SHIELDS); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); } @@ -159,8 +156,8 @@ TEST_F(BraveShieldsUtilTest, GetBraveShieldsEnabled_ForOrigin) { /* BLOCK */ map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kBraveShields, CONTENT_SETTING_BLOCK); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_SHIELDS, + CONTENT_SETTING_BLOCK); setting = brave_shields::GetBraveShieldsEnabled(map, GURL("http://brave.com/*")); EXPECT_EQ(false, setting); @@ -187,36 +184,33 @@ TEST_F(BraveShieldsUtilTest, GetBraveShieldsEnabled_IsNotHttpHttps) { TEST_F(BraveShieldsUtilTest, SetAdControlType_Default) { auto* map = HostContentSettingsMapFactory::GetForProfile(profile()); // settings should be default - auto setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kAds); + auto setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kAds); + ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); /* ALLOW */ brave_shields::SetAdControlType(map, ControlType::ALLOW, GURL()); - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kAds); + setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // override should apply to all origins setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kAds); + ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); /* BLOCK */ brave_shields::SetAdControlType(map, ControlType::BLOCK, GURL()); - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kAds); + setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); // override should apply to all origins setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kAds); + ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); } @@ -227,19 +221,17 @@ TEST_F(BraveShieldsUtilTest, SetAdControlType_ForOrigin) { GURL("http://brave.com")); // setting should apply to origin auto setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kAds); + ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should also apply to different scheme setting = map->GetContentSetting(GURL("https://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kAds); + ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should not apply to default - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kAds); + setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::BRAVE_ADS); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); } @@ -250,18 +242,16 @@ TEST_F(BraveShieldsUtilTest, GetAdControlType_Default) { EXPECT_EQ(ControlType::BLOCK, setting); /* ALLOW */ - map->SetContentSettingCustomScope(ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, - brave_shields::kAds, CONTENT_SETTING_ALLOW); + map->SetContentSettingCustomScope( + ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_ADS, CONTENT_SETTING_ALLOW); setting = brave_shields::GetAdControlType(map, GURL()); EXPECT_EQ(ControlType::ALLOW, setting); /* BLOCK */ - map->SetContentSettingCustomScope(ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, - brave_shields::kAds, CONTENT_SETTING_BLOCK); + map->SetContentSettingCustomScope( + ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_ADS, CONTENT_SETTING_BLOCK); setting = brave_shields::GetAdControlType(map, GURL()); EXPECT_EQ(ControlType::BLOCK, setting); } @@ -279,8 +269,8 @@ TEST_F(BraveShieldsUtilTest, GetAdControlType_ForOrigin) { /* ALLOW */ map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kAds, CONTENT_SETTING_ALLOW); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_ADS, + CONTENT_SETTING_ALLOW); setting = brave_shields::GetAdControlType(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::ALLOW, setting); @@ -294,10 +284,9 @@ TEST_F(BraveShieldsUtilTest, GetAdControlType_ForOrigin) { /* BLOCK */ // change default to allow - map->SetContentSettingCustomScope(ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, - brave_shields::kAds, CONTENT_SETTING_ALLOW); + map->SetContentSettingCustomScope( + ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_ADS, CONTENT_SETTING_ALLOW); setting = brave_shields::GetAdControlType(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::ALLOW, setting); @@ -310,8 +299,8 @@ TEST_F(BraveShieldsUtilTest, GetAdControlType_ForOrigin) { // set override to block map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kAds, CONTENT_SETTING_BLOCK); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_ADS, + CONTENT_SETTING_BLOCK); setting = brave_shields::GetAdControlType(map, GURL("http://brave.com/*")); EXPECT_EQ(ControlType::BLOCK, setting); @@ -328,79 +317,71 @@ TEST_F(BraveShieldsUtilTest, GetAdControlType_ForOrigin) { TEST_F(BraveShieldsUtilTest, SetCookieControlType_Default) { auto* map = HostContentSettingsMapFactory::GetForProfile(profile()); // setting should be default to start with - auto setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kCookies); + auto setting = map->GetContentSetting(GURL(), GURL(), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); setting = map->GetContentSetting(GURL(), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); - setting = map->GetContentSetting( - GURL("http://brave.com"), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); + setting = map->GetContentSetting(GURL("http://brave.com"), + GURL("https://firstParty"), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); /* ALLOW */ brave_shields::SetCookieControlType(map, ControlType::ALLOW, GURL()); - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL(), GURL(), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); setting = map->GetContentSetting(GURL(), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should apply to all urls setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); - setting = map->GetContentSetting( - GURL("http://brave.com"), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL("http://brave.com"), + GURL("https://firstParty"), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); /* BLOCK */ brave_shields::SetCookieControlType(map, ControlType::BLOCK, GURL()); - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL(), GURL(), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); setting = map->GetContentSetting(GURL(), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); // setting should apply to all urls setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); - setting = map->GetContentSetting( - GURL("http://brave.com"), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL("http://brave.com"), + GURL("https://firstParty"), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); /* BLOCK_THIRD_PARTY */ brave_shields::SetCookieControlType(map, ControlType::BLOCK_THIRD_PARTY, GURL()); - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL(), GURL(), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); setting = map->GetContentSetting(GURL(), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should apply to all urls setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); - setting = map->GetContentSetting( - GURL("http://brave.com"), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL("http://brave.com"), + GURL("https://firstParty"), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); } @@ -412,31 +393,28 @@ TEST_F(BraveShieldsUtilTest, SetCookieControlType_ForOrigin) { GURL("http://brave.com")); // override should apply to origin auto setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); - setting = map->GetContentSetting( - GURL("http://brave.com"), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); + setting = map->GetContentSetting(GURL("http://brave.com"), + GURL("https://firstParty"), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // override should also apply to different scheme setting = map->GetContentSetting(GURL("https://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); - setting = map->GetContentSetting( - GURL("https://brave.com"), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL("https://brave.com"), + GURL("https://firstParty"), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // override should not apply to default - setting = map->GetContentSetting( - GURL(), GURL(), ContentSettingsType::PLUGINS, brave_shields::kCookies); + setting = map->GetContentSetting(GURL(), GURL(), + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); // override should not apply to default setting = map->GetContentSetting(GURL(), GURL("https://firstParty"), - ContentSettingsType::PLUGINS, - brave_shields::kCookies); + ContentSettingsType::BRAVE_COOKIES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); } @@ -452,13 +430,11 @@ TEST_F(BraveShieldsUtilTest, GetCookieControlType_Default) { /* ALLOW */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_ALLOW); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_ALLOW); map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_ALLOW); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_ALLOW); setting = brave_shields::GetCookieControlType(map, GURL()); EXPECT_EQ(ControlType::ALLOW, setting); setting = brave_shields::GetCookieControlType(map, GURL("http://brave.com")); @@ -467,13 +443,11 @@ TEST_F(BraveShieldsUtilTest, GetCookieControlType_Default) { /* BLOCK */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_BLOCK); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_BLOCK); map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_BLOCK); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_BLOCK); setting = brave_shields::GetCookieControlType(map, GURL()); EXPECT_EQ(ControlType::BLOCK, setting); setting = brave_shields::GetCookieControlType(map, GURL("http://brave.com")); @@ -482,13 +456,11 @@ TEST_F(BraveShieldsUtilTest, GetCookieControlType_Default) { /* BLOCK_THIRD_PARTY */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_BLOCK); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_BLOCK); map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_ALLOW); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_ALLOW); setting = brave_shields::GetCookieControlType(map, GURL()); EXPECT_EQ(ControlType::BLOCK_THIRD_PARTY, setting); setting = brave_shields::GetCookieControlType(map, GURL("http://brave.com")); @@ -505,13 +477,12 @@ TEST_F(BraveShieldsUtilTest, GetCookieControlType_ForOrigin) { /* ALLOW */ map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kCookies, CONTENT_SETTING_ALLOW); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_COOKIES, + CONTENT_SETTING_ALLOW); map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_ALLOW); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_ALLOW); setting = brave_shields::GetCookieControlType(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::ALLOW, setting); setting = brave_shields::GetCookieControlType(map, GURL()); @@ -520,13 +491,12 @@ TEST_F(BraveShieldsUtilTest, GetCookieControlType_ForOrigin) { /* BLOCK */ map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kCookies, CONTENT_SETTING_BLOCK); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_COOKIES, + CONTENT_SETTING_BLOCK); map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_BLOCK); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_BLOCK); setting = brave_shields::GetCookieControlType(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::BLOCK, setting); setting = brave_shields::GetCookieControlType(map, GURL()); @@ -535,13 +505,12 @@ TEST_F(BraveShieldsUtilTest, GetCookieControlType_ForOrigin) { /* BLOCK_THIRD_PARTY */ map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kCookies, CONTENT_SETTING_BLOCK); + ContentSettingsPattern::Wildcard(), ContentSettingsType::BRAVE_COOKIES, + CONTENT_SETTING_BLOCK); map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), ContentSettingsPattern::FromString("https://firstParty/*"), - ContentSettingsType::PLUGINS, brave_shields::kCookies, - CONTENT_SETTING_ALLOW); + ContentSettingsType::BRAVE_COOKIES, CONTENT_SETTING_ALLOW); setting = brave_shields::GetCookieControlType(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::BLOCK_THIRD_PARTY, setting); setting = brave_shields::GetCookieControlType(map, GURL()); @@ -642,39 +611,36 @@ TEST_F(BraveShieldsUtilTest, SetFingerprintingControlType_ForOrigin) { TEST_F(BraveShieldsUtilTest, SetHTTPSEverywhereEnabled_Default) { auto* map = HostContentSettingsMapFactory::GetForProfile(profile()); // settings should be default - auto setting = - map->GetContentSetting(GURL(), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + auto setting = map->GetContentSetting( + GURL(), GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); - setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL("http://brave.com"), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); /* disabled */ brave_shields::SetHTTPSEverywhereEnabled(map, false, GURL()); - setting = - map->GetContentSetting(GURL(), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL(), GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // override should apply to all origins - setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL("http://brave.com"), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); /* enabled */ brave_shields::SetHTTPSEverywhereEnabled(map, true, GURL()); - setting = - map->GetContentSetting(GURL(), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL(), GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); // override should apply to all origins - setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL("http://brave.com"), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); } @@ -685,20 +651,19 @@ TEST_F(BraveShieldsUtilTest, SetHTTPSEverywhereEnabled_ForOrigin) { map, false, GURL("http://brave.com")); // setting should apply to origin auto setting = map->GetContentSetting( - GURL("http://brave.com"), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + GURL("http://brave.com"), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should apply to different scheme - setting = map->GetContentSetting(GURL("https://brave.com"), GURL(), - ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL("https://brave.com"), GURL(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // setting should not apply to default - setting = - map->GetContentSetting(GURL(), GURL(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources); + setting = map->GetContentSetting( + GURL(), GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES); EXPECT_EQ(CONTENT_SETTING_DEFAULT, setting); } @@ -711,7 +676,7 @@ TEST_F(BraveShieldsUtilTest, GetHTTPSEverywhereEnabled_Default) { /* ALLOW */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kHTTPUpgradableResources, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, CONTENT_SETTING_ALLOW); setting = brave_shields::GetHTTPSEverywhereEnabled(map, GURL()); EXPECT_EQ(false, setting); @@ -719,7 +684,7 @@ TEST_F(BraveShieldsUtilTest, GetHTTPSEverywhereEnabled_Default) { /* BLOCK */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kHTTPUpgradableResources, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, CONTENT_SETTING_BLOCK); setting = brave_shields::GetHTTPSEverywhereEnabled(map, GURL()); EXPECT_EQ(true, setting); @@ -740,8 +705,9 @@ TEST_F(BraveShieldsUtilTest, GetHTTPSEverywhereEnabled_ForOrigin) { /* ALLOW */ map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_ALLOW); + ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, + CONTENT_SETTING_ALLOW); setting = brave_shields::GetHTTPSEverywhereEnabled(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::ALLOW, setting); @@ -758,7 +724,7 @@ TEST_F(BraveShieldsUtilTest, GetHTTPSEverywhereEnabled_ForOrigin) { // change default to allow map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kHTTPUpgradableResources, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, CONTENT_SETTING_ALLOW); setting = brave_shields::GetHTTPSEverywhereEnabled(map, GURL("http://brave.com")); @@ -772,8 +738,9 @@ TEST_F(BraveShieldsUtilTest, GetHTTPSEverywhereEnabled_ForOrigin) { // set override to block map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::PLUGINS, - brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_BLOCK); + ContentSettingsPattern::Wildcard(), + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, + CONTENT_SETTING_BLOCK); setting = brave_shields::GetHTTPSEverywhereEnabled( map, GURL("http://brave.com/*")); EXPECT_EQ(true, setting); @@ -790,37 +757,37 @@ TEST_F(BraveShieldsUtilTest, GetHTTPSEverywhereEnabled_ForOrigin) { TEST_F(BraveShieldsUtilTest, SetNoScriptControlType_Default) { auto* map = HostContentSettingsMapFactory::GetForProfile(profile()); // settings should be default - auto setting = map->GetContentSetting(GURL(), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + auto setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); /* BLOCK */ brave_shields::SetNoScriptControlType(map, ControlType::BLOCK, GURL()); - setting = map->GetContentSetting(GURL(), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); // override should apply to all origins setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); /* ALLOW */ brave_shields::SetNoScriptControlType(map, ControlType::ALLOW, GURL()); - setting = map->GetContentSetting(GURL(), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); // override should apply to all origins setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); } @@ -832,17 +799,17 @@ TEST_F(BraveShieldsUtilTest, SetNoScriptControlType_ForOrigin) { GURL("http://brave.com")); // setting should apply to origin auto setting = map->GetContentSetting(GURL("http://brave.com"), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); // setting should also apply to different scheme setting = map->GetContentSetting(GURL("https://brave.com"), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); // setting should not apply to default - setting = map->GetContentSetting(GURL(), GURL(), - ContentSettingsType::JAVASCRIPT, ""); + setting = + map->GetContentSetting(GURL(), GURL(), ContentSettingsType::JAVASCRIPT); EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); } @@ -855,14 +822,14 @@ TEST_F(BraveShieldsUtilTest, GetNoScriptControlType_Default) { /* BLOCK */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_BLOCK); + ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_BLOCK); setting = brave_shields::GetNoScriptControlType(map, GURL()); EXPECT_EQ(ControlType::BLOCK, setting); /* ALLOW */ map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_ALLOW); + ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_ALLOW); setting = brave_shields::GetNoScriptControlType(map, GURL()); EXPECT_EQ(ControlType::ALLOW, setting); } @@ -883,7 +850,7 @@ TEST_F(BraveShieldsUtilTest, GetNoScriptControlType_ForOrigin) { // set override to block map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::JAVASCRIPT, "", + ContentSettingsPattern::Wildcard(), ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_BLOCK); setting = brave_shields::GetNoScriptControlType(map, GURL("http://brave.com/*")); @@ -900,7 +867,7 @@ TEST_F(BraveShieldsUtilTest, GetNoScriptControlType_ForOrigin) { // change default to block map->SetContentSettingCustomScope( ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_BLOCK); + ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_BLOCK); setting = brave_shields::GetNoScriptControlType(map, GURL("http://brave.com")); EXPECT_EQ(ControlType::BLOCK, setting); @@ -912,7 +879,7 @@ TEST_F(BraveShieldsUtilTest, GetNoScriptControlType_ForOrigin) { map->SetContentSettingCustomScope( ContentSettingsPattern::FromString("http://brave.com/*"), - ContentSettingsPattern::Wildcard(), ContentSettingsType::JAVASCRIPT, "", + ContentSettingsPattern::Wildcard(), ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_ALLOW); setting = brave_shields::GetNoScriptControlType(map, GURL("http://brave.com")); diff --git a/components/brave_shields/browser/cookie_pref_service.cc b/components/brave_shields/browser/cookie_pref_service.cc index 91dead089d0b..aa494c52915a 100644 --- a/components/brave_shields/browser/cookie_pref_service.cc +++ b/components/brave_shields/browser/cookie_pref_service.cc @@ -140,12 +140,10 @@ void CookiePrefService::OnPreferenceChanged() { void CookiePrefService::OnContentSettingChanged( const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - const std::string& resource_identifier) { + ContentSettingsType content_type) { if (primary_pattern == ContentSettingsPattern::Wildcard() && secondary_pattern == ContentSettingsPattern::Wildcard() && - content_type == ContentSettingsType::PLUGINS && - resource_identifier == brave_shields::kCookies) { + content_type == ContentSettingsType::BRAVE_COOKIES) { if (lock_.Try()) { SetCookiePrefDefaults(host_content_settings_map_, prefs_); lock_.Release(); diff --git a/components/brave_shields/browser/cookie_pref_service.h b/components/brave_shields/browser/cookie_pref_service.h index cbfef7c213ef..15a2de13d5ac 100644 --- a/components/brave_shields/browser/cookie_pref_service.h +++ b/components/brave_shields/browser/cookie_pref_service.h @@ -45,8 +45,7 @@ class CookiePrefService : public KeyedService, // content_settings::Observer overrides: void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - const std::string& resource_identifier) override; + ContentSettingsType content_type) override; Lock lock_; HostContentSettingsMap* host_content_settings_map_; diff --git a/components/brave_shields/common/brave_shield_constants.h b/components/brave_shields/common/brave_shield_constants.h index ea61b84c77f0..f05977b52767 100644 --- a/components/brave_shields/common/brave_shield_constants.h +++ b/components/brave_shields/common/brave_shield_constants.h @@ -9,7 +9,7 @@ namespace brave_shields { -const char kAds[] = "ads"; +const char kAds[] = "shieldsAds"; const char kCosmeticFiltering[] = "cosmeticFiltering"; const char kTrackers[] = "trackers"; const char kHTTPUpgradableResources[] = "httpUpgradableResources"; @@ -17,11 +17,16 @@ const char kJavaScript[] = "javascript"; const char kFingerprintingV2[] = "fingerprintingV2"; const char kBraveShields[] = "braveShields"; const char kReferrers[] = "referrers"; -const char kCookies[] = "cookies"; +const char kCookies[] = "shieldsCookies"; const char kFacebookEmbeds[] = "fb-embeds"; const char kTwitterEmbeds[] = "twitter-embeds"; const char kLinkedInEmbeds[] = "linked-in-embeds"; +// Values used before the migration away from ResourceIdentifier, kept around +// for migration purposes only. +const char kObsoleteAds[] = "ads"; +const char kObsoleteCookies[] = "cookies"; + } // namespace brave_shields #endif // BRAVE_COMPONENTS_BRAVE_SHIELDS_COMMON_BRAVE_SHIELD_CONSTANTS_H_ diff --git a/components/content_settings/core/browser/BUILD.gn b/components/content_settings/core/browser/BUILD.gn index 89ebb1bdccfc..09da13cb34e8 100644 --- a/components/content_settings/core/browser/BUILD.gn +++ b/components/content_settings/core/browser/BUILD.gn @@ -3,8 +3,8 @@ source_set("browser") { check_includes = false if (!is_ios) { sources = [ - "brave_content_settings_ephemeral_provider.cc", - "brave_content_settings_ephemeral_provider.h", + "brave_content_settings_default_provider.cc", + "brave_content_settings_default_provider.h", "brave_content_settings_pref_provider.cc", "brave_content_settings_pref_provider.h", "brave_content_settings_utils.cc", @@ -18,9 +18,11 @@ source_set("browser") { "//brave/common:shield_exceptions", "//brave/components/brave_shields/common", "//brave/components/content_settings/core/common", + + # see https://github.com/brave/brave-browser/issues/10624 above + # "//components/content_settings/core/browser", "//components/content_settings/core/common", "//components/prefs", - "//extensions/buildflags", "//net", "//url", ] diff --git a/components/content_settings/core/browser/brave_content_settings_default_provider.cc b/components/content_settings/core/browser/brave_content_settings_default_provider.cc new file mode 100644 index 000000000000..d80a50c96363 --- /dev/null +++ b/components/content_settings/core/browser/brave_content_settings_default_provider.cc @@ -0,0 +1,35 @@ +/* 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 "brave/components/content_settings/core/browser/brave_content_settings_default_provider.h" + +#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" +#include "build/build_config.h" +#include "components/prefs/pref_service.h" + +namespace content_settings { + +// static +void BraveDefaultProvider::RegisterProfilePrefs( + user_prefs::PrefRegistrySyncable* registry) { + DefaultProvider::RegisterProfilePrefs(registry); +} + +BraveDefaultProvider::BraveDefaultProvider(PrefService* prefs, + bool off_the_record) + : DefaultProvider(prefs, off_the_record) {} + +BraveDefaultProvider::~BraveDefaultProvider() {} + +std::unique_ptr BraveDefaultProvider::GetRuleIterator( + ContentSettingsType content_type, + bool off_the_record) const { + if (content_settings::IsShieldsContentSettingsType(content_type)) + return nullptr; + + return DefaultProvider::GetRuleIterator(content_type, off_the_record); +} + +} // namespace content_settings diff --git a/components/content_settings/core/browser/brave_content_settings_default_provider.h b/components/content_settings/core/browser/brave_content_settings_default_provider.h new file mode 100644 index 000000000000..334211f90fd6 --- /dev/null +++ b/components/content_settings/core/browser/brave_content_settings_default_provider.h @@ -0,0 +1,39 @@ +/* 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_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_ +#define BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_ + +#include + +#include "base/macros.h" +#include "base/synchronization/lock.h" +#include "components/content_settings/core/browser/content_settings_default_provider.h" +#include "components/content_settings/core/browser/content_settings_rule.h" +#include "components/content_settings/core/common/content_settings_types.h" + +class PrefService; + +namespace content_settings { + +class BraveDefaultProvider : public DefaultProvider { + public: + BraveDefaultProvider(PrefService* prefs, bool off_the_record); + ~BraveDefaultProvider() override; + + static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); + + // ProviderInterface implementations. + std::unique_ptr GetRuleIterator( + ContentSettingsType content_type, + bool off_the_record) const override; + + private: + DISALLOW_COPY_AND_ASSIGN(BraveDefaultProvider); +}; + +} // namespace content_settings + +#endif // BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_ diff --git a/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.cc b/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.cc deleted file mode 100644 index d701c527970e..000000000000 --- a/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.cc +++ /dev/null @@ -1,36 +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/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.h" - -#include -#include - -#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" - -namespace content_settings { - -bool BraveEphemeralProvider::SetWebsiteSetting( - const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - const ResourceIdentifier& resource_identifier, - std::unique_ptr&& in_value, - const ContentSettingConstraints& constraint) { - // Prevent this handle shields configuration. - if (content_type == ContentSettingsType::PLUGINS && - IsShieldsResourceID(resource_identifier)) { - return false; - } - - // Only flash plugin setting can be reached here. - DCHECK(resource_identifier.empty()); - - return EphemeralProvider::SetWebsiteSetting( - primary_pattern, secondary_pattern, content_type, resource_identifier, - std::move(in_value), constraint); -} - -} // namespace content_settings diff --git a/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.h b/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.h deleted file mode 100644 index b805c9e6bb1a..000000000000 --- a/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.h +++ /dev/null @@ -1,36 +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/. */ - -#ifndef BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_EPHEMERAL_PROVIDER_H_ -#define BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_EPHEMERAL_PROVIDER_H_ - -#include - -#include "components/content_settings/core/browser/content_settings_ephemeral_provider.h" - -namespace content_settings { - -// See the comments of BravePrefProvider. -class BraveEphemeralProvider : public EphemeralProvider { - public: - using EphemeralProvider::EphemeralProvider; - ~BraveEphemeralProvider() override {} - - private: - // EphemeralProvider overrides: - bool SetWebsiteSetting( - const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - const ResourceIdentifier& resource_identifier, - std::unique_ptr&& value, - const ContentSettingConstraints& constraints = {}) override; - - DISALLOW_COPY_AND_ASSIGN(BraveEphemeralProvider); -}; - -} // namespace content_settings - -#endif // BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_EPHEMERAL_PROVIDER_H_ diff --git a/components/content_settings/core/browser/brave_content_settings_pref_provider.cc b/components/content_settings/core/browser/brave_content_settings_pref_provider.cc index 61a9f55326d7..b7aa7a2b3a43 100644 --- a/components/content_settings/core/browser/brave_content_settings_pref_provider.cc +++ b/components/content_settings/core/browser/brave_content_settings_pref_provider.cc @@ -24,6 +24,8 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" +#include "services/preferences/public/cpp/dictionary_value_update.h" +#include "services/preferences/public/cpp/scoped_pref_update.h" namespace content_settings { @@ -32,6 +34,12 @@ namespace { constexpr char kGoogleAuthPattern[] = "https://accounts.google.com/*"; constexpr char kFirebasePattern[] = "https://[*.]firebaseapp.com/*"; +const char kExpirationPath[] = "expiration"; +const char kLastModifiedPath[] = "last_modified"; +const char kSessionModelPath[] = "model"; +const char kSettingPath[] = "setting"; +const char kPerResourcePath[] = "per_resource"; + Rule CloneRule(const Rule& rule, bool reverse_patterns = false) { // brave plugin rules incorrectly use first party url as primary auto primary_pattern = reverse_patterns ? rule.secondary_pattern @@ -109,37 +117,29 @@ bool IsActive(const Rule& cookie_rule, } // namespace +// static +void BravePrefProvider::CopyPluginSettingsForMigration(PrefService* prefs) { + auto* plugins = + prefs->GetDictionary("profile.content_settings.exceptions.plugins"); + prefs->Set("brave.migrate.content_settings.exceptions.plugins", *plugins); +} + BravePrefProvider::BravePrefProvider(PrefService* prefs, bool off_the_record, bool store_last_modified, bool restore_session) : PrefProvider(prefs, off_the_record, store_last_modified, restore_session), initialized_(false), + store_last_modified_(store_last_modified), weak_factory_(this) { - brave_pref_change_registrar_.Init(prefs_); - brave_pref_change_registrar_.Add( + pref_change_registrar_.Add( kGoogleLoginControlType, base::BindRepeating(&BravePrefProvider::OnCookiePrefsChanged, base::Unretained(this))); - WebsiteSettingsRegistry* website_settings = - WebsiteSettingsRegistry::GetInstance(); - // Makes BravePrefProvder handle plugin type. - for (const WebsiteSettingsInfo* info : *website_settings) { - if (info->type() == ContentSettingsType::PLUGINS) { - content_settings_prefs_.insert(std::make_pair( - info->type(), - std::make_unique( - info->type(), prefs_, &brave_pref_change_registrar_, - info->pref_name(), off_the_record_, restore_session, - base::Bind(&PrefProvider::Notify, base::Unretained(this))))); - break; - } - } - MigrateShieldsSettings(off_the_record); - OnCookieSettingsChanged(ContentSettingsType::PLUGINS); + OnCookieSettingsChanged(ContentSettingsType::BRAVE_COOKIES); // Enable change notifications after initial setup to avoid notification spam initialized_ = true; @@ -150,7 +150,6 @@ BravePrefProvider::~BravePrefProvider() {} void BravePrefProvider::ShutdownOnUIThread() { RemoveObserver(this); - brave_pref_change_registrar_.RemoveAll(); PrefProvider::ShutdownOnUIThread(); } @@ -160,6 +159,10 @@ void BravePrefProvider::RegisterProfilePrefs( PrefProvider::RegisterProfilePrefs(registry); // Register shields settings migration pref. registry->RegisterIntegerPref(kBraveShieldsSettingsVersion, 1); + + // migration of obsolete plugin prefs + registry->RegisterDictionaryPref( + "brave.migrate.content_settings.exceptions.plugins"); } void BravePrefProvider::MigrateShieldsSettings(bool incognito) { @@ -168,7 +171,100 @@ void BravePrefProvider::MigrateShieldsSettings(bool incognito) { // session, so also nothing to do. if (incognito) return; + + // Prior to Chromium 88, we used the "plugins" ContentSettingsType along with + // ResourceIdentifiers to store our settings, which we need to migrate now + // first of all, before attempting any other migration. + MigrateShieldsSettingsFromResourceIds(); + + // Now carry on with any other migration that we might need. MigrateShieldsSettingsV1ToV2(); + + // Finally clean this up now that Shields' settings have been migrated. + prefs_->ClearPref("brave.migrate.content_settings.exceptions.plugins"); +} + +void BravePrefProvider::MigrateShieldsSettingsFromResourceIds() { + const base::DictionaryValue* plugins_dictionary = prefs_->GetDictionary( + "brave.migrate.content_settings.exceptions.plugins"); + if (!plugins_dictionary) + return; + + for (base::DictionaryValue::Iterator i(*plugins_dictionary); !i.IsAtEnd(); + i.Advance()) { + const std::string& patterns_string(i.key()); + const base::DictionaryValue* settings_dictionary = nullptr; + bool is_dictionary = i.value().GetAsDictionary(&settings_dictionary); + DCHECK(is_dictionary); + + base::Time expiration = + GetTimeStampFromDictionary(settings_dictionary, kExpirationPath); + SessionModel session_model = + GetSessionModelFromDictionary(settings_dictionary, kSessionModelPath); + + const base::DictionaryValue* resource_dictionary = nullptr; + if (settings_dictionary->GetDictionary(kPerResourcePath, + &resource_dictionary)) { + base::Time last_modified = + GetTimeStampFromDictionary(settings_dictionary, kLastModifiedPath); + for (base::DictionaryValue::Iterator j(*resource_dictionary); + !j.IsAtEnd(); j.Advance()) { + const std::string& resource_identifier(j.key()); + int setting = CONTENT_SETTING_DEFAULT; + bool is_integer = j.value().GetAsInteger(&setting); + DCHECK(is_integer); + DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); + + // For "ads" and "cookies" we need to adapt the name to the new one, + // otherwise it will refer to upstream's "ads" and "cookies" settings. + std::string actual_name; + if (resource_identifier == brave_shields::kObsoleteAds) + actual_name = brave_shields::kAds; + else if (resource_identifier == brave_shields::kObsoleteCookies) + actual_name = brave_shields::kCookies; + else + actual_name = resource_identifier; + + MigrateShieldsSettingsFromResourceIdsForOneType( + GetShieldsSettingUserPrefsPath(actual_name), patterns_string, + expiration, last_modified, session_model, setting); + } + } + } +} + +void BravePrefProvider::MigrateShieldsSettingsFromResourceIdsForOneType( + const std::string& preference_name, + const std::string& patterns_string, + const base::Time& expiration, + const base::Time& last_modified, + SessionModel session_model, + int setting) { + prefs::ScopedDictionaryPrefUpdate update(prefs_, preference_name); + std::unique_ptr shield_settings = update.Get(); + + std::unique_ptr shield_settings_dictionary; + bool found = shield_settings->GetDictionaryWithoutPathExpansion( + patterns_string, &shield_settings_dictionary); + + if (!found) { + shield_settings_dictionary = + shield_settings->SetDictionaryWithoutPathExpansion( + patterns_string, std::make_unique()); + } + DCHECK(shield_settings_dictionary); + + shield_settings_dictionary->SetKey( + kExpirationPath, + base::Value(base::NumberToString( + expiration.ToDeltaSinceWindowsEpoch().InMicroseconds()))); + shield_settings_dictionary->SetKey( + kLastModifiedPath, + base::Value(base::NumberToString( + last_modified.ToDeltaSinceWindowsEpoch().InMicroseconds()))); + shield_settings_dictionary->SetKey( + kSessionModelPath, base::Value(static_cast(session_model))); + shield_settings_dictionary->SetKey(kSettingPath, base::Value(setting)); } void BravePrefProvider::MigrateShieldsSettingsV1ToV2() { @@ -176,28 +272,24 @@ void BravePrefProvider::MigrateShieldsSettingsV1ToV2() { if (prefs_->GetInteger(kBraveShieldsSettingsVersion) != 1) return; - // All sources in ContentSettingsType::PLUGINS we want to migrate. - for (const auto& resource_id : GetShieldsResourceIDs()) { - MigrateShieldsSettingsV1ToV2ForOneType(ContentSettingsType::PLUGINS, - resource_id); - } + // All sources in Brave-specific ContentSettingsType(s) we want to migrate. + for (const auto& content_type : GetShieldsContentSettingsTypes()) + MigrateShieldsSettingsV1ToV2ForOneType(content_type); // ContentSettingsType::JAVASCRIPT. - MigrateShieldsSettingsV1ToV2ForOneType(ContentSettingsType::JAVASCRIPT, - std::string()); + MigrateShieldsSettingsV1ToV2ForOneType(ContentSettingsType::JAVASCRIPT); // Mark migration as done. prefs_->SetInteger(kBraveShieldsSettingsVersion, 2); } void BravePrefProvider::MigrateShieldsSettingsV1ToV2ForOneType( - ContentSettingsType content_type, - const std::string& resource_id) { + ContentSettingsType content_type) { using OldRule = std::pair; // Find rules that can be migrated and create replacement rules for them. std::vector old_rules; std::vector new_rules; - auto rule_iterator = PrefProvider::GetRuleIterator(content_type, resource_id, + auto rule_iterator = PrefProvider::GetRuleIterator(content_type, /*off_the_record*/ false); while (rule_iterator && rule_iterator->HasNext()) { auto rule = rule_iterator->Next(); @@ -219,13 +311,13 @@ void BravePrefProvider::MigrateShieldsSettingsV1ToV2ForOneType( DCHECK_EQ(old_rules.size(), new_rules.size()); for (size_t i = 0; i < old_rules.size(); i++) { // Remove current setting. - PrefProvider::SetWebsiteSetting( - old_rules[i].first, old_rules[i].second, content_type, resource_id, + SetWebsiteSettingInternal( + old_rules[i].first, old_rules[i].second, content_type, ContentSettingToValue(CONTENT_SETTING_DEFAULT), {}); // Add new setting. - PrefProvider::SetWebsiteSetting( + SetWebsiteSettingInternal( new_rules[i].primary_pattern, new_rules[i].secondary_pattern, - content_type, resource_id, + content_type, ContentSettingToValue(ValueToContentSetting(&(new_rules[i].value))), {new_rules[i].expiration, new_rules[i].session_model}); } @@ -235,18 +327,8 @@ bool BravePrefProvider::SetWebsiteSetting( const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern, ContentSettingsType content_type, - const ResourceIdentifier& resource_identifier, std::unique_ptr&& in_value, const ContentSettingConstraints& constraints) { - // Flash's setting shouldn't be reached here. - // Its content type is plugin and id is empty string. - // One excpetion is default setting. It can be persisted. - if (content_type == ContentSettingsType::PLUGINS && - resource_identifier.empty()) { - DCHECK(primary_pattern == ContentSettingsPattern::Wildcard() && - secondary_pattern == ContentSettingsPattern::Wildcard()); - } - // handle changes to brave cookie settings from chromium cookie settings UI if (content_type == ContentSettingsType::COOKIES) { auto* value = in_value.get(); @@ -269,22 +351,43 @@ bool BravePrefProvider::SetWebsiteSetting( ContentSettingsPattern::FromString("https://firstParty/*"); } - // change to type PLUGINS - return PrefProvider::SetWebsiteSetting( + // change to type ContentSettingsType::BRAVE_COOKIES + return SetWebsiteSettingInternal( plugin_primary_pattern, plugin_secondary_pattern, - ContentSettingsType::PLUGINS, brave_shields::kCookies, - std::move(in_value), constraints); + ContentSettingsType::BRAVE_COOKIES, std::move(in_value), constraints); } } + return SetWebsiteSettingInternal(primary_pattern, secondary_pattern, + content_type, std::move(in_value), + constraints); +} + +bool BravePrefProvider::SetWebsiteSettingInternal( + const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, + ContentSettingsType content_type, + std::unique_ptr&& in_value, + const ContentSettingConstraints& constraints) { + // PrefProvider ignores default settings so handle them here for shields + if (content_settings::IsShieldsContentSettingsType(content_type) && + primary_pattern == ContentSettingsPattern::Wildcard() && + secondary_pattern == ContentSettingsPattern::Wildcard()) { + base::Time modified_time = + store_last_modified_ ? base::Time::Now() : base::Time(); + + return GetPref(content_type) + ->SetWebsiteSetting(primary_pattern, secondary_pattern, modified_time, + std::move(in_value), constraints); + } + return PrefProvider::SetWebsiteSetting(primary_pattern, secondary_pattern, - content_type, resource_identifier, - std::move(in_value), constraints); + content_type, std::move(in_value), + constraints); } std::unique_ptr BravePrefProvider::GetRuleIterator( ContentSettingsType content_type, - const ResourceIdentifier& resource_identifier, bool incognito) const { if (content_type == ContentSettingsType::COOKIES) { std::vector rules; @@ -297,14 +400,7 @@ std::unique_ptr BravePrefProvider::GetRuleIterator( return std::make_unique(std::move(rules)); } - // Early return. We don't store flash plugin setting in preference. - if (content_type == ContentSettingsType::PLUGINS && - resource_identifier == "") - return nullptr; - - return PrefProvider::GetRuleIterator(content_type, - resource_identifier, - incognito); + return PrefProvider::GetRuleIterator(content_type, incognito); } void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, @@ -350,7 +446,6 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, // add chromium cookies auto chromium_cookies_iterator = PrefProvider::GetRuleIterator( ContentSettingsType::COOKIES, - "", incognito); while (chromium_cookies_iterator && chromium_cookies_iterator->HasNext()) { rules.emplace_back(CloneRule(chromium_cookies_iterator->Next())); @@ -358,9 +453,7 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, chromium_cookies_iterator.reset(); auto brave_shields_iterator = PrefProvider::GetRuleIterator( - ContentSettingsType::PLUGINS, - brave_shields::kBraveShields, - incognito); + ContentSettingsType::BRAVE_SHIELDS, incognito); // collect shield rules std::vector shield_rules; @@ -372,9 +465,7 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, // add brave cookies after checking shield status auto brave_cookies_iterator = PrefProvider::GetRuleIterator( - ContentSettingsType::PLUGINS, - brave_shields::kCookies, - incognito); + ContentSettingsType::BRAVE_COOKIES, incognito); // Matching cookie rules against shield rules. while (brave_cookies_iterator && brave_cookies_iterator->HasNext()) { @@ -446,7 +537,8 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, } // Notify brave cookie changes as ContentSettingsType::COOKIES - if (initialized_ && content_type == ContentSettingsType::PLUGINS) { + if (initialized_ && (content_type == ContentSettingsType::BRAVE_COOKIES || + content_type == ContentSettingsType::BRAVE_SHIELDS)) { // PostTask here to avoid content settings autolock DCHECK base::PostTask( FROM_HERE, @@ -460,16 +552,14 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type, void BravePrefProvider::NotifyChanges(const std::vector& rules, bool incognito) { for (const auto& rule : rules) { - Notify(rule.primary_pattern, - rule.secondary_pattern, - ContentSettingsType::COOKIES, - ""); + Notify(rule.primary_pattern, rule.secondary_pattern, + ContentSettingsType::COOKIES); } } void BravePrefProvider::OnCookiePrefsChanged( const std::string& pref) { - OnCookieSettingsChanged(ContentSettingsType::PLUGINS); + OnCookieSettingsChanged(ContentSettingsType::BRAVE_COOKIES); } void BravePrefProvider::OnCookieSettingsChanged( @@ -481,12 +571,10 @@ void BravePrefProvider::OnCookieSettingsChanged( void BravePrefProvider::OnContentSettingChanged( const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - const std::string& resource_identifier) { + ContentSettingsType content_type) { if (content_type == ContentSettingsType::COOKIES || - (content_type == ContentSettingsType::PLUGINS && - (resource_identifier == brave_shields::kCookies || - resource_identifier == brave_shields::kBraveShields))) { + content_type == ContentSettingsType::BRAVE_COOKIES || + content_type == ContentSettingsType::BRAVE_SHIELDS) { OnCookieSettingsChanged(content_type); } } diff --git a/components/content_settings/core/browser/brave_content_settings_pref_provider.h b/components/content_settings/core/browser/brave_content_settings_pref_provider.h index 93dbe776ccbc..e0217d5f0c85 100644 --- a/components/content_settings/core/browser/brave_content_settings_pref_provider.h +++ b/components/content_settings/core/browser/brave_content_settings_pref_provider.h @@ -34,6 +34,7 @@ class BravePrefProvider : public PrefProvider, bool restore_session); ~BravePrefProvider() override; + static void CopyPluginSettingsForMigration(PrefService* prefs); static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); // content_settings::PrefProvider overrides: @@ -41,12 +42,10 @@ class BravePrefProvider : public PrefProvider, bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern, ContentSettingsType content_type, - const ResourceIdentifier& resource_identifier, std::unique_ptr&& value, const ContentSettingConstraints& constraints) override; std::unique_ptr GetRuleIterator( ContentSettingsType content_type, - const ResourceIdentifier& resource_identifier, bool incognito) const override; private: @@ -54,29 +53,40 @@ class BravePrefProvider : public PrefProvider, FRIEND_TEST_ALL_PREFIXES(BravePrefProviderTest, TestShieldsSettingsMigration); FRIEND_TEST_ALL_PREFIXES(BravePrefProviderTest, TestShieldsSettingsMigrationVersion); + FRIEND_TEST_ALL_PREFIXES(BravePrefProviderTest, + TestShieldsSettingsMigrationFromResourceIDs); void MigrateShieldsSettings(bool incognito); + void MigrateShieldsSettingsFromResourceIds(); + void MigrateShieldsSettingsFromResourceIdsForOneType( + const std::string& preference_name, + const std::string& patterns_string, + const base::Time& expiration, + const base::Time& last_modified, + SessionModel session_model, + int setting); void MigrateShieldsSettingsV1ToV2(); - void MigrateShieldsSettingsV1ToV2ForOneType(ContentSettingsType content_type, - const std::string& resource_id); + void MigrateShieldsSettingsV1ToV2ForOneType(ContentSettingsType content_type); void UpdateCookieRules(ContentSettingsType content_type, bool incognito); void OnCookieSettingsChanged(ContentSettingsType content_type); void NotifyChanges(const std::vector& rules, bool incognito); + bool SetWebsiteSettingInternal( + const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, + ContentSettingsType content_type, + std::unique_ptr&& in_value, + const ContentSettingConstraints& constraints); // content_settings::Observer overrides: void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - const std::string& resource_identifier) override; + ContentSettingsType content_type) override; void OnCookiePrefsChanged(const std::string& pref); - // PrefProvider::pref_change_registrar_ alreay has plugin type. - PrefChangeRegistrar brave_pref_change_registrar_; - std::map> cookie_rules_; std::map> brave_cookie_rules_; bool initialized_; - + bool store_last_modified_; base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(BravePrefProvider); diff --git a/components/content_settings/core/browser/brave_content_settings_pref_provider_unittest.cc b/components/content_settings/core/browser/brave_content_settings_pref_provider_unittest.cc index 9f96e8618a9c..fa2371b9f348 100644 --- a/components/content_settings/core/browser/brave_content_settings_pref_provider_unittest.cc +++ b/components/content_settings/core/browser/brave_content_settings_pref_provider_unittest.cc @@ -8,17 +8,22 @@ #include "base/macros.h" #include "base/optional.h" +#include "base/values.h" #include "brave/common/pref_names.h" #include "brave/components/brave_shields/common/brave_shield_constants.h" #include "brave/components/content_settings/core/browser/brave_content_settings_pref_provider.h" +#include "brave/components/content_settings/core/browser/brave_content_settings_utils.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/browser/content_settings_registry.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/content_settings_types.h" #include "components/content_settings/core/common/content_settings_utils.h" #include "components/content_settings/core/test/content_settings_test_utils.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_task_environment.h" +#include "services/preferences/public/cpp/dictionary_value_update.h" +#include "services/preferences/public/cpp/scoped_pref_update.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -26,7 +31,16 @@ namespace content_settings { namespace { -using GURLSourcePair = std::pair; +constexpr char kUserProfilePluginsPath[] = + "profile.content_settings.exceptions.plugins"; + +const char kExpirationPath[] = "expiration"; +const char kLastModifiedPath[] = "last_modified"; +const char kSessionModelPath[] = "model"; +const char kSettingPath[] = "setting"; +const char kPerResourcePath[] = "per_resource"; + +using GURLSourcePair = std::pair; ContentSettingsPattern SecondaryUrlToPattern(const GURL& gurl) { CHECK(gurl == GURL() || gurl == GURL("https://firstParty/*")); @@ -36,6 +50,73 @@ ContentSettingsPattern SecondaryUrlToPattern(const GURL& gurl) { return ContentSettingsPattern::FromString("https://firstParty/*"); } +void InitializeAllShieldSettingsInDictionary( + prefs::DictionaryValueUpdate* dictionary, + const base::Time& last_modified_time, + const int& value) { + const uint64_t last_modified_time_in_ms = + last_modified_time.ToDeltaSinceWindowsEpoch().InMicroseconds(); + + dictionary->SetInteger(kExpirationPath, 0); + dictionary->SetString(kLastModifiedPath, + base::NumberToString(last_modified_time_in_ms)); + dictionary->SetInteger( + kSessionModelPath, + static_cast(content_settings::SessionModel::Durable)); + + std::unique_ptr per_resource_dict = + dictionary->SetDictionaryWithoutPathExpansion( + kPerResourcePath, std::make_unique()); + + per_resource_dict->SetInteger(brave_shields::kAds, value); + per_resource_dict->SetInteger(brave_shields::kCookies, value); + per_resource_dict->SetInteger(brave_shields::kCosmeticFiltering, value); + per_resource_dict->SetInteger(brave_shields::kFingerprintingV2, value); + per_resource_dict->SetInteger(brave_shields::kHTTPUpgradableResources, value); + per_resource_dict->SetInteger(brave_shields::kReferrers, value); + per_resource_dict->SetInteger(brave_shields::kTrackers, value); +} + +void InitializeBraveShieldsSettingInDictionary( + prefs::DictionaryValueUpdate* dictionary, + const base::Time& last_modified_time, + const int& value) { + const uint64_t last_modified_time_in_ms = + last_modified_time.ToDeltaSinceWindowsEpoch().InMicroseconds(); + + dictionary->SetInteger(kExpirationPath, 0); + dictionary->SetString(kLastModifiedPath, + base::NumberToString(last_modified_time_in_ms)); + dictionary->SetInteger( + kSessionModelPath, + static_cast(content_settings::SessionModel::Durable)); + + std::unique_ptr brave_per_resource_dict = + dictionary->SetDictionaryWithoutPathExpansion( + kPerResourcePath, std::make_unique()); + + brave_per_resource_dict->SetInteger(brave_shields::kBraveShields, value); +} + +void CheckMigrationFromResourceIdentifierForDictionary( + const base::DictionaryValue* dictionary, + const std::string& patterns_string, + const base::Time& expected_last_modified, + const int& expected_setting_value) { + const base::DictionaryValue* settings_dict = nullptr; + dictionary->GetDictionaryWithoutPathExpansion(patterns_string, + &settings_dict); + EXPECT_NE(settings_dict, nullptr); + + int actual_value; + settings_dict->GetInteger(kSettingPath, &actual_value); + EXPECT_EQ(GetTimeStampFromDictionary(settings_dict, kLastModifiedPath), + expected_last_modified); + EXPECT_EQ(GetSessionModelFromDictionary(settings_dict, kSessionModelPath), + content_settings::SessionModel::Durable); + EXPECT_EQ(actual_value, expected_setting_value); +} + class ShieldsSetting { public: ShieldsSetting(BravePrefProvider* provider, @@ -47,8 +128,7 @@ class ShieldsSetting { ContentSetting setting) { for (const auto& url_source : urls_) { provider_->SetWebsiteSetting( - pattern, SecondaryUrlToPattern(url_source.first), - ContentSettingsType::PLUGINS, url_source.second, + pattern, SecondaryUrlToPattern(url_source.first), url_source.second, ContentSettingToValue(setting), {}); } } @@ -70,7 +150,6 @@ class ShieldsSetting { for (const auto& url_source : urls_) { EXPECT_EQ(setting, TestUtils::GetContentSetting(provider_, url, url_source.first, - ContentSettingsType::PLUGINS, url_source.second, false)); } } @@ -82,46 +161,43 @@ class ShieldsSetting { class ShieldsCookieSetting : public ShieldsSetting { public: explicit ShieldsCookieSetting(BravePrefProvider* provider) - : ShieldsSetting(provider, - {{GURL(), brave_shields::kCookies}, - {GURL("https://firstParty/*"), brave_shields::kCookies}, - {GURL(), brave_shields::kReferrers}}) {} + : ShieldsSetting( + provider, + {{GURL(), ContentSettingsType::BRAVE_COOKIES}, + {GURL("https://firstParty/*"), ContentSettingsType::BRAVE_COOKIES}, + {GURL(), ContentSettingsType::BRAVE_REFERRERS}}) {} }; class ShieldsFingerprintingSetting : public ShieldsSetting { public: explicit ShieldsFingerprintingSetting(BravePrefProvider* provider) : ShieldsSetting(provider, - {{GURL(), brave_shields::kFingerprintingV2}, - {GURL("https://firstParty/*"), - brave_shields::kFingerprintingV2}}) {} + {{GURL(), ContentSettingsType::BRAVE_FINGERPRINTING_V2}, + {GURL("https://firstParty/*"), + ContentSettingsType::BRAVE_FINGERPRINTING_V2}}) {} }; class ShieldsHTTPSESetting : public ShieldsSetting { public: explicit ShieldsHTTPSESetting(BravePrefProvider* provider) - : ShieldsSetting(provider, - {{GURL(), brave_shields::kHTTPUpgradableResources}}) {} + : ShieldsSetting( + provider, + {{GURL(), ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES}}) {} }; class ShieldsAdsSetting : public ShieldsSetting { public: explicit ShieldsAdsSetting(BravePrefProvider* provider) : ShieldsSetting(provider, - {{GURL(), brave_shields::kAds}, - {GURL(), brave_shields::kTrackers}}) {} + {{GURL(), ContentSettingsType::BRAVE_ADS}, + {GURL(), ContentSettingsType::BRAVE_TRACKERS}}) {} }; class ShieldsEnabledSetting : public ShieldsSetting { public: explicit ShieldsEnabledSetting(BravePrefProvider* provider) - : ShieldsSetting(provider, {{GURL(), brave_shields::kBraveShields}}) {} -}; - -class ShieldsUnknownResourceIDSetting : public ShieldsSetting { - public: - explicit ShieldsUnknownResourceIDSetting(BravePrefProvider* provider) - : ShieldsSetting(provider, {{GURL(), "test_resource_id"}}) {} + : ShieldsSetting(provider, + {{GURL(), ContentSettingsType::BRAVE_SHIELDS}}) {} }; class ShieldsScriptSetting : public ShieldsSetting { @@ -132,7 +208,7 @@ class ShieldsScriptSetting : public ShieldsSetting { void SetPreMigrationSettings(const ContentSettingsPattern& pattern, ContentSetting setting) override { provider_->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", + ContentSettingsType::JAVASCRIPT, ContentSettingToValue(setting), {}); } @@ -140,7 +216,7 @@ class ShieldsScriptSetting : public ShieldsSetting { void CheckSettings(const GURL& url, ContentSetting setting) const override { EXPECT_EQ(setting, TestUtils::GetContentSetting( provider_, url, GURL(), - ContentSettingsType::JAVASCRIPT, "", false)); + ContentSettingsType::JAVASCRIPT, false)); } }; @@ -178,7 +254,6 @@ TEST_F(BravePrefProviderTest, TestShieldsSettingsMigration) { ShieldsAdsSetting ads_settings(&provider); ShieldsEnabledSetting enabled_settings(&provider); ShieldsScriptSetting script_settings(&provider); - ShieldsUnknownResourceIDSetting unknown_resource_id_settings(&provider); GURL url("http://brave.com:8080/"); GURL url2("http://allowed.brave.com:3030"); @@ -237,14 +312,6 @@ TEST_F(BravePrefProviderTest, TestShieldsSettingsMigration) { script_settings.CheckSettingsWouldBlock(url); script_settings.CheckSettingsAreDefault(GURL("http://brave.com:5555")); - // Unknown resource_id. - unknown_resource_id_settings.SetPreMigrationSettings(pattern, - CONTENT_SETTING_BLOCK); - // Check that settings would block brave.com:8080, but not brave.com:5555. - unknown_resource_id_settings.CheckSettingsWouldBlock(url); - unknown_resource_id_settings.CheckSettingsAreDefault( - GURL("http://brave.com:5555")); - // Migrate settings. // ------------------------------------------------------ testing_profile()->GetPrefs()->SetInteger(kBraveShieldsSettingsVersion, 1); @@ -305,12 +372,6 @@ TEST_F(BravePrefProviderTest, TestShieldsSettingsMigration) { // Would not block a different domain. script_settings.CheckSettingsAreDefault(GURL("http://brave2.com")); - // Unknown resource_id - should not have been migrated. - // Check that settings would block brave.com:8080, but not brave.com:5555. - unknown_resource_id_settings.CheckSettingsWouldBlock(url); - unknown_resource_id_settings.CheckSettingsAreDefault( - GURL("http://brave.com:5555")); - provider.ShutdownOnUIThread(); } @@ -320,7 +381,7 @@ TEST_F(BravePrefProviderTest, TestShieldsSettingsMigrationVersion) { true /* store_last_modified */, false /* restore_session */); - // Should have migrated when constrcuted (with profile). + // Should have migrated when constructed (with profile). EXPECT_EQ(2, prefs->GetInteger(kBraveShieldsSettingsVersion)); // Reset and check that migration runs. @@ -336,4 +397,79 @@ TEST_F(BravePrefProviderTest, TestShieldsSettingsMigrationVersion) { provider.ShutdownOnUIThread(); } +TEST_F(BravePrefProviderTest, TestShieldsSettingsMigrationFromResourceIDs) { + PrefService* pref_service = testing_profile()->GetPrefs(); + BravePrefProvider provider(pref_service, false /* incognito */, + true /* store_last_modified */, + false /* restore_session */); + + // Manually write settings under the PLUGINS type using the no longer existing + // ResourceIdentifier names, and then perform the migration. + prefs::ScopedDictionaryPrefUpdate plugins_pref_update( + pref_service, kUserProfilePluginsPath); + std::unique_ptr plugins_dictionary = + plugins_pref_update.Get(); + EXPECT_NE(plugins_dictionary, nullptr); + + base::Time expected_last_modified = base::Time::Now(); + + // Seed global shield settings with non-default values. + std::unique_ptr global_settings_dict = + plugins_dictionary->SetDictionaryWithoutPathExpansion( + "*,*", std::make_unique()); + + const int expected_global_settings_value = 1; + InitializeAllShieldSettingsInDictionary(global_settings_dict.get(), + expected_last_modified, + expected_global_settings_value); + + // Change all of those global settings for www.example.com. + std::unique_ptr example_settings_dict = + plugins_dictionary->SetDictionaryWithoutPathExpansion( + "www.example.com,*", std::make_unique()); + + const int expected_example_com_settings_value = 1; + InitializeAllShieldSettingsInDictionary(example_settings_dict.get(), + expected_last_modified, + expected_example_com_settings_value); + + // Disable Brave Shields for www.brave.com. + std::unique_ptr brave_settings_dict = + plugins_dictionary->SetDictionaryWithoutPathExpansion( + "www.brave.com,*", std::make_unique()); + + const int expected_brave_com_settings_value = 1; + InitializeBraveShieldsSettingInDictionary(brave_settings_dict.get(), + expected_last_modified, + expected_brave_com_settings_value); + + BravePrefProvider::CopyPluginSettingsForMigration(pref_service); + provider.MigrateShieldsSettingsFromResourceIds(); + + // Check migration for all the settings has been properly done. + for (auto content_type : GetShieldsContentSettingsTypes()) { + const base::DictionaryValue* brave_shields_dict = + pref_service->GetDictionary(GetShieldsSettingUserPrefsPath( + GetShieldsContentTypeName(content_type))); + EXPECT_NE(brave_shields_dict, nullptr); + + if (content_type == ContentSettingsType::BRAVE_SHIELDS) { + // We only changed the value of BRAVE_SHIELDS in www.brave.com. + CheckMigrationFromResourceIdentifierForDictionary( + brave_shields_dict, "www.brave.com,*", expected_last_modified, + expected_brave_com_settings_value); + } else { + // All the other settings we changed them globally and in www.example.com. + CheckMigrationFromResourceIdentifierForDictionary( + brave_shields_dict, "*,*", expected_last_modified, + expected_global_settings_value); + CheckMigrationFromResourceIdentifierForDictionary( + brave_shields_dict, "www.example.com,*", expected_last_modified, + expected_example_com_settings_value); + } + } + + provider.ShutdownOnUIThread(); +} + } // namespace content_settings diff --git a/components/content_settings/core/browser/brave_content_settings_utils.cc b/components/content_settings/core/browser/brave_content_settings_utils.cc index d9915f34dfb1..ad7022187f48 100644 --- a/components/content_settings/core/browser/brave_content_settings_utils.cc +++ b/components/content_settings/core/browser/brave_content_settings_utils.cc @@ -7,22 +7,24 @@ #include +#include "base/notreached.h" #include "base/optional.h" +#include "base/strings/string_number_conversions.h" +#include "base/values.h" #include "brave/components/brave_shields/common/brave_shield_constants.h" #include "url/gurl.h" namespace { -const std::vector kShieldsResourceIDs { - brave_shields::kAds, - brave_shields::kTrackers, - brave_shields::kCosmeticFiltering, - brave_shields::kHTTPUpgradableResources, - brave_shields::kJavaScript, - brave_shields::kFingerprintingV2, - brave_shields::kBraveShields, - brave_shields::kReferrers, - brave_shields::kCookies }; +const std::vector kShieldsContentSettingsTypes{ + ContentSettingsType::BRAVE_ADS, + ContentSettingsType::BRAVE_COSMETIC_FILTERING, + ContentSettingsType::BRAVE_TRACKERS, + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES, + ContentSettingsType::BRAVE_FINGERPRINTING_V2, + ContentSettingsType::BRAVE_SHIELDS, + ContentSettingsType::BRAVE_REFERRERS, + ContentSettingsType::BRAVE_COOKIES}; bool CanPatternBeConvertedToWildcardSchemeAndPort( const ContentSettingsPattern& pattern) { @@ -54,15 +56,49 @@ bool CanPatternBeConvertedToWildcardSchemeAndPort( namespace content_settings { -const std::vector& GetShieldsResourceIDs() { - return kShieldsResourceIDs; +const std::vector& GetShieldsContentSettingsTypes() { + return kShieldsContentSettingsTypes; } -bool IsShieldsResourceID( - const content_settings::ResourceIdentifier& resource_identifier) { - return std::find(kShieldsResourceIDs.begin(), - kShieldsResourceIDs.end(), - resource_identifier) != kShieldsResourceIDs.end(); +std::string GetShieldsContentTypeName(const ContentSettingsType& content_type) { + switch (content_type) { + case ContentSettingsType::BRAVE_ADS: + return brave_shields::kAds; + break; + case ContentSettingsType::BRAVE_COSMETIC_FILTERING: + return brave_shields::kCosmeticFiltering; + break; + case ContentSettingsType::BRAVE_TRACKERS: + return brave_shields::kTrackers; + break; + case ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES: + return brave_shields::kHTTPUpgradableResources; + break; + case ContentSettingsType::BRAVE_FINGERPRINTING_V2: + return brave_shields::kFingerprintingV2; + break; + case ContentSettingsType::BRAVE_SHIELDS: + return brave_shields::kBraveShields; + break; + case ContentSettingsType::BRAVE_REFERRERS: + return brave_shields::kReferrers; + break; + case ContentSettingsType::BRAVE_COOKIES: + return brave_shields::kCookies; + break; + default: + NOTREACHED(); + return std::string(); + } + + NOTREACHED(); + return std::string(); +} + +bool IsShieldsContentSettingsType(const ContentSettingsType& content_type) { + return std::find(kShieldsContentSettingsTypes.begin(), + kShieldsContentSettingsTypes.end(), + content_type) != kShieldsContentSettingsTypes.end(); } base::Optional ConvertPatternToWildcardSchemeAndPort( @@ -75,4 +111,41 @@ base::Optional ConvertPatternToWildcardSchemeAndPort( return new_pattern; } +// Returns the full path in the user preferences store to the Brave Shields +// setting identified by it's name (i.e. |name|). +std::string GetShieldsSettingUserPrefsPath(const std::string& name) { + return std::string("profile.content_settings.exceptions.").append(name); +} + +// Extract a timestamp from |dictionary[key]|. Will return base::Time() if no +// timestamp exists. +base::Time GetTimeStampFromDictionary(const base::DictionaryValue* dictionary, + const char* key) { + std::string timestamp_str; + dictionary->GetStringWithoutPathExpansion(key, ×tamp_str); + int64_t timestamp = 0; + base::StringToInt64(timestamp_str, ×tamp); + base::Time last_modified = base::Time::FromDeltaSinceWindowsEpoch( + base::TimeDelta::FromMicroseconds(timestamp)); + return last_modified; +} + +// Extract a SessionModel from |dictionary[key]|. Will return +// SessionModel::Durable if no model exists. +content_settings::SessionModel GetSessionModelFromDictionary( + const base::DictionaryValue* dictionary, + const char* key) { + int model_int = 0; + dictionary->GetIntegerWithoutPathExpansion(key, &model_int); + if ((model_int > + static_cast(content_settings::SessionModel::kMaxValue)) || + (model_int < 0)) { + model_int = 0; + } + + content_settings::SessionModel session_model = + static_cast(model_int); + return session_model; +} + } // namespace content_settings diff --git a/components/content_settings/core/browser/brave_content_settings_utils.h b/components/content_settings/core/browser/brave_content_settings_utils.h index 9cd5f0e17e00..99f45d5af824 100644 --- a/components/content_settings/core/browser/brave_content_settings_utils.h +++ b/components/content_settings/core/browser/brave_content_settings_utils.h @@ -9,17 +9,31 @@ #include #include +#include "base/time/time.h" #include "components/content_settings/core/common/content_settings.h" +#include "components/content_settings/core/common/content_settings_constraints.h" +#include "components/content_settings/core/common/content_settings_types.h" namespace content_settings { -const std::vector& GetShieldsResourceIDs(); +const std::vector& GetShieldsContentSettingsTypes(); -bool IsShieldsResourceID(const ResourceIdentifier& resource_identifier); +std::string GetShieldsContentTypeName(const ContentSettingsType& content_type); + +bool IsShieldsContentSettingsType(const ContentSettingsType& content_type); base::Optional ConvertPatternToWildcardSchemeAndPort( const ContentSettingsPattern& pattern); +std::string GetShieldsSettingUserPrefsPath(const std::string& name); + +base::Time GetTimeStampFromDictionary(const base::DictionaryValue* dictionary, + const char* key); + +content_settings::SessionModel GetSessionModelFromDictionary( + const base::DictionaryValue* dictionary, + const char* key); + } // namespace content_settings #endif // BRAVE_COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_BRAVE_CONTENT_SETTINGS_UTILS_H_ diff --git a/components/content_settings/core/common/content_settings_util.cc b/components/content_settings/core/common/content_settings_util.cc index a2fa15dae2e5..cf52b64d275b 100644 --- a/components/content_settings/core/common/content_settings_util.cc +++ b/components/content_settings/core/common/content_settings_util.cc @@ -13,25 +13,26 @@ namespace content_settings { -ContentSetting GetDefaultFromResourceIdentifier( - const std::string& resource_identifier, +ContentSetting GetDefaultFromContentSettingsType( + const ContentSettingsType& content_type, const GURL& primary_url, const GURL& secondary_url) { - if (resource_identifier == brave_shields::kAds) { + if (content_type == ContentSettingsType::ADS) { return CONTENT_SETTING_BLOCK; - } else if (resource_identifier == brave_shields::kCosmeticFiltering) { + } else if (content_type == ContentSettingsType::BRAVE_COSMETIC_FILTERING) { return secondary_url == GURL("https://firstParty/") ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; - } else if (resource_identifier == brave_shields::kTrackers) { + } else if (content_type == ContentSettingsType::BRAVE_TRACKERS) { return CONTENT_SETTING_BLOCK; - } else if (resource_identifier == brave_shields::kHTTPUpgradableResources) { + } else if (content_type == + ContentSettingsType::BRAVE_HTTP_UPGRADABLE_RESOURCES) { return CONTENT_SETTING_BLOCK; - } else if (resource_identifier == brave_shields::kBraveShields) { + } else if (content_type == ContentSettingsType::BRAVE_SHIELDS) { return CONTENT_SETTING_ALLOW; - } else if (resource_identifier == brave_shields::kReferrers) { + } else if (content_type == ContentSettingsType::BRAVE_REFERRERS) { return CONTENT_SETTING_BLOCK; - } else if (resource_identifier == brave_shields::kCookies) { + } else if (content_type == ContentSettingsType::BRAVE_COOKIES) { return secondary_url == GURL("https://firstParty/") ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW; @@ -42,11 +43,9 @@ ContentSetting GetDefaultFromResourceIdentifier( bool IsAllowContentSetting(const ContentSettingsForOneType& content_settings, const GURL& primary_url, const GURL& secondary_url, - const std::string& resource_identifier) { - ContentSetting setting = - GetDefaultFromResourceIdentifier(resource_identifier, - primary_url, - secondary_url); + const ContentSettingsType& content_type) { + ContentSetting setting = GetDefaultFromContentSettingsType( + content_type, primary_url, secondary_url); for (const auto& entry : content_settings) { if (entry.primary_pattern.Matches(primary_url) && diff --git a/components/content_settings/core/common/content_settings_util.h b/components/content_settings/core/common/content_settings_util.h index 9fae569dc20b..49e10c662291 100644 --- a/components/content_settings/core/common/content_settings_util.h +++ b/components/content_settings/core/common/content_settings_util.h @@ -14,15 +14,15 @@ namespace content_settings { -ContentSetting GetDefaultFromResourceIdentifier( - const std::string& resource_identifier, +ContentSetting GetDefaultFromContentSettingsType( + const ContentSettingsType& content_type, const GURL& primary_url, const GURL& secondary_url); bool IsAllowContentSetting(const ContentSettingsForOneType& content_settings, const GURL& primary_url, const GURL& secondary_url, - const std::string& resource_identifier); + const ContentSettingsType& content_type); } // namespace content_settings diff --git a/components/content_settings/renderer/brave_content_settings_agent_impl.cc b/components/content_settings/renderer/brave_content_settings_agent_impl.cc index 5be16861b636..4615cbe60283 100644 --- a/components/content_settings/renderer/brave_content_settings_agent_impl.cc +++ b/components/content_settings/renderer/brave_content_settings_agent_impl.cc @@ -10,7 +10,7 @@ #include #include -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/feature_list.h" #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" diff --git a/components/content_settings/renderer/brave_content_settings_agent_impl_browsertest.cc b/components/content_settings/renderer/brave_content_settings_agent_impl_browsertest.cc index 9e805e6482b2..1a9b0a3f9f58 100644 --- a/components/content_settings/renderer/brave_content_settings_agent_impl_browsertest.cc +++ b/components/content_settings/renderer/brave_content_settings_agent_impl_browsertest.cc @@ -217,22 +217,20 @@ class BraveContentSettingsAgentImplBrowserTest : public InProcessBrowserTest { void BlockReferrers() { content_settings()->SetContentSettingCustomScope( top_level_page_pattern(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kReferrers, - CONTENT_SETTING_BLOCK); + ContentSettingsType::BRAVE_REFERRERS, CONTENT_SETTING_BLOCK); ContentSettingsForOneType settings; content_settings()->GetSettingsForOneType( - ContentSettingsType::PLUGINS, brave_shields::kReferrers, &settings); + ContentSettingsType::BRAVE_REFERRERS, &settings); EXPECT_EQ(settings.size(), 1u); } void AllowReferrers() { content_settings()->SetContentSettingCustomScope( top_level_page_pattern(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::PLUGINS, brave_shields::kReferrers, - CONTENT_SETTING_ALLOW); + ContentSettingsType::BRAVE_REFERRERS, CONTENT_SETTING_ALLOW); ContentSettingsForOneType settings; content_settings()->GetSettingsForOneType( - ContentSettingsType::PLUGINS, brave_shields::kReferrers, &settings); + ContentSettingsType::BRAVE_REFERRERS, &settings); EXPECT_EQ(settings.size(), 1u); } @@ -579,7 +577,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentSettingsAgentImplBrowserTest, BlockReferrerByDefault) { ContentSettingsForOneType settings; content_settings()->GetSettingsForOneType( - ContentSettingsType::PLUGINS, brave_shields::kReferrers, &settings); + ContentSettingsType::BRAVE_REFERRERS, &settings); EXPECT_EQ(settings.size(), 0u) << "There should not be any visible referrer rules."; @@ -634,7 +632,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentSettingsAgentImplBrowserTest, BlockReferrerByDefaultRedirects) { ContentSettingsForOneType settings; content_settings()->GetSettingsForOneType( - ContentSettingsType::PLUGINS, brave_shields::kReferrers, &settings); + ContentSettingsType::BRAVE_REFERRERS, &settings); EXPECT_EQ(settings.size(), 0u) << "There should not be any visible referrer rules."; @@ -925,7 +923,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentSettingsAgentImplBrowserTest, HostContentSettingsMapFactory::GetForProfile(browser()->profile()); content_settings->SetContentSettingCustomScope( top_level_page_pattern(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::COOKIES, std::string(), CONTENT_SETTING_BLOCK); + ContentSettingsType::COOKIES, CONTENT_SETTING_BLOCK); NavigateToPageWithIframe(); CheckCookie(contents(), kEmptyCookie); @@ -941,7 +939,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentSettingsAgentImplBrowserTest, HostContentSettingsMapFactory::GetForProfile(browser()->profile()); content_settings->SetContentSettingCustomScope( iframe_pattern(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::COOKIES, std::string(), CONTENT_SETTING_BLOCK); + ContentSettingsType::COOKIES, CONTENT_SETTING_BLOCK); NavigateToPageWithIframe(); CheckCookie(contents(), kTestCookie); @@ -1068,7 +1066,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentSettingsAgentImplBrowserTest, // Block scripts in b.com. content_settings()->SetContentSettingCustomScope( iframe_pattern(), ContentSettingsPattern::Wildcard(), - ContentSettingsType::JAVASCRIPT, "", CONTENT_SETTING_BLOCK); + ContentSettingsType::JAVASCRIPT, CONTENT_SETTING_BLOCK); NavigateToURLUntilLoadStop("b.com", "/load_js_from_origins.html"); EXPECT_EQ(contents()->GetAllFrames().size(), 1u); diff --git a/components/definitions/chromel.d.ts b/components/definitions/chromel.d.ts index c1e3615378e3..0fa9d01b6e9f 100644 --- a/components/definitions/chromel.d.ts +++ b/components/definitions/chromel.d.ts @@ -236,7 +236,7 @@ declare namespace chrome.braveToday { } } -type BlockTypes = 'ads' | 'trackers' | 'httpUpgradableResources' | 'javascript' | 'fingerprinting' +type BlockTypes = 'shieldsAds' | 'trackers' | 'httpUpgradableResources' | 'javascript' | 'fingerprinting' interface BlockDetails { blockType: BlockTypes diff --git a/components/error_page_strings.grdp b/components/error_page_strings.grdp index 0f4808867245..bb778803f753 100644 --- a/components/error_page_strings.grdp +++ b/components/error_page_strings.grdp @@ -369,5 +369,15 @@ If spelling is correct, <a href="javascript:diagnoseErrors()" id="diagnose-link">try running Connectivity Diagnostics</a>. + + + Tap the dino to play + + + + + Press space to play + + diff --git a/components/error_page_strings_override.grdp b/components/error_page_strings_override.grdp index 8944c7cdd56e..e94a7f57f0e0 100644 --- a/components/error_page_strings_override.grdp +++ b/components/error_page_strings_override.grdp @@ -30,5 +30,9 @@ + + + + diff --git a/components/greaselion/browser/greaselion_service_impl.cc b/components/greaselion/browser/greaselion_service_impl.cc index df1f9edf45a3..a9b07328f723 100644 --- a/components/greaselion/browser/greaselion_service_impl.cc +++ b/components/greaselion/browser/greaselion_service_impl.cc @@ -13,7 +13,7 @@ #include "base/base64.h" #include "base/bind.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/command_line.h" #include "base/feature_list.h" #include "base/files/file_path.h" @@ -36,6 +36,7 @@ #include "crypto/sha2.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" +#include "extensions/common/api/content_scripts.h" #include "extensions/common/constants.h" #include "extensions/common/extension.h" #include "extensions/common/file_util.h" @@ -47,6 +48,8 @@ using extensions::Manifest; namespace { +constexpr char kRunAtDocumentStart[] = "document_start"; + // Wraps a Greaselion rule in a component. The component is stored as // an unpacked extension in the user data dir. Returns a valid // extension that the caller should take ownership of, or nullptr. @@ -106,31 +109,32 @@ scoped_refptr ConvertGreaselionRuleToExtensionOnTaskRunner( root->SetStringPath(extensions::manifest_keys::kDescription, ""); root->SetStringPath(extensions::manifest_keys::kPublicKey, key); - auto js_files = std::make_unique(); - for (auto script : rule->scripts()) - js_files->AppendString(script.BaseName().value()); - - auto matches = std::make_unique(); + std::vector matches; + matches.reserve(rule->url_patterns().size()); for (auto url_pattern : rule->url_patterns()) - matches->AppendString(url_pattern); + matches.push_back(url_pattern); + + extensions::api::content_scripts::ContentScript content_script; + content_script.matches = std::move(matches); + + content_script.js = std::make_unique>(); + for (auto script : rule->scripts()) + content_script.js->push_back(script.BaseName().AsUTF8Unsafe()); - auto content_script = std::make_unique(); - content_script->Set(extensions::manifest_keys::kMatches, std::move(matches)); - content_script->Set(extensions::manifest_keys::kJs, std::move(js_files)); // All Greaselion scripts default to document end. - content_script->SetStringPath(extensions::manifest_keys::kRunAt, - rule->run_at() == extensions::manifest_values::kRunAtDocumentStart - ? extensions::manifest_values::kRunAtDocumentStart - : extensions::manifest_values::kRunAtDocumentEnd); + content_script.run_at = + rule->run_at() == kRunAtDocumentStart + ? extensions::api::content_scripts::RUN_AT_DOCUMENT_START + : extensions::api::content_scripts::RUN_AT_DOCUMENT_END; if (!rule->messages().empty()) { root->SetStringPath(extensions::manifest_keys::kDefaultLocale, "en_US"); } auto content_scripts = std::make_unique(); - content_scripts->Append(std::move(content_script)); + content_scripts->Append(content_script.ToValue()); - root->Set(extensions::manifest_keys::kContentScripts, + root->Set(extensions::api::content_scripts::ManifestKeys::kContentScripts, std::move(content_scripts)); base::FilePath manifest_path = diff --git a/components/ipfs/ipfs_navigation_throttle_unittest.cc b/components/ipfs/ipfs_navigation_throttle_unittest.cc index 3e0bda733087..08a473d80edd 100644 --- a/components/ipfs/ipfs_navigation_throttle_unittest.cc +++ b/components/ipfs/ipfs_navigation_throttle_unittest.cc @@ -9,7 +9,7 @@ #include #include -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/scoped_feature_list.h" #include "brave/browser/ipfs/ipfs_service_factory.h" #include "brave/components/ipfs/features.h" diff --git a/components/ipfs/translate_ipfs_uri_unittest.cc b/components/ipfs/translate_ipfs_uri_unittest.cc index 38d3bd182bba..dddd8ef10375 100644 --- a/components/ipfs/translate_ipfs_uri_unittest.cc +++ b/components/ipfs/translate_ipfs_uri_unittest.cc @@ -8,7 +8,7 @@ #include #include -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "brave/browser/ipfs/ipfs_service_factory.h" #include "brave/components/ipfs/ipfs_constants.h" #include "brave/components/ipfs/ipfs_service.h" diff --git a/components/network_time/network_time_tracker_unittest.cc b/components/network_time/network_time_tracker_unittest.cc index 806978f22538..ced162c61bee 100644 --- a/components/network_time/network_time_tracker_unittest.cc +++ b/components/network_time/network_time_tracker_unittest.cc @@ -13,10 +13,10 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/stringprintf.h" -#include "base/test/bind_test_util.h" -#include "base/test/task_environment.h" +#include "base/test/bind.h" #include "base/test/simple_test_clock.h" #include "base/test/simple_test_tick_clock.h" +#include "base/test/task_environment.h" #include "components/client_update_protocol/ecdsa.h" #include "components/network_time/network_time_pref_names.h" #include "components/network_time/network_time_test_utils.h" diff --git a/components/omnibox_strings.grdp b/components/omnibox_strings.grdp index 43751f4fedae..ebcd1a56c3a2 100644 --- a/components/omnibox_strings.grdp +++ b/components/omnibox_strings.grdp @@ -252,7 +252,7 @@ $1The Brave Projects http://www.chromium.org bookmark, multiple actions are available, press Tab to cycle through them - + $1The Brave Projects http://www.chromium.org bookmark, press Tab then Enter to search @@ -260,6 +260,9 @@ + + $1The Brave Projects http://www.chromium.org bookmark, press Tab then Enter to Remove Suggestion. + Remove Suggestion button, press Enter to remove, $1The Brave Projects http://www.chromium.org bookmark diff --git a/components/page_info_strings.grdp b/components/page_info_strings.grdp index fd52bdadb2ab..314b2ad57ad4 100644 --- a/components/page_info_strings.grdp +++ b/components/page_info_strings.grdp @@ -49,9 +49,6 @@ Suspicious site - - This site could be fake or fraudulent. Brave recommends leaving now. - Leave site @@ -64,7 +61,7 @@ Did you mean $1google.com? - + Attackers sometimes mimic sites by making hard-to-see changes to the web address. @@ -336,6 +333,9 @@ Allow + + Only this time + Block diff --git a/components/pdf_strings.grdp b/components/pdf_strings.grdp index db4809f6e9cb..f8e8ba089412 100644 --- a/components/pdf_strings.grdp +++ b/components/pdf_strings.grdp @@ -8,6 +8,9 @@ With your changes + + Full screen + This document is password protected. Please enter a password. diff --git a/components/permissions_strings.grdp b/components/permissions_strings.grdp index 6f0836d44b95..98303a1e8017 100644 --- a/components/permissions_strings.grdp +++ b/components/permissions_strings.grdp @@ -135,6 +135,15 @@ This will otherwise be blocked by your privacy settings. This will allow the con Block + + Only this time + + + On every visit + + + Allow $1google.com to: + diff --git a/components/policy_strings.grdp b/components/policy_strings.grdp index 8994a70595eb..5c6addd93a26 100644 --- a/components/policy_strings.grdp +++ b/components/policy_strings.grdp @@ -592,5 +592,17 @@ Additional details: Printing of this content is blocked by your administrator. + + Screen capture paused + + + Screen capture was paused by your administrator due to content on your screen. + + + Screen capture resumed + + + Screen capture was resumed. + diff --git a/components/rappor/log_uploader_unittest.cc b/components/rappor/log_uploader_unittest.cc index 56591a61e6f8..739c82a8482f 100644 --- a/components/rappor/log_uploader_unittest.cc +++ b/components/rappor/log_uploader_unittest.cc @@ -7,7 +7,7 @@ #include "base/macros.h" #include "base/run_loop.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h" #include "services/network/public/cpp/shared_url_loader_factory.h" diff --git a/components/sync/driver/brave_sync_auth_manager_unittest.cc b/components/sync/driver/brave_sync_auth_manager_unittest.cc index cb68b537eff5..df55ae734629 100644 --- a/components/sync/driver/brave_sync_auth_manager_unittest.cc +++ b/components/sync/driver/brave_sync_auth_manager_unittest.cc @@ -7,7 +7,7 @@ #include -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/test/mock_callback.h" #include "base/test/task_environment.h" #include "brave/common/network_constants.h" diff --git a/components/test/brave_extension/actions/shieldsPanelActions_test.ts b/components/test/brave_extension/actions/shieldsPanelActions_test.ts index 2aaa748ac565..2fa377a78072 100644 --- a/components/test/brave_extension/actions/shieldsPanelActions_test.ts +++ b/components/test/brave_extension/actions/shieldsPanelActions_test.ts @@ -60,7 +60,7 @@ describe('shieldsPanelActions', () => { it('resourceBlocked action', () => { const details: BlockDetails = { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 2, subresource: 'https://www.brave.com/test' } diff --git a/components/test/brave_extension/background/reducers/shieldsPanelReducer_test.ts b/components/test/brave_extension/background/reducers/shieldsPanelReducer_test.ts index 4f6315230919..396532cc8bb8 100644 --- a/components/test/brave_extension/background/reducers/shieldsPanelReducer_test.ts +++ b/components/test/brave_extension/background/reducers/shieldsPanelReducer_test.ts @@ -544,7 +544,7 @@ describe('braveShieldsPanelReducer', () => { let nextState = shieldsPanelReducer(state, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 2, subresource: 'https://test.brave.com' } @@ -564,7 +564,7 @@ describe('braveShieldsPanelReducer', () => { nextState = shieldsPanelReducer(nextState, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 2, subresource: 'https://test2.brave.com' } @@ -589,7 +589,7 @@ describe('braveShieldsPanelReducer', () => { let nextState = shieldsPanelReducer(state, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: tabId, subresource: 'https://test.brave.com' } @@ -601,7 +601,7 @@ describe('braveShieldsPanelReducer', () => { nextState = shieldsPanelReducer(nextState, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: tabId, subresource: 'https://test2.brave.com' } @@ -616,7 +616,7 @@ describe('braveShieldsPanelReducer', () => { nextState = shieldsPanelReducer(nextState, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: tabId, subresource: 'https://test2.brave.com' } @@ -632,7 +632,7 @@ describe('braveShieldsPanelReducer', () => { let nextState = deepFreeze(shieldsPanelReducer(state, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 2, subresource: 'https://test.brave.com' } @@ -654,7 +654,7 @@ describe('braveShieldsPanelReducer', () => { nextState = shieldsPanelReducer(nextState, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 3, subresource: 'https://test.brave.com' } @@ -688,7 +688,7 @@ describe('braveShieldsPanelReducer', () => { let nextState = deepFreeze(shieldsPanelReducer(state, { type: types.RESOURCE_BLOCKED, details: { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 2, subresource: 'https://test.brave.com' } diff --git a/components/test/brave_extension/state/shieldsPanelState_test.ts b/components/test/brave_extension/state/shieldsPanelState_test.ts index 9bf7854ff030..0c81d64046a3 100644 --- a/components/test/brave_extension/state/shieldsPanelState_test.ts +++ b/components/test/brave_extension/state/shieldsPanelState_test.ts @@ -272,7 +272,7 @@ describe('shieldsPanelState test', () => { describe('updateResourceBlocked', () => { it('can update ads blocked count', () => { this.tabId = 2 - expect(shieldsPanelState.updateResourceBlocked(state, this.tabId, 'ads', 'https://test.brave.com')).toEqual({ + expect(shieldsPanelState.updateResourceBlocked(state, this.tabId, 'shieldsAds', 'https://test.brave.com')).toEqual({ ...state, tabs: { ...state.tabs, diff --git a/components/test/testData.ts b/components/test/testData.ts index 6e88d65cd6a2..854b0bd89f36 100644 --- a/components/test/testData.ts +++ b/components/test/testData.ts @@ -97,7 +97,7 @@ export const tabs: Tabs = { export const activeTabData = tabs[2] export const blockedResource: BlockDetails = { - blockType: 'ads', + blockType: 'shieldsAds', tabId: 2, subresource: 'https://www.brave.com/test' } diff --git a/components/tor/tor_control.cc b/components/tor/tor_control.cc index ee29add92d3b..c3557126301e 100644 --- a/components/tor/tor_control.cc +++ b/components/tor/tor_control.cc @@ -5,7 +5,7 @@ #include "brave/components/tor/tor_control.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/files/file.h" #include "base/files/file_path_watcher.h" #include "base/sequenced_task_runner.h" diff --git a/components/tor/tor_control_unittest.cc b/components/tor/tor_control_unittest.cc index 03ee4bbff369..48e83932a09d 100644 --- a/components/tor/tor_control_unittest.cc +++ b/components/tor/tor_control_unittest.cc @@ -5,8 +5,8 @@ #include "brave/components/tor/tor_control.h" +#include "base/callback_helpers.h" #include "base/run_loop.h" -#include "base/bind_helpers.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/browser_task_environment.h" diff --git a/components/translate/core/browser/translate_language_list_unittest.cc b/components/translate/core/browser/translate_language_list_unittest.cc index 5abe6cb32884..c3ea4acdff77 100644 --- a/components/translate/core/browser/translate_language_list_unittest.cc +++ b/components/translate/core/browser/translate_language_list_unittest.cc @@ -9,7 +9,7 @@ #include #include "base/run_loop.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/task_environment.h" #include "brave/browser/translate/buildflags/buildflags.h" #include "components/translate/core/browser/translate_download_manager.h" diff --git a/ios/browser/api/bookmarks/exporter/brave_bookmarks_exporter.mm b/ios/browser/api/bookmarks/exporter/brave_bookmarks_exporter.mm index e7de4a4a2e21..b28e4886b288 100644 --- a/ios/browser/api/bookmarks/exporter/brave_bookmarks_exporter.mm +++ b/ios/browser/api/bookmarks/exporter/brave_bookmarks_exporter.mm @@ -11,7 +11,7 @@ #include "base/base_paths.h" #include "base/bind.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/mac/foundation_util.h" @@ -145,7 +145,7 @@ - (void)exportToFile:(NSString*)filePath listener(BraveBookmarksExporterStateStarted); base::FilePath destination_file_path = base::mac::NSStringToFilePath(filePath); - + // Create artificial nodes auto bookmark_bar_node = [exporter getBookmarksBarNode]; auto other_folder_node = [exporter getOtherBookmarksNode]; diff --git a/ios/browser/api/bookmarks/importer/bookmarks_importer.cc b/ios/browser/api/bookmarks/importer/bookmarks_importer.cc index ca390e2e7d6e..a5cdb8ca7925 100644 --- a/ios/browser/api/bookmarks/importer/bookmarks_importer.cc +++ b/ios/browser/api/bookmarks/importer/bookmarks_importer.cc @@ -9,7 +9,7 @@ #include "base/base_paths.h" #include "base/bind.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/files/file_path.h" #include "base/path_service.h" #include "base/strings/string_number_conversions.h" diff --git a/ios/browser/api/bookmarks/importer/brave_bookmarks_importer.mm b/ios/browser/api/bookmarks/importer/brave_bookmarks_importer.mm index e346e65f3060..15b842e06258 100644 --- a/ios/browser/api/bookmarks/importer/brave_bookmarks_importer.mm +++ b/ios/browser/api/bookmarks/importer/brave_bookmarks_importer.mm @@ -9,7 +9,7 @@ #include "base/base_paths.h" #include "base/bind.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/mac/foundation_util.h" diff --git a/patches/base-BUILD.gn.patch b/patches/base-BUILD.gn.patch index f269c5638ffe..ae0b6efc7565 100644 --- a/patches/base-BUILD.gn.patch +++ b/patches/base-BUILD.gn.patch @@ -1,8 +1,8 @@ diff --git a/base/BUILD.gn b/base/BUILD.gn -index 5bc48a734b4b85a0e30a2570aa4ff6f776f40a69..e63c1286eef96edc30d7e25e2b5afc1abe9a5400 100644 +index 632d70d0a04ede980c6b8fde6a46ae417017c369..877071f5a0df76feb711662bf1e3192cf28c4604 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn -@@ -3746,6 +3746,7 @@ if (is_android) { +@@ -3754,6 +3754,7 @@ if (is_android) { "android/java/src/org/chromium/base/task/TaskTraits.java", "android/java/src/org/chromium/base/task/TaskTraitsExtensionDescriptor.java", ] diff --git a/patches/build-config-android-config.gni.patch b/patches/build-config-android-config.gni.patch index 30f4aef1c068..512e89d89b17 100644 --- a/patches/build-config-android-config.gni.patch +++ b/patches/build-config-android-config.gni.patch @@ -1,5 +1,5 @@ diff --git a/build/config/android/config.gni b/build/config/android/config.gni -index 4c363465c3c7a153c7934ba99b665435d8fdaf12..25e1033577f9821d0e6fce4d87d49aac2aea57d9 100644 +index bc176d5e0317dd4dab9c1e1bfcf20955c254674f..bec1208b56ef9bca7a785dd6d186cd3af59ac3d1 100644 --- a/build/config/android/config.gni +++ b/build/config/android/config.gni @@ -7,6 +7,7 @@ diff --git a/patches/build-config-android-internal_rules.gni.patch b/patches/build-config-android-internal_rules.gni.patch index d41683b4bf2f..3dc24219401b 100644 --- a/patches/build-config-android-internal_rules.gni.patch +++ b/patches/build-config-android-internal_rules.gni.patch @@ -1,8 +1,8 @@ diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni -index c01294f793e85040bc3d258c277cb82869609eb8..a91d163dafe8c60c41b20ad9601542b364c4c664 100644 +index f79f26ef501ed326c56b070dbe2cc993d2f858b0..0a2da0edc7823bdf036b57f98e24e1aa7904d70d 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni -@@ -2023,6 +2023,7 @@ if (enable_java_templates) { +@@ -2072,6 +2072,7 @@ if (enable_java_templates) { _deps = [ ":$_desugar_target" ] _previous_output_jar = _desugar_output_jar } diff --git a/patches/build-config-android-rules.gni.patch b/patches/build-config-android-rules.gni.patch index 7dc652e9fd9e..0febbb021a24 100644 --- a/patches/build-config-android-rules.gni.patch +++ b/patches/build-config-android-rules.gni.patch @@ -1,11 +1,11 @@ diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni -index 588b619121a62905a0b056b1a4640f3d62446c4b..d68609ee34a09075d3b48eb36dadccab63e9d644 100644 +index 78d1eb7155739ef2986bac6485f7a3acee4c272a..061c96e49f5ef4977b8bc54ca9c0201c59c93d3b 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni -@@ -509,6 +509,7 @@ if (enable_java_templates) { +@@ -472,6 +472,7 @@ if (enable_java_templates) { + # ] # } template("java_cpp_enum") { - set_sources_assignment_filter([]) + foreach(source, invoker.sources) { foreach(filter, brave_java_cpp_enum_filter) { if(source == filter) { invoker.sources -= [filter] }}} action_with_pydeps(target_name) { forward_variables_from(invoker, @@ -16,5 +16,5 @@ index 588b619121a62905a0b056b1a4640f3d62446c4b..d68609ee34a09075d3b48eb36dadccab template("jinja_template") { + if (defined(invoker.includes)) { invoker.includes += brave_android_manifest_includes } else { invoker.includes = brave_android_manifest_includes } action_with_pydeps(target_name) { - forward_variables_from(invoker, - [ + # TODO(crbug.com/1112471): Get this to run cleanly under Python 3. + run_under_python2 = true diff --git a/patches/build-config-compiler-BUILD.gn.patch b/patches/build-config-compiler-BUILD.gn.patch index d448011ac9f7..8e116c6baa68 100644 --- a/patches/build-config-compiler-BUILD.gn.patch +++ b/patches/build-config-compiler-BUILD.gn.patch @@ -1,8 +1,8 @@ diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn -index ed3d81786b0dd16f998ece213f7cd66723bed5fb..84b1e1aac1b113688f4b6bd527be846db2a8aee1 100644 +index 9d66490cdb555a6114d71b156a32b2fd7a32591f..ca637f0f50bb5b750f82c3a9507ccf6e6a74f186 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn -@@ -1670,6 +1670,7 @@ config("chromium_code") { +@@ -1645,6 +1645,7 @@ config("chromium_code") { cflags += [ "-Wextra-semi" ] } } diff --git a/patches/build-toolchain-win-setup_toolchain.py.patch b/patches/build-toolchain-win-setup_toolchain.py.patch index a4a4e54fd411..1956e8b933ee 100644 --- a/patches/build-toolchain-win-setup_toolchain.py.patch +++ b/patches/build-toolchain-win-setup_toolchain.py.patch @@ -1,5 +1,5 @@ diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py -index 58bf3e8caf4e0a0fdcba03c5b8bf72b30ea8f075..b504e562355cc2468a1c661a4daec983e68dfb6a 100644 +index 47309866ca790e6753d20cdd097cce9ee2b3f57b..99e676117f6f60ef06fb84162ecea7d0efdf614b 100644 --- a/build/toolchain/win/setup_toolchain.py +++ b/build/toolchain/win/setup_toolchain.py @@ -277,6 +277,7 @@ def main(): diff --git a/patches/chrome-BUILD.gn.patch b/patches/chrome-BUILD.gn.patch index 88e9041a697d..fd9500427b12 100644 --- a/patches/chrome-BUILD.gn.patch +++ b/patches/chrome-BUILD.gn.patch @@ -1,5 +1,5 @@ diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn -index a1f8f46f3055f412aff2a883b5e8ca3d609468cf..3ffae4dcc3fb330c75b80ede23b26721c31746c4 100644 +index f721f1aff4781fa5936010dfb5b0c97587e81c05..8476c12cd97d3f01974b574a1ff137fdcc11969e 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -150,6 +150,10 @@ if (!is_android && !is_mac) { @@ -73,7 +73,7 @@ index a1f8f46f3055f412aff2a883b5e8ca3d609468cf..3ffae4dcc3fb330c75b80ede23b26721 extra_substitutions = [ "CHROMIUM_BUNDLE_ID=$chrome_mac_bundle_id", "CHROMIUM_SHORT_NAME=$chrome_product_short_name", -@@ -1019,6 +1028,10 @@ if (is_win) { +@@ -1033,6 +1042,10 @@ if (is_win) { if (is_chrome_branded) { deps += [ ":default_apps" ] } @@ -84,7 +84,7 @@ index a1f8f46f3055f412aff2a883b5e8ca3d609468cf..3ffae4dcc3fb330c75b80ede23b26721 ldflags = [ "-Wl,-install_name,@executable_path/../Frameworks/$chrome_framework_name.framework/Versions/$chrome_version_full/$chrome_framework_name" ] -@@ -1176,6 +1189,7 @@ if (is_win) { +@@ -1190,6 +1203,7 @@ if (is_win) { group("browser_dependencies") { public_deps = [ @@ -92,7 +92,7 @@ index a1f8f46f3055f412aff2a883b5e8ca3d609468cf..3ffae4dcc3fb330c75b80ede23b26721 "//build:branding_buildflags", "//build:chromeos_buildflags", "//chrome/app:shutdown_signal_handlers", -@@ -1276,12 +1290,13 @@ group("child_dependencies") { +@@ -1290,12 +1304,13 @@ group("child_dependencies") { # this is OK because all of content is linked into one library. "//content/browser", ] @@ -107,7 +107,7 @@ index a1f8f46f3055f412aff2a883b5e8ca3d609468cf..3ffae4dcc3fb330c75b80ede23b26721 output = "$target_gen_dir/chrome_exe_version.rc" } -@@ -1335,6 +1350,7 @@ group("resources") { +@@ -1349,6 +1364,7 @@ group("resources") { "//chrome/browser:resources", "//chrome/common:resources", "//chrome/renderer:resources", diff --git a/patches/chrome-VERSION.patch b/patches/chrome-VERSION.patch index 5d2638a994e1..12ebd4d62d69 100644 --- a/patches/chrome-VERSION.patch +++ b/patches/chrome-VERSION.patch @@ -1,12 +1,12 @@ diff --git a/chrome/VERSION b/chrome/VERSION -index af426b76bedc2ec8bc50af7d76e78dcaaea67550..5bb5d44b5747c886fb2cb497f62d14b050a04fa6 100644 +index afd73f87c276497d26af701b1475311a7330d6a2..5bb5d44b5747c886fb2cb497f62d14b050a04fa6 100644 --- a/chrome/VERSION +++ b/chrome/VERSION @@ -1,4 +1,4 @@ MAJOR=88 -MINOR=0 --BUILD=4315 --PATCH=7 +-BUILD=4324 +-PATCH=51 +MINOR=1 +BUILD=19 +PATCH=79 diff --git a/patches/chrome-android-BUILD.gn.patch b/patches/chrome-android-BUILD.gn.patch index 8bd9470ee014..3508748464d6 100644 --- a/patches/chrome-android-BUILD.gn.patch +++ b/patches/chrome-android-BUILD.gn.patch @@ -1,5 +1,5 @@ diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn -index e6f1f636018d937841567678bc90c1b77e48e0ef..1ffcce76316faf5f842549828f5d42018e7dac5b 100644 +index 99515abfdf92ccf70ee5070b0d539985d8428c6d..0cf3311623a41d2c764c3948626d87f1dbf443dc 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn @@ -231,6 +231,7 @@ android_resources("chrome_app_java_resources") { @@ -10,7 +10,7 @@ index e6f1f636018d937841567678bc90c1b77e48e0ef..1ffcce76316faf5f842549828f5d4201 } if (enable_vr) { -@@ -530,6 +531,7 @@ android_library("chrome_java") { +@@ -531,6 +532,7 @@ android_library("chrome_java") { ] deps += feed_deps @@ -18,7 +18,7 @@ index e6f1f636018d937841567678bc90c1b77e48e0ef..1ffcce76316faf5f842549828f5d4201 srcjar_deps = [ ":chrome_android_java_enums_srcjar", -@@ -560,6 +562,7 @@ android_library("chrome_java") { +@@ -561,6 +563,7 @@ android_library("chrome_java") { "//components/ui_metrics:ui_metrics_enums_java", "//net:effective_connection_type_java", ] @@ -26,15 +26,15 @@ index e6f1f636018d937841567678bc90c1b77e48e0ef..1ffcce76316faf5f842549828f5d4201 # From java_sources.gni. sources = chrome_java_sources + [ app_hooks_impl ] -@@ -683,6 +686,7 @@ group("jni_headers") { +@@ -678,6 +681,7 @@ group("jni_headers") { "//chrome/browser/webauthn/android:jni_headers", "//components/media_router/browser/android:jni_headers", ] + public_deps += ["//brave/build/android:jni_headers"] } - action("chrome_android_java_google_api_keys_srcjar") { -@@ -1799,6 +1803,7 @@ if (current_toolchain == default_toolchain) { + # TODO(crbug.com/1112471): Get this to run cleanly under Python 3. +@@ -1798,6 +1802,7 @@ if (current_toolchain == default_toolchain) { ":${_variant}_locale_pak_assets", ":${_variant}_paks", ] diff --git a/patches/chrome-android-chrome_java_sources.gni.patch b/patches/chrome-android-chrome_java_sources.gni.patch index 777159fb7164..06dc4a24d885 100644 --- a/patches/chrome-android-chrome_java_sources.gni.patch +++ b/patches/chrome-android-chrome_java_sources.gni.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni -index f8040f5bf4374f5eb81bc264282fb56562b2cc80..984762215631a61efadf6b0094cfb957fbc9068b 100644 +index 86597ad5745bfdc4318da347549486a4b3997f78..f1fa1e563306add61002c966035d3b80be354d66 100644 --- a/chrome/android/chrome_java_sources.gni +++ b/chrome/android/chrome_java_sources.gni -@@ -1682,3 +1682,4 @@ chrome_java_sources = [ +@@ -1693,3 +1693,4 @@ chrome_java_sources = [ "java/src/org/chromium/chrome/browser/webauth/authenticator/CableAuthenticatorActivity.java", "java/src/org/chromium/chrome/browser/webshare/ShareServiceImplementationFactory.java", ] diff --git a/patches/chrome-android-chrome_public_apk_tmpl.gni.patch b/patches/chrome-android-chrome_public_apk_tmpl.gni.patch index 890f27558338..f0b2d527f17b 100644 --- a/patches/chrome-android-chrome_public_apk_tmpl.gni.patch +++ b/patches/chrome-android-chrome_public_apk_tmpl.gni.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/chrome_public_apk_tmpl.gni b/chrome/android/chrome_public_apk_tmpl.gni -index 45b925f5df82cb1ed624ca357a49b8d044df1c6f..fd06f89a8ff95f6c96601de59a6762ac58b04bc6 100644 +index 00fde4514a8ada64522943070470bbf008398d2b..d9aa12d5f6ca9032684eef0f849c3eba568acd84 100644 --- a/chrome/android/chrome_public_apk_tmpl.gni +++ b/chrome/android/chrome_public_apk_tmpl.gni -@@ -207,6 +207,7 @@ template("chrome_public_common_apk_or_module_tmpl") { +@@ -210,6 +210,7 @@ template("chrome_public_common_apk_or_module_tmpl") { "${_material_package}:[Ss]lider", "${_material_package}:[Tt]oolbarLayout", ] @@ -10,7 +10,7 @@ index 45b925f5df82cb1ed624ca357a49b8d044df1c6f..fd06f89a8ff95f6c96601de59a6762ac if (!_is_monochrome) { product_config_java_packages = [ "org.chromium.chrome.browser" ] -@@ -316,6 +317,7 @@ template("chrome_public_common_apk_or_module_tmpl") { +@@ -319,6 +320,7 @@ template("chrome_public_common_apk_or_module_tmpl") { if (!defined(proguard_configs)) { proguard_configs = [] } diff --git a/patches/chrome-android-expectations-lint-suppressions.xml.patch b/patches/chrome-android-expectations-lint-suppressions.xml.patch index f7c533924861..a7d53898c2a2 100644 --- a/patches/chrome-android-expectations-lint-suppressions.xml.patch +++ b/patches/chrome-android-expectations-lint-suppressions.xml.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/expectations/lint-suppressions.xml b/chrome/android/expectations/lint-suppressions.xml -index b7143fd76a6114e222cabdb2e298d424622cde1d..7a28c11c2be01a03cc56d5bc6c6a394d2acc1811 100644 +index b31881da7a3162fd0e7549c32ec58b214fce926d..da5908c80352d4d1bff4b16362589014cf270c9e 100644 --- a/chrome/android/expectations/lint-suppressions.xml +++ b/chrome/android/expectations/lint-suppressions.xml -@@ -342,4 +342,5 @@ Still reading? +@@ -345,4 +345,5 @@ Still reading? diff --git a/patches/chrome-android-java-AndroidManifest.xml.patch b/patches/chrome-android-java-AndroidManifest.xml.patch index f0623b209ab7..fad5c82c4628 100644 --- a/patches/chrome-android-java-AndroidManifest.xml.patch +++ b/patches/chrome-android-java-AndroidManifest.xml.patch @@ -1,5 +1,5 @@ diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml -index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88d8d6e0ab 100644 +index 4f73e753eb851db0c3547a5ee636b94ded5350fd..5939198b6c899268128985999d3348b9e4e0c6d7 100644 --- a/chrome/android/java/AndroidManifest.xml +++ b/chrome/android/java/AndroidManifest.xml @@ -38,7 +38,9 @@ by a child template that "extends" this file. @@ -12,7 +12,7 @@ index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88 -@@ -48,17 +50,24 @@ by a child template that "extends" this file. +@@ -48,9 +50,13 @@ by a child template that "extends" this file. {% if target_sdk_version|int > 27 or target_sdk_version == "Q" %} {% endif %} @@ -25,9 +25,8 @@ index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88 +--> -+ - - + +@@ -59,7 +65,9 @@ by a child template that "extends" this file. @@ -37,7 +36,7 @@ index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88 -@@ -107,7 +116,9 @@ by a child template that "extends" this file. +@@ -107,7 +115,9 @@ by a child template that "extends" this file. @@ -47,7 +46,7 @@ index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88 {% block extra_uses_permissions %} {% endblock %} -@@ -160,6 +171,7 @@ by a child template that "extends" this file. +@@ -160,6 +170,7 @@ by a child template that "extends" this file. org.chromium.chrome.browser.ChromeApplication {%- endif -%} {% endblock %}" @@ -55,7 +54,7 @@ index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88 android:icon="@drawable/ic_launcher" android:roundIcon="@drawable/ic_launcher_round" android:label="{% block application_label %}@string/app_name{% endblock %}" -@@ -1166,6 +1178,7 @@ by a child template that "extends" this file. +@@ -1171,6 +1182,7 @@ by a child template that "extends" this file. {% endif %} @@ -63,7 +62,7 @@ index 2948f6a58cafde782ca2a7860d352ed56cf3cd20..c1cad83439f8da614abbd8c69db13e88 {% block extra_application_definitions %} {% endblock %} {% endmacro %} -@@ -1248,6 +1261,7 @@ by a child template that "extends" this file. +@@ -1253,6 +1265,7 @@ by a child template that "extends" this file. diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-AppHooks.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-AppHooks.java.patch index 49aa30483b4b..345b976bd545 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-AppHooks.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-AppHooks.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java b/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java -index 7463c1449dae81fc33d1518c4a95d71b16072a5b..283cb6c535f16e5914305565862a6c789f2711d2 100644 +index ed15b5d777ae94b92e8dc36e138416243cdc7d39..e342cb1a60367f67ee99661bc55fee5bd92da372 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java -@@ -77,7 +77,7 @@ public abstract class AppHooks { +@@ -78,7 +78,7 @@ public abstract class AppHooks { @CalledByNative public static AppHooks get() { diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-TabbedModeTabDelegateFactory.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-TabbedModeTabDelegateFactory.java.patch index d7a565c3cdce..afef42eba10d 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-TabbedModeTabDelegateFactory.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-TabbedModeTabDelegateFactory.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabbedModeTabDelegateFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/TabbedModeTabDelegateFactory.java -index 8d2a47311ce2f686cc343fc16c775008bffe855a..c05e6c020335951b421dcfd4c3918415ffe6bf79 100644 +index ebbe03f3cb8f66014ad51d0ecf5450ce4be86f95..b8c232ff14ae71eeba9941dd443e27781268f4f7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/TabbedModeTabDelegateFactory.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/TabbedModeTabDelegateFactory.java -@@ -56,7 +56,7 @@ public class TabbedModeTabDelegateFactory implements TabDelegateFactory { +@@ -58,7 +58,7 @@ public class TabbedModeTabDelegateFactory implements TabDelegateFactory { @Override public ExternalNavigationHandler createExternalNavigationHandler(Tab tab) { diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-app-ChromeActivity.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-app-ChromeActivity.java.patch index bebb65bc80c8..15f30cb2b11f 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-app-ChromeActivity.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-app-ChromeActivity.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java -index bcefc55f69ce1810cb7e70a15613aba5d6c96a80..595817c9826f6a1d89da0125f758301d2896e17c 100644 +index d2606e4b6c4c3cbebe1e363e43d4a73d19377e68..eca88feaa4617cb9e893e7b5467e25e9d7f352fd 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java -@@ -331,7 +331,7 @@ public abstract class ChromeActivity +@@ -330,7 +330,7 @@ public abstract class ChromeActivity NightModeReparentingController mNightModeReparentingController; protected ChromeActivity() { diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-password_manager-settings-PasswordSettings.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-password_manager-settings-PasswordSettings.java.patch index cee5809cdab1..4dfd3a6adf80 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-password_manager-settings-PasswordSettings.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-password_manager-settings-PasswordSettings.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java -index e857d81ad38bdcf73b3b75607b3d6144f1588e91..88dd035856cc0c0f060a3c1eaae4eb849f95ed63 100644 +index 2470d6bae98c5c0ba059b72f59608adfede06681..cb4a2acc687c5c4865004452b6b92be784294d4d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/settings/PasswordSettings.java -@@ -58,7 +58,7 @@ import java.util.Locale; +@@ -57,7 +57,7 @@ import java.util.Locale; * to view saved passwords (just the username and URL), and to delete saved passwords. */ public class PasswordSettings diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-ManageSyncSettings.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-ManageSyncSettings.java.patch index 9763184e0f5b..803f642bbe1e 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-ManageSyncSettings.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-ManageSyncSettings.java.patch @@ -1,5 +1,5 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/ManageSyncSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/ManageSyncSettings.java -index c437801b2a1f8d69acf5c6d9aa28478f4656027e..aefc7b706f29763af10a3a78aece2b215c0b7ddf 100644 +index 8e622ca4a0269c70d199cd773e040a076ad05b52..cf9ede4c52b6c7b650d009d4ce490d9086439702 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/ManageSyncSettings.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/ManageSyncSettings.java @@ -26,7 +26,7 @@ import androidx.appcompat.app.AlertDialog; @@ -11,7 +11,7 @@ index c437801b2a1f8d69acf5c6d9aa28478f4656027e..aefc7b706f29763af10a3a78aece2b21 import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceFragmentCompat; -@@ -353,7 +353,7 @@ public class ManageSyncSettings extends PreferenceFragmentCompat +@@ -366,7 +366,7 @@ public class ManageSyncSettings extends PreferenceFragmentCompat IdentityServicesProvider.get() .getIdentityManager(Profile.getLastUsedRegularProfile()) .getPrimaryAccountInfo(ConsentLevel.SYNC)); diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-SyncAndServicesSettings.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-SyncAndServicesSettings.java.patch index f3316c580276..a5d1b2aad856 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-SyncAndServicesSettings.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-sync-settings-SyncAndServicesSettings.java.patch @@ -1,5 +1,5 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/SyncAndServicesSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/SyncAndServicesSettings.java -index e29316630cceb054aef4ab270f3aa325dc62a075..1ae510a0255511d65d4292711aa2115c0f0af128 100644 +index a1101ceecf751b9914ba4bff7a91c8cac241879d..3aba3e417b2e006488676db7a62d90e02a8aab88 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/SyncAndServicesSettings.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/settings/SyncAndServicesSettings.java @@ -76,7 +76,7 @@ import org.chromium.ui.widget.ButtonCompat; diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-ToolbarManager.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-ToolbarManager.java.patch index 22ad8de936a1..1fcb1ca775b3 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-ToolbarManager.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-ToolbarManager.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java -index ec684d7d473d0c8d96acbacdb25ec0b349361f3a..3cfa37bd82493689b7cbfdb1de6d7f6eb918aa9d 100644 +index 910950278b3503367f56cfdae2bb0f22d527d775..b51b7553a2874ebdc5a384ddd95eee0396f7b94e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java -@@ -379,14 +379,14 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve +@@ -392,14 +392,14 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve ThemeColorProvider overviewModeThemeColorProvider = mAppThemeColorProvider; Runnable requestFocusRunnable = compositorViewHolder::requestFocus; @@ -19,7 +19,7 @@ index ec684d7d473d0c8d96acbacdb25ec0b349361f3a..3cfa37bd82493689b7cbfdb1de6d7f6e appMenuCoordinatorSupplier, mControlsVisibilityDelegate, mActivity, (focus, type) -> setUrlBarFocus(focus, type), -@@ -735,7 +735,7 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve +@@ -758,7 +758,7 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve IdentityDiscController identityDiscController, OneshotSupplier startSurfaceSupplier) { // clang-format off diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-bottom-BottomControlsCoordinator.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-bottom-BottomControlsCoordinator.java.patch index b80b0aaf18ff..73086533564b 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-bottom-BottomControlsCoordinator.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-bottom-BottomControlsCoordinator.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java -index e3b12ac8f13bc16a55b244d25075bb944ff7de6d..9be68e7dc5641bc5bbec56e3fc4c76b050d42a9f 100644 +index dd58bc81f065e0434d28f8ec665a3ae8e0ddd29b..8b8f3de73df0dc977bddc719a9805ff2353a2ef2 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java -@@ -98,7 +98,7 @@ public class BottomControlsCoordinator { +@@ -94,7 +94,7 @@ public class BottomControlsCoordinator { View container = root.findViewById(R.id.bottom_container_slot); ViewGroup.LayoutParams params = container.getLayoutParams(); params.height = root.getResources().getDimensionPixelOffset(bottomControlsHeightId); diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-top-ToolbarPhone.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-top-ToolbarPhone.java.patch index c1a44d38c4f5..9a291423c65a 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-top-ToolbarPhone.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-toolbar-top-ToolbarPhone.java.patch @@ -1,8 +1,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java -index 9170c4523a4208a074e8530393b53854dbed672b..fdbec35de197cbfd4ebd5daa2f907ad601409273 100644 +index 4e575a1d8984fbe5b13f42b866ef5c8236f44f5b..bec872a479f71443983f820a33cc0e7c1b3b287f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java -@@ -86,7 +86,7 @@ import java.util.List; +@@ -85,7 +85,7 @@ import java.util.List; /** * Phone specific toolbar implementation. */ @@ -11,7 +11,7 @@ index 9170c4523a4208a074e8530393b53854dbed672b..fdbec35de197cbfd4ebd5daa2f907ad6 /** The amount of time transitioning from one theme color to another should take in ms. */ public static final long THEME_COLOR_TRANSITION_DURATION = 250; -@@ -399,10 +399,12 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC +@@ -401,10 +401,12 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC /** * Set the background color of the location bar to appropriately match the theme color. */ @@ -25,7 +25,7 @@ index 9170c4523a4208a074e8530393b53854dbed672b..fdbec35de197cbfd4ebd5daa2f907ad6 } /** -@@ -512,6 +514,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC +@@ -526,6 +528,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC EventConstants.PARTNER_HOME_PAGE_BUTTON_PRESSED); } } @@ -33,7 +33,7 @@ index 9170c4523a4208a074e8530393b53854dbed672b..fdbec35de197cbfd4ebd5daa2f907ad6 } @Override -@@ -681,7 +684,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC +@@ -695,7 +698,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC * @return The right bounds of the location bar after accounting for any visible left buttons. */ private int getBoundsAfterAccountingForRightButtons() { @@ -42,7 +42,7 @@ index 9170c4523a4208a074e8530393b53854dbed672b..fdbec35de197cbfd4ebd5daa2f907ad6 } private void updateToolbarBackground(int color) { -@@ -2087,6 +2090,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC +@@ -2109,6 +2112,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC } else { populateUrlClearFocusingAnimatorSet(animators); } diff --git a/patches/chrome-android-java-src-org-chromium-chrome-browser-ui-RootUiCoordinator.java.patch b/patches/chrome-android-java-src-org-chromium-chrome-browser-ui-RootUiCoordinator.java.patch index 17c8e9a3d528..4e5e9fe46932 100644 --- a/patches/chrome-android-java-src-org-chromium-chrome-browser-ui-RootUiCoordinator.java.patch +++ b/patches/chrome-android-java-src-org-chromium-chrome-browser-ui-RootUiCoordinator.java.patch @@ -1,11 +1,11 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java -index c14b33ba342b6875d87c790e491939b3355919b4..9bf5df2aa6b318bcf1cf7e574bda781aaa269d74 100644 +index 8192354c80011a233a89e23f1d57e46101e4e96e..8d64bdada66b01408767d35c4eb4786c573fe8d4 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java -@@ -566,7 +566,7 @@ public class RootUiCoordinator - mActivity.getLifecycleDispatcher(), mActivity.getModalDialogManager(), - () -> mToolbarManager.setUrlBarFocus(false, OmniboxFocusReason.UNFOCUS)); - mButtonDataProviders = Arrays.asList(mIdentityDiscController, shareButtonController); +@@ -612,7 +612,7 @@ public class RootUiCoordinator + mActivity.getModalDialogManager(), voiceSearchDelegate); + mButtonDataProviders = Arrays.asList( + mIdentityDiscController, shareButtonController, voiceToolbarButtonController); - mToolbarManager = new ToolbarManager(mActivity, mActivity.getBrowserControlsManager(), + mToolbarManager = new org.chromium.chrome.browser.toolbar.BraveToolbarManager(mActivity, mActivity.getBrowserControlsManager(), mActivity.getFullscreenManager(), toolbarContainer, diff --git a/patches/chrome-app-BUILD.gn.patch b/patches/chrome-app-BUILD.gn.patch index 1238d6ac4d3c..c74f07131e48 100644 --- a/patches/chrome-app-BUILD.gn.patch +++ b/patches/chrome-app-BUILD.gn.patch @@ -1,8 +1,8 @@ diff --git a/chrome/app/BUILD.gn b/chrome/app/BUILD.gn -index d85c8180793d59dd22d4aafbfb95ac0b746908ca..1eed0b7c4fa3fce7c7a6d80b0a006cc19d78bf4d 100644 +index bc9b9495ad18b5b2e2980e975a06f5691b65a71f..06423a2741497c46b9ce11618043950dd306044d 100644 --- a/chrome/app/BUILD.gn +++ b/chrome/app/BUILD.gn -@@ -74,6 +74,8 @@ grit("generated_resources") { +@@ -77,6 +77,8 @@ grit("generated_resources") { if (is_android) { outputs += android_generated_java_resources } @@ -11,7 +11,7 @@ index d85c8180793d59dd22d4aafbfb95ac0b746908ca..1eed0b7c4fa3fce7c7a6d80b0a006cc1 } if (is_android) { -@@ -96,7 +98,7 @@ grit("google_chrome_strings") { +@@ -99,7 +101,7 @@ grit("google_chrome_strings") { } grit("chromium_strings") { diff --git a/patches/chrome-browser-BUILD.gn.patch b/patches/chrome-browser-BUILD.gn.patch index 160fbb7716ba..c9a172b85099 100644 --- a/patches/chrome-browser-BUILD.gn.patch +++ b/patches/chrome-browser-BUILD.gn.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn -index 535d65e656797dcb397e944d7d1ca5102ad5f9c6..93723bb09b79a6b58f4675f9a760fa3c55973ee0 100644 +index a7b0f89b47a0b1025f091ba18270f21ddebeeff9..d7e18716ae64e3ead55107ab973fd3181a6aba82 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn -@@ -2385,6 +2385,7 @@ static_library("browser") { +@@ -2423,6 +2423,7 @@ static_library("browser") { "performance_monitor/metric_evaluator_helper_posix.h", ] } diff --git a/patches/chrome-browser-about_flags.cc.patch b/patches/chrome-browser-about_flags.cc.patch index f3a49f0893e8..92a8e078db3f 100644 --- a/patches/chrome-browser-about_flags.cc.patch +++ b/patches/chrome-browser-about_flags.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc -index 4747a7d3424672f8cc79debf00a5633ed8eba044..76cb61eaa3c4716eb2cdd2322ddd1ff371034384 100644 +index 107ad9402c2e3d2bae02e414315442178f447224..cda90d691a49a065eaa00c1d1cebbf0e883044c3 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc -@@ -297,14 +297,14 @@ const FeatureEntry::Choice kTouchTextSelectionStrategyChoices[] = { +@@ -298,14 +298,14 @@ const FeatureEntry::Choice kTouchTextSelectionStrategyChoices[] = { const FeatureEntry::Choice kTraceUploadURL[] = { {flags_ui::kGenericExperimentChoiceDisabled, "", ""}, {flag_descriptions::kTraceUploadUrlChoiceOther, switches::kTraceUploadURL, @@ -21,7 +21,7 @@ index 4747a7d3424672f8cc79debf00a5633ed8eba044..76cb61eaa3c4716eb2cdd2322ddd1ff3 const FeatureEntry::Choice kPassiveListenersChoices[] = { {flags_ui::kGenericExperimentChoiceDefault, "", ""}, -@@ -6682,6 +6682,7 @@ const FeatureEntry kFeatureEntries[] = { +@@ -6780,6 +6780,7 @@ const FeatureEntry kFeatureEntries[] = { // "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag // Histograms" in tools/metrics/histograms/README.md (run the // AboutFlagsHistogramTest unit test to verify this process). diff --git a/patches/chrome-browser-chrome_content_browser_client.h.patch b/patches/chrome-browser-chrome_content_browser_client.h.patch index 3fcf45270bfd..c027021b8faf 100644 --- a/patches/chrome-browser-chrome_content_browser_client.h.patch +++ b/patches/chrome-browser-chrome_content_browser_client.h.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h -index fb5ec1857ec97a887562420e284cb99e63e61e8f..97f39d0d4847a89df6af52226f430b62ec7cc203 100644 +index dea6337718181065c0f6ec09125f1c472735de1b..5e53c94ec94e6b57c54857f0220fe118cb0497f9 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h -@@ -722,6 +722,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { +@@ -728,6 +728,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { } private: diff --git a/patches/chrome-browser-content_settings-host_content_settings_map_factory.cc.patch b/patches/chrome-browser-content_settings-host_content_settings_map_factory.cc.patch index 1b73a7833cf4..27590b3195ea 100644 --- a/patches/chrome-browser-content_settings-host_content_settings_map_factory.cc.patch +++ b/patches/chrome-browser-content_settings-host_content_settings_map_factory.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/content_settings/host_content_settings_map_factory.cc b/chrome/browser/content_settings/host_content_settings_map_factory.cc -index f3b51e20cb9c84719947b6fbf779d8429e924570..27d78b367a8fb8505ee49c51fa17a033aca2b66a 100644 +index cf62b79358e14c90dab5a1e68cec7055c0cce39f..3a6f8c0ea0368b627fc5477163858f028a45ebc1 100644 --- a/chrome/browser/content_settings/host_content_settings_map_factory.cc +++ b/chrome/browser/content_settings/host_content_settings_map_factory.cc -@@ -86,6 +86,7 @@ scoped_refptr +@@ -87,6 +87,7 @@ scoped_refptr scoped_refptr settings_map(new HostContentSettingsMap( profile->GetPrefs(), diff --git a/patches/chrome-browser-extensions-BUILD.gn.patch b/patches/chrome-browser-extensions-BUILD.gn.patch index 36d78a51cf56..caab3074ac79 100644 --- a/patches/chrome-browser-extensions-BUILD.gn.patch +++ b/patches/chrome-browser-extensions-BUILD.gn.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn -index 142b6699f13a779c783d93a25f1c5e3452183a83..a3f199a67c6e026865903f80a403b8394a68787f 100644 +index 0b3b0372d42a7f2c78d404125351ab54e6e258bd..ad8fa0ed5d4d23c87ae7cb31472b7e65a9173ad7 100644 --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn -@@ -1266,6 +1266,7 @@ static_library("extensions") { +@@ -1271,6 +1271,7 @@ static_library("extensions") { } else { sources += [ "api/braille_display_private/braille_controller_stub.cc" ] } diff --git a/patches/chrome-browser-extensions-chrome_component_extension_resource_manager.cc.patch b/patches/chrome-browser-extensions-chrome_component_extension_resource_manager.cc.patch index f4311ba9772c..c429b0538427 100644 --- a/patches/chrome-browser-extensions-chrome_component_extension_resource_manager.cc.patch +++ b/patches/chrome-browser-extensions-chrome_component_extension_resource_manager.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/extensions/chrome_component_extension_resource_manager.cc b/chrome/browser/extensions/chrome_component_extension_resource_manager.cc -index 81202cee9f5a9a31cf0097ff549ff002376514bf..3f1de5233e55770106187d93049af175f249efcc 100644 +index 18045b809f9cd6e7fccf49e5f7172fec0559c677..1e806c4c4b28c4931d8f2f03b8d06c6dd0e2eabf 100644 --- a/chrome/browser/extensions/chrome_component_extension_resource_manager.cc +++ b/chrome/browser/extensions/chrome_component_extension_resource_manager.cc -@@ -129,6 +129,7 @@ ChromeComponentExtensionResourceManager::Data::Data() { +@@ -128,6 +128,7 @@ ChromeComponentExtensionResourceManager::Data::Data() { std::move(pdf_viewer_replacements); } #endif diff --git a/patches/chrome-browser-extensions-extension_management.cc.patch b/patches/chrome-browser-extensions-extension_management.cc.patch index 0c0cc3558664..1efd4ebea296 100644 --- a/patches/chrome-browser-extensions-extension_management.cc.patch +++ b/patches/chrome-browser-extensions-extension_management.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc -index aecef847f26608a9a3f18a5479621a88c2c41465..545d662b5764fd0934f843add4a0a3d19f91f9ee 100644 +index 6368e26a6bf97ffef4cebeb390d2aab9de22bbe0..4e3bd0b62666c6188250235f2de352373d52bd82 100644 --- a/chrome/browser/extensions/extension_management.cc +++ b/chrome/browser/extensions/extension_management.cc @@ -17,6 +17,7 @@ diff --git a/patches/chrome-browser-extensions-extension_tab_util.cc.patch b/patches/chrome-browser-extensions-extension_tab_util.cc.patch index 377039f737a3..74101c53f01d 100644 --- a/patches/chrome-browser-extensions-extension_tab_util.cc.patch +++ b/patches/chrome-browser-extensions-extension_tab_util.cc.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc -index 4260e615cf9bc4bcc0fbabfc8a5fb5b236b8bd0f..99a3ebb76e9cdae8bde9b03d5dcb2aee19fb8b2f 100644 +index bfd8c85fbb1057ab8326fd48175c120468f44c02..ade81449e5173b5a00faf4067e8a3f98a2d9366c 100644 --- a/chrome/browser/extensions/extension_tab_util.cc +++ b/chrome/browser/extensions/extension_tab_util.cc -@@ -779,6 +779,7 @@ bool ExtensionTabUtil::IsKillURL(const GURL& url) { - GURL fixed_url = - url_formatter::FixupURL(url.possibly_invalid_spec(), std::string()); - if (!fixed_url.SchemeIs(content::kChromeUIScheme)) -+ if (!fixed_url.SchemeIs(content::kBraveUIScheme)) +@@ -784,6 +784,7 @@ bool ExtensionTabUtil::IsKillURL(const GURL& url) { + }; + + if (!url.SchemeIs(content::kChromeUIScheme)) ++ if (!url.SchemeIs(content::kBraveUIScheme)) return false; - base::StringPiece fixed_host = fixed_url.host_piece(); + return base::Contains(kill_hosts, url.host_piece()); diff --git a/patches/chrome-browser-flags-android-chrome_feature_list.cc.patch b/patches/chrome-browser-flags-android-chrome_feature_list.cc.patch index a8f32578690e..14bdbc2a25f3 100644 --- a/patches/chrome-browser-flags-android-chrome_feature_list.cc.patch +++ b/patches/chrome-browser-flags-android-chrome_feature_list.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc -index e0482c79a4f176381376285e8b93c3c5abc65db3..e063a10394852b0c9cbb2acce0772ecf2b97b51e 100644 +index c226d798ea37ac06928e59ee6941918190588e9b..127dd07ccb862e9b338cd17ea67b274eb678d71c 100644 --- a/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chrome/browser/flags/android/chrome_feature_list.cc -@@ -276,6 +276,7 @@ const base::Feature* kFeaturesExposedToJava[] = { +@@ -292,6 +292,7 @@ const base::Feature* kFeaturesExposedToJava[] = { }; const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) { diff --git a/patches/chrome-browser-net-net_error_tab_helper.cc.patch b/patches/chrome-browser-net-net_error_tab_helper.cc.patch index 60e462b88309..ca7e7120b2d9 100644 --- a/patches/chrome-browser-net-net_error_tab_helper.cc.patch +++ b/patches/chrome-browser-net-net_error_tab_helper.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/net/net_error_tab_helper.cc b/chrome/browser/net/net_error_tab_helper.cc -index 3477bb6fbeceb2ab3d9a00332bc0146f22793450..faf701cc8342ed7eed0679a6da93c136e2e6cfb6 100644 +index 313758372e0fcb842ee6a5b5cd69a64b8a95b2ac..cc920fb9459462075a1a9c123ae7af34ea5c8ac8 100644 --- a/chrome/browser/net/net_error_tab_helper.cc +++ b/chrome/browser/net/net_error_tab_helper.cc -@@ -201,6 +201,9 @@ void NetErrorTabHelper::InitializePref(WebContents* contents) { +@@ -200,6 +200,9 @@ void NetErrorTabHelper::InitializePref(WebContents* contents) { } bool NetErrorTabHelper::ProbesAllowed() const { diff --git a/patches/chrome-browser-net-system_network_context_manager.cc.patch b/patches/chrome-browser-net-system_network_context_manager.cc.patch index 73ba681580b2..f0387a7f3475 100644 --- a/patches/chrome-browser-net-system_network_context_manager.cc.patch +++ b/patches/chrome-browser-net-system_network_context_manager.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/net/system_network_context_manager.cc b/chrome/browser/net/system_network_context_manager.cc -index 7f58187215cb94be47e38f6be9de32012332d9fd..72d0d7bd243e3fa373f00396d5af8843551aa5cc 100644 +index c45a5a758d91d87d03791ceba1e3befca6768cdf..e610453c4f2ad9662fd7d89f856a5992e70ddc60 100644 --- a/chrome/browser/net/system_network_context_manager.cc +++ b/chrome/browser/net/system_network_context_manager.cc -@@ -218,7 +218,7 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem +@@ -220,7 +220,7 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem if (!manager_) return; manager_->GetURLLoaderFactory()->CreateLoaderAndStart( diff --git a/patches/chrome-browser-plugins-chrome_plugin_service_filter.cc.patch b/patches/chrome-browser-plugins-chrome_plugin_service_filter.cc.patch deleted file mode 100644 index 1a87dfc80a76..000000000000 --- a/patches/chrome-browser-plugins-chrome_plugin_service_filter.cc.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/chrome/browser/plugins/chrome_plugin_service_filter.cc b/chrome/browser/plugins/chrome_plugin_service_filter.cc -index e46003ea5e4ab9094201dc2d0b53aa5940ac7e0d..30dbe677c889c982cae9fb45fed8c4afe0283024 100644 ---- a/chrome/browser/plugins/chrome_plugin_service_filter.cc -+++ b/chrome/browser/plugins/chrome_plugin_service_filter.cc -@@ -50,7 +50,7 @@ class ProfileContentSettingObserver : public content_settings::Observer { - PluginService::GetInstance()->PurgePluginListCache(profile_, false); - - const GURL primary(primary_pattern.ToString()); -- if (primary.is_valid()) { -+ if (primary.is_valid() && resource_identifier.length() == 0) { - DCHECK_EQ(ContentSettingsPattern::Relation::IDENTITY, - ContentSettingsPattern::Wildcard().Compare(secondary_pattern)); - PluginUtils::RememberFlashChangedForSite(map, primary); diff --git a/patches/chrome-browser-prefs-browser_prefs.cc.patch b/patches/chrome-browser-prefs-browser_prefs.cc.patch index 088810972f8b..ece59e2668ea 100644 --- a/patches/chrome-browser-prefs-browser_prefs.cc.patch +++ b/patches/chrome-browser-prefs-browser_prefs.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc -index 9c81ffe93ae903e045c07b578c89083b6675a935..418ade6c5662779666b78290556d4d233ff87b22 100644 +index 7e31648f1a8cde7b84a3764c80930309138b9ec2..d7d925a3de64aa8574dc099b74638503477734d1 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc -@@ -742,6 +742,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) { +@@ -764,6 +764,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) { #if defined(TOOLKIT_VIEWS) RegisterBrowserViewLocalPrefs(registry); #endif @@ -10,7 +10,7 @@ index 9c81ffe93ae903e045c07b578c89083b6675a935..418ade6c5662779666b78290556d4d23 // This is intentionally last. RegisterLocalStatePrefsForMigration(registry); -@@ -1008,6 +1009,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, +@@ -1029,6 +1030,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, #endif RegisterProfilePrefsForMigration(registry); diff --git a/patches/chrome-browser-profiles-profile.cc.patch b/patches/chrome-browser-profiles-profile.cc.patch index 55aac863d087..82d139d1498b 100644 --- a/patches/chrome-browser-profiles-profile.cc.patch +++ b/patches/chrome-browser-profiles-profile.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc -index 039035dce20878b29523ad7ebce2bf189eadfa0c..c08083fd5cef809ddff0e97f7c87df4c5a00b48d 100644 +index 103c8c04b728e35b3ac1a5b8461acbc8616dcf47..6820c83d5b14012e879587c96273375f9178dcd5 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -131,6 +131,7 @@ bool Profile::OTRProfileID::AllowsBrowserWindows() const { diff --git a/patches/chrome-browser-profiles-profile_avatar_icon_util.cc.patch b/patches/chrome-browser-profiles-profile_avatar_icon_util.cc.patch index 33dbbd2e3744..073c38d32596 100644 --- a/patches/chrome-browser-profiles-profile_avatar_icon_util.cc.patch +++ b/patches/chrome-browser-profiles-profile_avatar_icon_util.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/profiles/profile_avatar_icon_util.cc b/chrome/browser/profiles/profile_avatar_icon_util.cc -index d2214a75fdf2045c471386ac1b43385100c671a9..174601e2a0346452cd983942f21680fcf3a4e71f 100644 +index 09aaa307c1a73b1d73643947e787ef06661c4f3d..6fd70c64c9418a2edf0dd1278bb1d5af6c1edeb0 100644 --- a/chrome/browser/profiles/profile_avatar_icon_util.cc +++ b/chrome/browser/profiles/profile_avatar_icon_util.cc -@@ -335,7 +335,7 @@ constexpr size_t kDefaultAvatarIconsCount = 1; +@@ -344,7 +344,7 @@ constexpr size_t kDefaultAvatarIconsCount = 1; #elif defined(OS_CHROMEOS) constexpr size_t kDefaultAvatarIconsCount = 27; #else @@ -11,7 +11,7 @@ index d2214a75fdf2045c471386ac1b43385100c671a9..174601e2a0346452cd983942f21680fc #endif #if !defined(OS_ANDROID) -@@ -470,6 +470,7 @@ size_t GetPlaceholderAvatarIndex() { +@@ -476,6 +476,7 @@ size_t GetPlaceholderAvatarIndex() { size_t GetModernAvatarIconStartIndex() { #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) @@ -19,7 +19,7 @@ index d2214a75fdf2045c471386ac1b43385100c671a9..174601e2a0346452cd983942f21680fc return GetPlaceholderAvatarIndex() + 1; #else // Only use the placeholder avatar on ChromeOS and Android. -@@ -503,6 +504,7 @@ std::string GetPlaceholderAvatarIconUrl() { +@@ -509,6 +510,7 @@ std::string GetPlaceholderAvatarIconUrl() { const IconResourceInfo* GetDefaultAvatarIconResourceInfo(size_t index) { CHECK_LT(index, kDefaultAvatarIconsCount); diff --git a/patches/chrome-browser-profiles-profile_impl.cc.patch b/patches/chrome-browser-profiles-profile_impl.cc.patch index 7372e4e2bbec..e6b5f351fd9b 100644 --- a/patches/chrome-browser-profiles-profile_impl.cc.patch +++ b/patches/chrome-browser-profiles-profile_impl.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc -index 1c6cb0b66b46a958ad57f3f8c31ad225558d5c71..9ad82d26e2760cb0e06d95fedaed9c4f26986b49 100644 +index 03953cd006a5e6717d78a5f878a8ff065c520318..2eb4f00844c0acf3e98918cbbbdd55535cbc7dc6 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -356,7 +356,7 @@ std::unique_ptr Profile::CreateProfile(const base::FilePath& path, diff --git a/patches/chrome-browser-profiles-profile_io_data.cc.patch b/patches/chrome-browser-profiles-profile_io_data.cc.patch index 4be5e1990aae..171776dc4b4a 100644 --- a/patches/chrome-browser-profiles-profile_io_data.cc.patch +++ b/patches/chrome-browser-profiles-profile_io_data.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc -index 7c91474fa32ce1780b2a9ceb8924a848a01187e1..0ecefb79f1c19fea87457b30323aec6cd21d4d8d 100644 +index 16c5e6132537cd576fdb6832d291f9413c578344..f2147c203b23b8ffd5a1437b643befa539c69766 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -255,6 +255,9 @@ bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { diff --git a/patches/chrome-browser-renderer_context_menu-render_view_context_menu.cc.patch b/patches/chrome-browser-renderer_context_menu-render_view_context_menu.cc.patch index ec9638933e3b..533dee9ab3db 100644 --- a/patches/chrome-browser-renderer_context_menu-render_view_context_menu.cc.patch +++ b/patches/chrome-browser-renderer_context_menu-render_view_context_menu.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc -index 6043ab9230474f36fb901ddfeee456615ed30183..d6651c5f599d814ea9ee93df239c1e13f4a389b2 100644 +index d0578f71b353dd087bd9e6edc8efa4dfb1d4c215..54833e552d97ffca2e1edbb37a4fb523ebd88e40 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc -@@ -1631,6 +1631,7 @@ void RenderViewContextMenu::AppendSearchProvider() { +@@ -1632,6 +1632,7 @@ void RenderViewContextMenu::AppendSearchProvider() { selection_navigation_url_ = match.destination_url; if (!selection_navigation_url_.is_valid()) return; diff --git a/patches/chrome-browser-resources-downloads-toolbar.js.patch b/patches/chrome-browser-resources-downloads-toolbar.js.patch index 91024a61229a..9492143c8206 100644 --- a/patches/chrome-browser-resources-downloads-toolbar.js.patch +++ b/patches/chrome-browser-resources-downloads-toolbar.js.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/downloads/toolbar.js b/chrome/browser/resources/downloads/toolbar.js -index a14fbf89bfe7eb925e9a9febdd280454d573c90b..8caf240db979c09d30a36a71ab74d31e582b8b8c 100644 +index 9d6413739b71440ad88eb3bd57b0f415d425299c..8aecba85bed4c7d3461f2ec7f04734c1eeab0ff9 100644 --- a/chrome/browser/resources/downloads/toolbar.js +++ b/chrome/browser/resources/downloads/toolbar.js @@ -4,7 +4,7 @@ diff --git a/patches/chrome-browser-resources-extensions-BUILD.gn.patch b/patches/chrome-browser-resources-extensions-BUILD.gn.patch index 025c6cfdb41b..9c348b7ee4e7 100644 --- a/patches/chrome-browser-resources-extensions-BUILD.gn.patch +++ b/patches/chrome-browser-resources-extensions-BUILD.gn.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/resources/extensions/BUILD.gn b/chrome/browser/resources/extensions/BUILD.gn -index 41882a90448cee3778522c1c1abdd0d5ef675bca..fcfcacabd41712c874d08be461022f38b1e6ff5e 100644 +index cfed148d68be8d0880823b391b55936f942c22cc..2b2989f4ce45b6b74d25d3537865d7d09c54c19e 100644 --- a/chrome/browser/resources/extensions/BUILD.gn +++ b/chrome/browser/resources/extensions/BUILD.gn @@ -57,6 +57,7 @@ generate_grd("build_grd") { diff --git a/patches/chrome-browser-resources-local_discovery-local_discovery.html.patch b/patches/chrome-browser-resources-local_discovery-local_discovery.html.patch deleted file mode 100644 index 16c61429d34a..000000000000 --- a/patches/chrome-browser-resources-local_discovery-local_discovery.html.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/chrome/browser/resources/local_discovery/local_discovery.html b/chrome/browser/resources/local_discovery/local_discovery.html -index 54cdbff5e16b78d5ea9c7c75e82da869d3aae166..630f3bb90f0759d7fa909aef266cc74fcc6082e2 100644 ---- a/chrome/browser/resources/local_discovery/local_discovery.html -+++ b/chrome/browser/resources/local_discovery/local_discovery.html -@@ -30,6 +30,7 @@ - $i18nRaw{registerPrinterInformationMessage} - - -+ -

- -+ -
- - -@@ -85,6 +87,7 @@ -
-

$i18n{availableDevicesTitle}

- -+ - -+ -
- $i18n{noPrintersOnNetworkExplanation} -
- -
- -+ - -
-

$i18n{titleConnector}

-@@ -111,12 +116,14 @@ -
-
-
-+
- -
-

$i18n{myDevicesTitle}

- -+ - -+ -