Commit 86a1c8e8 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Cleanup browsing data flag

This CL removes the flag for clearing browsing data in web/

Bug: none
Change-Id: If7cdadee8e2c88145ee296ccbead9501762d77ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049969Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743027}
parent b66e5ea6
...@@ -3,6 +3,3 @@ ...@@ -3,6 +3,3 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "ios/chrome/browser/browsing_data/browsing_data_features.h" #include "ios/chrome/browser/browsing_data/browsing_data_features.h"
const base::Feature kWebClearBrowsingData{"WebClearBrowsingData",
base::FEATURE_ENABLED_BY_DEFAULT};
...@@ -7,8 +7,4 @@ ...@@ -7,8 +7,4 @@
#include "base/feature_list.h" #include "base/feature_list.h"
// Feature to use the clear browsing data from web instead of the one from
// chrome.
extern const base::Feature kWebClearBrowsingData;
#endif // IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FEATURES_H_ #endif // IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FEATURES_H_
...@@ -112,12 +112,6 @@ class BrowsingDataRemoverImpl : public BrowsingDataRemover { ...@@ -112,12 +112,6 @@ class BrowsingDataRemoverImpl : public BrowsingDataRemover {
// SessionService to use (allow injection of a specific instance for testing). // SessionService to use (allow injection of a specific instance for testing).
SessionServiceIOS* session_service_ = nil; SessionServiceIOS* session_service_ = nil;
// Dummy WKWebView. A WKWebView object is created before deleting cookies. and
// is deleted after deleting cookies is completed. this is a workaround that
// makes sure that there is a WKWebView object alive while accessing
// WKHTTPCookieStore.
WKWebView* dummy_web_view_ = nil;
// Used to delete data from HTTP cache. // Used to delete data from HTTP cache.
scoped_refptr<net::URLRequestContextGetter> context_getter_; scoped_refptr<net::URLRequestContextGetter> context_getter_;
......
...@@ -551,112 +551,31 @@ void BrowsingDataRemoverImpl::RemoveImpl(base::Time delete_begin, ...@@ -551,112 +551,31 @@ void BrowsingDataRemoverImpl::RemoveImpl(base::Time delete_begin,
void BrowsingDataRemoverImpl::RemoveDataFromWKWebsiteDataStore( void BrowsingDataRemoverImpl::RemoveDataFromWKWebsiteDataStore(
base::Time delete_begin, base::Time delete_begin,
BrowsingDataRemoveMask mask) { BrowsingDataRemoveMask mask) {
if (base::FeatureList::IsEnabled(kWebClearBrowsingData)) { web::ClearBrowsingDataMask types = web::ClearBrowsingDataMask::kRemoveNothing;
web::ClearBrowsingDataMask types = if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_APPCACHE)) {
web::ClearBrowsingDataMask::kRemoveNothing; types |= web::ClearBrowsingDataMask::kRemoveAppCache;
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_APPCACHE)) {
types |= web::ClearBrowsingDataMask::kRemoveAppCache;
}
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_COOKIES)) {
types |= web::ClearBrowsingDataMask::kRemoveCookies;
}
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_INDEXEDDB)) {
types |= web::ClearBrowsingDataMask::kRemoveIndexedDB;
}
if (IsRemoveDataMaskSet(mask,
BrowsingDataRemoveMask::REMOVE_LOCAL_STORAGE)) {
types |= web::ClearBrowsingDataMask::kRemoveLocalStorage;
}
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_WEBSQL)) {
types |= web::ClearBrowsingDataMask::kRemoveWebSQL;
}
if (IsRemoveDataMaskSet(mask,
BrowsingDataRemoveMask::REMOVE_CACHE_STORAGE)) {
types |= web::ClearBrowsingDataMask::kRemoveCacheStorage;
}
if (IsRemoveDataMaskSet(mask,
BrowsingDataRemoveMask::REMOVE_VISITED_LINKS)) {
types |= web::ClearBrowsingDataMask::kRemoveVisitedLinks;
}
web::ClearBrowsingData(browser_state_, types, delete_begin,
CreatePendingTaskCompletionClosure());
return;
} }
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_COOKIES)) {
// Converts browsing data types from BrowsingDataRemoveMask to types |= web::ClearBrowsingDataMask::kRemoveCookies;
// WKWebsiteDataStore strings.
NSMutableSet* data_types_to_remove = [[NSMutableSet alloc] init];
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_CACHE_STORAGE)) {
[data_types_to_remove addObject:WKWebsiteDataTypeDiskCache];
[data_types_to_remove addObject:WKWebsiteDataTypeMemoryCache];
} }
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_APPCACHE)) { if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_INDEXEDDB)) {
[data_types_to_remove types |= web::ClearBrowsingDataMask::kRemoveIndexedDB;
addObject:WKWebsiteDataTypeOfflineWebApplicationCache];
} }
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_LOCAL_STORAGE)) { if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_LOCAL_STORAGE)) {
[data_types_to_remove addObject:WKWebsiteDataTypeSessionStorage]; types |= web::ClearBrowsingDataMask::kRemoveLocalStorage;
[data_types_to_remove addObject:WKWebsiteDataTypeLocalStorage];
} }
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_WEBSQL)) { if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_WEBSQL)) {
[data_types_to_remove addObject:WKWebsiteDataTypeWebSQLDatabases]; types |= web::ClearBrowsingDataMask::kRemoveWebSQL;
}
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_INDEXEDDB)) {
[data_types_to_remove addObject:WKWebsiteDataTypeIndexedDBDatabases];
} }
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_COOKIES)) { if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_CACHE_STORAGE)) {
[data_types_to_remove addObject:WKWebsiteDataTypeCookies]; types |= web::ClearBrowsingDataMask::kRemoveCacheStorage;
}
if (![data_types_to_remove count]) {
return;
} }
base::WeakPtr<BrowsingDataRemoverImpl> weak_ptr = GetWeakPtr();
__block base::OnceClosure closure = CreatePendingTaskCompletionClosure();
ProceduralBlock completion_block = ^{
if (BrowsingDataRemoverImpl* strong_ptr = weak_ptr.get())
strong_ptr->dummy_web_view_ = nil;
std::move(closure).Run();
};
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_VISITED_LINKS)) { if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_VISITED_LINKS)) {
ProceduralBlock previous_completion_block = completion_block; types |= web::ClearBrowsingDataMask::kRemoveVisitedLinks;
// TODO(crbug.com/557963): Purging the WKProcessPool is a workaround for
// the fact that there is no public API to clear visited links in
// WKWebView. Remove this workaround if/when that API is made public.
// Note: Purging the WKProcessPool for clearing visisted links does have
// the side-effect of also losing the in-memory cookies of WKWebView but
// it is not a problem in practice since there is no UI to only have
// visited links be removed but not cookies.
completion_block = ^{
if (BrowsingDataRemoverImpl* strong_ptr = weak_ptr.get()) {
web::WKWebViewConfigurationProvider::FromBrowserState(
strong_ptr->browser_state_)
.Purge();
}
previous_completion_block();
};
}
// TODO(crbug.com/661630): |dummy_web_view_| is created to allow
// the -[WKWebsiteDataStore removeDataOfTypes:] API to access the cookiestore
// and clear cookies. This is a workaround for
// https://bugs.webkit.org/show_bug.cgi?id=149078. Remove this
// workaround when it's not needed anymore.
if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::REMOVE_COOKIES)) {
if (!dummy_web_view_)
dummy_web_view_ = [[WKWebView alloc] initWithFrame:CGRectZero];
} }
NSDate* delete_begin_date = web::ClearBrowsingData(browser_state_, types, delete_begin,
[NSDate dateWithTimeIntervalSince1970:delete_begin.ToDoubleT()]; CreatePendingTaskCompletionClosure());
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:data_types_to_remove
modifiedSince:delete_begin_date
completionHandler:completion_block];
} }
void BrowsingDataRemoverImpl::OnKeywordsLoaded(base::Time delete_begin, void BrowsingDataRemoverImpl::OnKeywordsLoaded(base::Time delete_begin,
......
...@@ -441,9 +441,6 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -441,9 +441,6 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flag_descriptions::kBrowserContainerKeepsContentViewName, flag_descriptions::kBrowserContainerKeepsContentViewName,
flag_descriptions::kBrowserContainerKeepsContentViewDescription, flag_descriptions::kBrowserContainerKeepsContentViewDescription,
flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerKeepsContentView)}, flags_ui::kOsIos, FEATURE_VALUE_TYPE(kBrowserContainerKeepsContentView)},
{"web-clear-browsing-data", flag_descriptions::kWebClearBrowsingDataName,
flag_descriptions::kWebClearBrowsingDataDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kWebClearBrowsingData)},
{"send-uma-cellular", flag_descriptions::kSendUmaOverAnyNetwork, {"send-uma-cellular", flag_descriptions::kSendUmaOverAnyNetwork,
flag_descriptions::kSendUmaOverAnyNetworkDescription, flags_ui::kOsIos, flag_descriptions::kSendUmaOverAnyNetworkDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kUmaCellular)}, FEATURE_VALUE_TYPE(kUmaCellular)},
......
...@@ -411,10 +411,6 @@ const char kWalletServiceUseSandboxName[] = "Use Google Payments sandbox"; ...@@ -411,10 +411,6 @@ const char kWalletServiceUseSandboxName[] = "Use Google Payments sandbox";
const char kWalletServiceUseSandboxDescription[] = const char kWalletServiceUseSandboxDescription[] =
"Uses the sandbox service for Google Payments API calls."; "Uses the sandbox service for Google Payments API calls.";
const char kWebClearBrowsingDataName[] = "Web-API for browsing data";
const char kWebClearBrowsingDataDescription[] =
"When enabled the Clear Browsing Data feature is using the web API.";
const char kWebPageTextAccessibilityName[] = const char kWebPageTextAccessibilityName[] =
"Enable text accessibility in web pages"; "Enable text accessibility in web pages";
const char kWebPageTextAccessibilityDescription[] = const char kWebPageTextAccessibilityDescription[] =
......
...@@ -363,11 +363,6 @@ extern const char kUseWKWebViewLoadingDescription[]; ...@@ -363,11 +363,6 @@ extern const char kUseWKWebViewLoadingDescription[];
extern const char kWalletServiceUseSandboxName[]; extern const char kWalletServiceUseSandboxName[];
extern const char kWalletServiceUseSandboxDescription[]; extern const char kWalletServiceUseSandboxDescription[];
// Title and description for the flag to use the Clear browsing data API from
// web.
extern const char kWebClearBrowsingDataName[];
extern const char kWebClearBrowsingDataDescription[];
// Title and description for the flag to enable text accessibility in webpages. // Title and description for the flag to enable text accessibility in webpages.
extern const char kWebPageTextAccessibilityName[]; extern const char kWebPageTextAccessibilityName[];
extern const char kWebPageTextAccessibilityDescription[]; extern const char kWebPageTextAccessibilityDescription[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment