Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(privacy): Update Shred behaviour to clear all cache data (uplift to 1.71.x) #25886

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/brave_shields/core/common/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ BASE_FEATURE(kBraveReduceLanguage,
BASE_FEATURE(kBraveShredFeature,
"BraveShredFeature",
base::FEATURE_DISABLED_BY_DEFAULT);
// When enabled, brave shred will clear all cache data when shredding.
BASE_FEATURE(kBraveShredCacheData,
"BraveShredCacheData",
base::FEATURE_DISABLED_BY_DEFAULT);
// When enabled, show Strict (aggressive) fingerprinting mode in Brave Shields.
BASE_FEATURE(kBraveShowStrictFingerprintingMode,
"BraveShowStrictFingerprintingMode",
Expand Down
1 change: 1 addition & 0 deletions components/brave_shields/core/common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BASE_DECLARE_FEATURE(kBraveExtensionNetworkBlocking);
BASE_DECLARE_FEATURE(kBraveLocalhostAccessPermission);
BASE_DECLARE_FEATURE(kBraveReduceLanguage);
BASE_DECLARE_FEATURE(kBraveShredFeature);
BASE_DECLARE_FEATURE(kBraveShredCacheData);
BASE_DECLARE_FEATURE(kBraveShowStrictFingerprintingMode);
BASE_DECLARE_FEATURE(kCosmeticFilteringExtraPerfMetrics);
BASE_DECLARE_FEATURE(kCosmeticFilteringJsPerformance);
Expand Down
15 changes: 13 additions & 2 deletions ios/brave-ios/Sources/Brave/Frontend/Browser/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,8 @@ class TabManager: NSObject {
) {
guard let etldP1 = url.baseDomain else { return }
forgetTasks[tab.type] = forgetTasks[tab.type] ?? [:]
// Start a task to delete all data for this etldP1
// The task may be delayed in case we want to cancel it
forgetTasks[tab.type]?[etldP1] = Task {
try await Task.sleep(seconds: delay)
await self.forgetData(for: url, in: tab)
Expand All @@ -869,12 +871,21 @@ class TabManager: NSObject {
await FaviconFetcher.deleteCache(for: url)
guard let etldP1 = url.baseDomain else { return }

// Start a task to delete all data for this etldP1
// The task may be delayed in case we want to cancel it
let dataStore = tab.webView?.configuration.websiteDataStore
// Delete 1P data records
await dataStore?.deleteDataRecords(
forDomain: etldP1
)
if BraveCore.FeatureList.kBraveShredCacheData.enabled {
// Delete all cache data (otherwise 3P cache entries left behind
// are visible in Manage Website Data view brave-browser #41095)
let cacheTypes = Set([
WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeDiskCache,
WKWebsiteDataTypeOfflineWebApplicationCache,
])
let cacheRecords = await dataStore?.dataRecords(ofTypes: cacheTypes) ?? []
await dataStore?.removeData(ofTypes: cacheTypes, for: cacheRecords)
}

// Delete the history for forgotten websites
if let historyAPI = self.historyAPI {
Expand Down
1 change: 1 addition & 0 deletions ios/browser/api/features/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ OBJC_EXPORT
@property(class, nonatomic, readonly) Feature* kBraveReduceLanguage;
@property(class, nonatomic, readonly) Feature* kBraveSearchDefaultAPIFeature;
@property(class, nonatomic, readonly) Feature* kBraveShredFeature;
@property(class, nonatomic, readonly) Feature* kBraveShredCacheData;
@property(class, nonatomic, readonly)
Feature* kBraveShowStrictFingerprintingMode;
@property(class, nonatomic, readonly) Feature* kBraveSync;
Expand Down
5 changes: 5 additions & 0 deletions ios/browser/api/features/features.mm
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ + (Feature*)kBraveShredFeature {
initWithFeature:&brave_shields::features::kBraveShredFeature];
}

+ (Feature*)kBraveShredCacheData {
return [[Feature alloc]
initWithFeature:&brave_shields::features::kBraveShredCacheData];
}

+ (Feature*)kBraveShowStrictFingerprintingMode {
return
[[Feature alloc] initWithFeature:&brave_shields::features::
Expand Down
62 changes: 35 additions & 27 deletions ios/browser/flags/about_flags.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,41 @@
kBraveWalletTransactionSimulationsFeature), \
})

#define BRAVE_SHIELDS_FEATURE_ENTRIES \
EXPAND_FEATURE_ENTRIES( \
{ \
"brave-shred", \
"Enable Brave 'Shred' Feature", \
"Enable the Brave ‘Shred’ feature which will allow a user to " \
"easily delete all site data on demand or automatically when " \
"closing a site or terminating the application.", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE(brave_shields::features::kBraveShredFeature), \
}, \
{ \
"https-by-default", \
"Use HTTPS by Default", \
"Attempt to connect to all websites using HTTPS before falling " \
"back to HTTP.", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE(net::features::kBraveHttpsByDefault), \
}, \
{ \
"https-only-mode", \
"Enable HTTPS By Default Strict Mode", \
"Connect to all websites using HTTPS and display an intersitital " \
"to fallback to HTTP", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE( \
security_interstitials::features::kHttpsOnlyMode), \
#define BRAVE_SHIELDS_FEATURE_ENTRIES \
EXPAND_FEATURE_ENTRIES( \
{ \
"brave-shred", \
"Enable Brave 'Shred' Feature", \
"Enable the Brave ‘Shred’ feature which will allow a user to " \
"easily delete all site data on demand or automatically when " \
"closing a site or terminating the application.", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE(brave_shields::features::kBraveShredFeature), \
}, \
{ \
"brave-shred-cache-data", \
"Shred Clears All Cache Data", \
"Shred feature will also remove all cache data, in addition to the " \
"data associated with the site being shred.", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE(brave_shields::features::kBraveShredCacheData), \
}, \
{ \
"https-by-default", \
"Use HTTPS by Default", \
"Attempt to connect to all websites using HTTPS before falling " \
"back to HTTP.", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE(net::features::kBraveHttpsByDefault), \
}, \
{ \
"https-only-mode", \
"Enable HTTPS By Default Strict Mode", \
"Connect to all websites using HTTPS and display an intersitital " \
"to fallback to HTTP", \
flags_ui::kOsIos, \
FEATURE_VALUE_TYPE( \
security_interstitials::features::kHttpsOnlyMode), \
})

#if BUILDFLAG(ENABLE_AI_CHAT)
Expand Down
Loading