Commit Graph
34 Commits
Author SHA1 Message Date
Mario Sanchez Prada b2e4de697f Migrate usage of base::Passed with base::BindOnce to std::move
A new static assertion has been added upstream and otherwise the
build will fail for Linux now, as well as for other platforms in
the next release.

Chromium change:

https://source.chromium.org/chromium/chromium/src/+/ad0da8ebec488b6b3696b44d2da80744f8a90d17
https://source.chromium.org/chromium/chromium/src/+/63714a9ffe267a0212f4120a188f45408555a993

commit ad0da8ebec488b6b3696b44d2da80744f8a90d17
Author: Daniel Cheng <dcheng@chromium.org>
Date:   Mon Feb 22 21:07:22 2021 +0000

    Disallow base::Passed() from being used with base::BindOnce().

    The assert is currently only enabled on OS_LINUX. Platforms will be
    incrementally fixed until the assert is enabled everywhere.

    Bug: 1180750

commit 63714a9ffe267a0212f4120a188f45408555a993
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Feb 26 09:51:28 2021

    [base] Disallow base::BindOnce() + base::Passed() use on iOS.

    std::move() and base::Passed() mean the same thing for base::BindOnce(),
    so use the standard library idiom instead.

    Bug: 1180750
2021-03-23 14:55:33 -04:00
Jocelyn Liu e94e2c02a5 Remove base::Unretained usage in BraveBrowsingDataRemoverDelegate::ClearIPFSCache 2021-02-10 22:18:56 -08:00
mkarolin 289ac4aa21 Moved brave_clear_browsing_data_browsertest.cc to its own target. 2021-02-04 23:52:44 -05:00
Mario Sanchez Prada eb35c13518 Drop references to ContentSettingsType::PLUGINS in Brave-specific code
This type is now deprecated upstream and cleared from preferences (as
it's considered obsolete) now when starting chromium, so let's drop
the remaining references from the code and fix a build issue at the
same time now that upstream's EphemeralProvider has been removed.

Chromium change:

https://source.chromium.org/chromium/chromium/src/+/ce14b8610aa681638eb5063c5013518d387e545e

commit ce14b8610aa681638eb5063c5013518d387e545e
Author: Illia Klimov <elklm@google.com>
Date:   Wed Dec 9 21:20:36 2020 +0000

    Remove Ephemeral provider.

    Flash has been removed from Chrome almost entirely. Ephemeral provider
    was used only by these two content settings - PLUGINS and
    PERIODIC_BACKGROUND_SYNC. PERIODIC_BACKGROUND_SYNC is no longer
    registered and PLUGINS is deprecated.

    Bug: 1149381
2021-02-04 23:52:23 -05:00
Mario Sanchez Prada 98dd8989ed Reference constants from chrome_browsing_data_remover
These constants were previously defined in a different namespace
(i.e. ChromeBrowsingDataRemoverDelegate) and have been now moved
into chrome_browsing_data_remover instead.

Chromium change:

https://source.chromium.org/chromium/chromium/src/+/e7eca7b2ee50d035dea12e055c36823666f697b8

commit e7eca7b2ee50d035dea12e055c36823666f697b8
Author: Glen Robertson <glenrob@chromium.org>
Date:   Thu Nov 26 03:52:57 2020 +0000

    Separate ChromeBrowsingDataRemover constants from Delegate

    Constants that were defined in chrome_browsing_data_remover_delegate.h
    have been moved to a separate header in its own gn target, so that
    dependents like profile can avoid taking a dependency on all of
    //chrome/browser:browser just for access to the constants.

    This is done in prep for moving profile out of the //c/b target.

    Bug: 1149277
2021-02-04 23:52:22 -05:00
mkarolin fedf5ef049 Fixes header includes. 2021-02-04 23:52:11 -05:00
mkarolin fd687132bc ChromeBrowsingDataRemover constants moved to their own header.
Chromium change:

https://source.chromium.org/chromium/chromium/src/+/e7eca7b2ee50d035dea12e055c36823666f697b8

commit e7eca7b2ee50d035dea12e055c36823666f697b8
Author: Glen Robertson <glenrob@chromium.org>
Date:   Thu Nov 26 03:52:57 2020 +0000

    Separate ChromeBrowsingDataRemover constants from Delegate

    Constants that were defined in chrome_browsing_data_remover_delegate.h
    have been moved to a separate header in its own gn target, so that
    dependents like profile can avoid taking a dependency on all of
    //chrome/browser:browser just for access to the constants.

    This is done in prep for moving profile out of the //c/b target.

    Bug: 1149277
2021-02-04 23:52:10 -05:00
Brian R. Bondy 3b4fb821ca Fix crash when clearing IPFS cache
The problem is the TracingDataTypes are stored in a set, so if you re-use one of them that's already used it will crash.
See `std::set<TracingDataType> pending_sub_tasks_`.

So I just patched in a new tracing data type and now the crash is gone.
2021-01-17 20:40:08 -05:00
Jocelyn Liu 0d78434a6a Clear IPFS cache when clearing browsing data 2021-01-15 09:35:41 -08:00
mkarolin f6f6d30dc0 Formatting fixes. 2021-01-05 21:27:44 -05:00
mkarolin 7ba3c3f84b Lint fixes. 2021-01-05 21:27:44 -05:00
Mario Sanchez Prada 63b895ab55 Remove BraveSiteSettingsCounter, it's no longer necessary
With the migration away from ResourceIds, the BraveSiteSettingsCounter
class is no longer needed, since upstream's SiteSettingsCounter will be
good enough now that we don't need to perform a "subsearch" for the
ContentSettingsType::PLUGINS type, to consider Brave-specific cases.

In this new worls where we have Brave-specific ContentSettingsTypes,
SiteSettingsCounter::Count() will suffice to account for Brave's own
ContentSettingsTypes, so there's no need to have a subclass to deal
with them now, therefore we have to remove it (otherwise the count
won't be correct, at least in its current form, since the same type
would be counted twice).
2021-01-05 21:27:44 -05:00
Mario Sanchez Prada e6fedc966a Migrate away from using ResourceIdentifier now that it's gone upstream
As part of upstream bug 1134547[1], the ResourceIdentifier that Brave
Shields relied on so far has been completely removed[2], so we need to
adapt our code not to rely on it anymore so that we can keep building
Brave correctly on the latest dev channel release of Chromium 88.

This patch implements the first step to adapt Brave to this new
scenario, by moving into using Brave-specific values of the
ContentSettingsType enumeration instead of using the PLUGINS
type plus a ResourceIdentifier as we did before.

Note that this patch adds a "bs_" prefix to all the BraveShields
constants, to avoid collisions with the COOKIES and JAVASCRIPT
upstream content types. Added prefix to all constants for
consistency + update TS code.

Note that the goal of this change is simply to keep Brave building,
running and passing the tests so that we can continue working on the
rebase. Further work will be still needed in follow-up patches to
fully migrate the code base to a post-Flash world by changing those
bits that don't make sense anymore, and simplifying things as much
as possible.

[1] https://crbug.com/1134547
[2] https://crrev.com/c/2500161
2021-01-05 21:27:44 -05:00
mkarolin 3b1130c6c9 [Browser Tests] Added missing header includes. 2020-12-08 15:25:54 -05:00
Pete Miller 7d49956803 Brave Today: use profile prefs, and remove feed from cache when user clears history
Profile prefs are now used for saving publisher / source enabled or disabled. This is more future proof as this data is not ephemeral.
Also provides a method for resetting those prefs from the NTP "customize" panel. Now that this is a regular profile pref, this could also be cleared from the regular Settings page.
Sets up an event flow from clearing history to the background process which caches the feed. It's important to clear the feed cache when the history is cleared since the feed assigns higher rank to content from hosts that the user has previously visited.
Also allows Today to be turned on and off.
2020-11-07 20:58:50 -08:00
Gyuyoung Kim b0ebf11e7a Fix deps in //brave/tests
Remove unnecessary includes header files and
add missing dependencies to the proper targets.

Additionally, this PR copies TranslateManagerTest from
upstream code to TranslateManagerUnittest in order to
avoid touching the upstream code. Then, this PR renames
the file to brave_translate_manager_unittest.cc.

Resolves brave/brave-browser#10613.
2020-10-29 19:23:40 +09:00
Mario Sanchez Prada f07cca22fd Replace param-less GetOffTheRecordProfile() with GetPrimaryOTRProfile()
Chromium change:

https://chromium.googlesource.com/chromium/src/+/b06b34efeb4d6648d9b014c7cf8bf5e73284b69c

commit b06b34efeb4d6648d9b014c7cf8bf5e73284b69c
Author: Ramin Halavati <rhalavati@chromium.org>
Date:   Thu Sep 3 12:01:34 2020 +0000

    Remove defaults from Profile::[Get/Has]OffTheRecordProfile().

    The default values for OffTheRecord profile functions are removed and
    all remaining use cases are replaced with [Get/Has]PrimaryOTRProfile.

    The cases that need further update later are marked with TODO.

    This CL does NOT change any behavior.

    Bug: 1033903
2020-10-28 14:00:05 -04:00
Brian Clifton b70bb4cb56 Update where browser count is checked for BraveClearDataOnExitTest
With visibility handler added `chrome::GetTotalBrowserCount` was always
returning a non-zero count. Instead of checking on main thread tear
down, check is moved to browser process tear down.
2020-10-06 01:34:41 -07:00
Mario Sanchez Prada dbf94d6e23 Update signatures of RemoveEmbedderData() and OnBrowsingDataRemoverDone()
Chromium change:

https://chromium.googlesource.com/chromium/src/+/7492117659dab49c3f4d7c16af696af428e5e3a1

commit 7492117659dab49c3f4d7c16af696af428e5e3a1
Author: Marc Treib <treib@chromium.org>
Date:   Tue Jul 7 15:19:56 2020 +0000

    [CBD] Wire password deletion failure to the UI

    Before this CL, BrowsingDataRemover did not expose the concept of
    "deletion failure", i.e. when a requested deletion could not be
    completed. (An example of such a deletion failure is a timeout, which
    BrowsingDataRemoverImpl sets to 30 seconds.)

    This CL adds the concept of "failed data types" to the API. They're
    represented as a bitmask of DataTypes - the same format that's used to
    request deletion in the various Remove*() methods.

    So far, the only data type that will actually report deletion errors is
    DATA_TYPE_PASSWORDS, but support for more types can easily be added.
    None of the clients/observers does anything with the new information
    yet; that's left for a future CL.

    Bug: 1086433
2020-09-11 14:45:30 -04:00
mkarolin 52871b629f OriginType and DataType enums were updated to uint64_t.
Chromium change:

https://chromium.googlesource.com/chromium/src/+/c3305c04ac6800d488bfc8b2f3249fd13186984a

commit c3305c04ac6800d488bfc8b2f3249fd13186984a
Author: Marcus Pasell <mapasell@microsoft.com>
Date:   Wed Jun 3 22:14:36 2020 +0000

    Update OriginType and DataType enums to uint64_t

    Update the enums used by the BrowsingDataRemover to be 64bit unsigned
    to make room for future additions. Update usages and bitmasks to also
    reflect this change.

    Bug: 668114
2020-08-06 17:31:53 -04:00
Pranjal Jumde 9c2501854e Fix 9365: Add gn check to npm scripts 2020-07-20 09:58:02 -07:00
mkarolin 35e73f73f7 [Browser Tests] IWYU browser_test.h.
Chromium change:

https://chromium.googlesource.com/chromium/src/+/919ce657e4e37dfa13758f1eb8fe0e9ef7ab1b20

commit 919ce657e4e37dfa13758f1eb8fe0e9ef7ab1b20
Author: Peter Kasting <pkasting@chromium.org>
Date:   Thu May 7 10:22:36 2020 +0000

    Add missing #includes of browser_test.h.

    This is a step towards doing full IWYU of browser_test.h, which will
    have other benefits.

    Completely mechanical and already R+ed as part of r765923.

    Bug: none
2020-07-01 18:12:03 -04:00
mkarolin 34e8d0f2f7 Content Settings updated to Utilize Time/Scope Restrictions.
Chromium change:

https://chromium.googlesource.com/chromium/src/+/f62a1294a4b54626abf1275e47057e5564a7bb3a

commit f62a1294a4b54626abf1275e47057e5564a7bb3a
Author: Brandon Maslen <brandm@microsoft.com>
Date:   Wed Apr 29 07:37:10 2020 +0000

    Update Content Settings to Utilize Time/Scope Restrictions to Get/Set Settings.

    Currently all content/website settings are not bounded or scoped aside
    from possibly being ephemeral and held in memory only. In order to
    support scenarios for the Storage Access API and future permission
    time-boxing efforts the concept of scoping settings is needed.

    This change introduces the notion of a ContentSettingConstraints struct
    that can be optionally provided when setting a content or website
    setting. The constraint consists of an optional base::Time to
    specify the expiration that a setting should use,as well as a
    SessionModel to specify the lifetime model of the setting.

    The following initial SessionModel have been specified; however, future
    options such as TabOnly may be added to accommodate permissions scoping:
    Durable:     Settings persist forever and are bounded only by an expiry
                 date, if set. Will be persisted to disk to survive session
                 restarts.
    UserSession: Settings will persist no longer than a user session
                 regardless of expiry date, if set.

    All types of scopes may be constrained by an upper bound duration. This
    allows settings to expire after a set period of time has passed.

    The majority of this new behaviour is contained within the
    HostContentSettingsMap and associated Providers and supporting classes.
    New constraint parameters have been added as optional to setters and
    unless opted in by new callers will behave as they did prior to this
    change. The getters have been updated so that a direct retrieval of
    a setting will only return a value if a currently un-expired setting
    exists. If an array of values is retrieved for future use like with
    GetSettingsForOneType the expiry date and convenience method
    IsExpired() have been added to ensure consumers can accurately
    determine if a setting is relevant.

    In order to cleanup expired Durable entries we will validate the
    expiration time on entries, if set, when we read our settings from
    prefs. If present any expired entries will be cleaned up at this time.

    New test cases have been added to validate the HCSM behaviour changes
    as well as the PrefProvider and supporting classes.

    In addition to this the first consumer of these changes has been added
    in the Storage Access API permissions context code. This ensures that
    the API can both set either a UserSession or Durable grant with an
    associated duration as well as determine the number of existing grants
    that are UserSession only as required.

    Bug: 989663
2020-07-01 18:12:02 -04:00
Simon Hong 0d2a1a216d Deleted fingerprinting v2 feature flag
v2 is used by default.
2020-06-03 11:31:21 +09:00
mkarolin 357902c33e Do not create global GURL instances.
GURL constructor uses scheme registry which now DCHECKs if accessed
before being initialized with schemes.

Converted BraveStatsUpdater::g_base_update_url_ to std::string.
Converted SuggestedSitesProvider::suggested_sites_ to method local
static.
Converted oauth_url in binance_service.cc to const char[].

Also, moved inside functions in several unit tests.

Chromium change:

https://chromium.googlesource.com/chromium/src/+/2add7d44778f7be638639aeb26a3b14f0b222e09

commit 2add7d44778f7be638639aeb26a3b14f0b222e09
Author: Michael Thiessen <mthiesse@chromium.org>
Date:   Wed Feb 5 13:49:38 2020 +0000

    Lock SchemeRegistry on first use.

    This change locks the SchemeRegistry on first use, which required
    refactoring url_util.cc to differentiate between SchemeRegistry use for
    adding Schemes, and SchemeRegistry use for using Schemes.

    Tests can now only modify schemes after initialization by calling
    url::UnlockForTests(), which creates a scoped object that resets the
    schemes, so tests can't mistakenly leave global scheme state modified.

    This change required changes to browser startup to decouple scheme
    registration from ContentMain, found here:
    https://chromium-review.googlesource.com/c/chromium/src/+/1945926

    Doc: https://docs.google.com/document/d/1kDKqBaq-b6EbUm0F4ea7ARoksUcj1KUx3qxFuSXEwM4/edit

    Bug: 783819
2020-05-26 09:52:30 -04:00
samartnik 031207472c Made brave_unit_tests runnable for android 2020-04-14 10:52:00 -04:00
mkarolin 01b93e625e Migrate shield settings.
Migrates all shields settings patterns to use wildcard for protocol and port.

This was needed for cookies due to Chromium change that uses
SiteForCookies which doesn't contain port information to match settings
patterns.

However, using wildcards for protocol and port makes sense for all
shields settings.

Chromium change:

https://chromium.googlesource.com/chromium/src/+/5d02d9e0ab081fb052eed0ab65581fb5b4622fa4

commit 5d02d9e0ab081fb052eed0ab65581fb5b4622fa4
Author: Maks Orlovich <morlovich@chromium.org>
Date:   Sun Dec 15 22:14:10 2019 +0000

    Give ResourceRequest::site_for_cookies proper type.

    (With net::RedirectInfo matching it as well).

    It previously being a URL was highly misleading since:
    1) There was a special meaning to empty URLs
    2) The path bits weren't really guaranteed to exist.

    ... And also having a dedicated type will simplify computations by
    centralizing the use... in following CLs.

    Bug: 577565
2020-03-19 16:51:50 -04:00
Simon Hong 294b7c1768 Subclass ChromeBrowsingDataRemoverDelegate
We don't need to subclass HostContentsSettingsMap to clear shields
settings. BraveBrowsingDataRemoverDelegateTest is added.
2020-02-21 07:52:59 +09:00
Simon Hong 7be2ab0142 Add tests for BraveSiteSettingsCount 2020-02-21 07:52:59 +09:00
Simon Hong a85a399a16 Clear shields settings via clear browsing data dialog
So far, shields settings are also cleard with "All time" time range.
With "All time" range option, browser nuke whole plugins type data.
With non "All time" range option, browser only clears plugins type for
empty resource ids which is flash type.
This commit makes browser clear shields data also with non "All time" range.
2020-02-21 07:52:59 +09:00
mkarolin 4cfe0380da browser_shutdown::ShutdownType is now an enum class.
Chromium change:

https://chromium.googlesource.com/chromium/src/+/ae8a5b1faf6dee0e2363ce04a9bad6b073b7baeb

commit ae8a5b1faf6dee0e2363ce04a9bad6b073b7baeb
Author: Greg Thompson <grt@chromium.org>
Date:   Thu Nov 21 12:35:36 2019 +0000

    Reland: Browser shutdown cleanups (no functional changes).

    - Make ShutdownType an enum class.
    - Introduce browser_shutdown::HasShutdownStarted as a convenience.
    - Switch from UMA macros to functions for one-shot metrics.

    (cherry picked from commit 11936b318f36c4624c9bcba47f61f65cf457dc20)

    BUG=958865
2020-01-29 07:42:50 -05:00
mkarolin 54c1db4f3a Browser test: fixes waiting for browser to open/close. 2019-10-10 02:53:27 -04:00
mkarolin 5bd5f81e7c BrowserAddedObserver was removed.
Chromium change:

https://chromium.googlesource.com/chromium/src/+/9ce426007956a2db57f880721c247c0c8a824de6

commit 9ce426007956a2db57f880721c247c0c8a824de6
Author: Evan Stade <estade@chromium.org>
Date:   Mon Jul 29 23:56:14 2019 +0000

    Remove test util class BrowserAddedObserver

    It used NOTIFICATION_BROWSER_OPENED.

    Most of the time in these tests, the new browser is opened
    with chrome::NewWindow or chrome::NewEmptyWindow, which
    are usually synchronous, so waiting is not needed. The
    exception is when they trigger session restore, and in
    those cases it's sufficient to use
    SessionRestoreTestHelper::Wait.

    Bug: 268984
2019-10-10 02:53:24 -04:00
Max Karolinskiy 02e63a950d Clear browsing data on exit when instructed by the user.
Fixes brave/brave-browser#492

1. Adds a new "On exit" tab to chrome://settings/clearBrowserData dialog
with the same options as on the "Advanced" tab and a "Save" button. By
default all "On exit" options are turned off. When an option is modified
from the current state the Save button becomes enabled and allows the
user to save the "on exit" options. The options are saved to profile's
preferences: new *OnExit preferences have been added for each option.

2. Clear browsing data on exit functionality is triggered from
BraveBrowserMainParts::PreShutdown override. For each loaded profile
the code checks if user selected any on exit options and if so then a
BrowsingDataRemover is called.

3. Adds BraveClearDataOnExitTest and BraveClearDataOnExitTwoBrowsersTest
browser tests that verify that:
- the removal of the browsing data is triggered only when an "on exit"
  preference is set;
- the removal flags are constrcuted correctly;
- the removal is called only when the browser is exiting (tests with
  OTR/Guest/multiple profiles).
2019-02-28 22:42:45 -05:00