Commit 8e902a99 authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Fixed a bug where incognito browser crashes on Android.

The fix was to add a null pointer check.

Bug: 990624
Change-Id: Iec3283a8a908343661945cf40343cdfbe8aefe37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762223
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689464}
parent d8952b61
......@@ -119,6 +119,20 @@ public final class BrowsingDataBridge {
blacklistedDomainReasons, ignoredDomains, ignoredDomainReasons);
}
/**
* This method tests clearing of specified types of browsing data for incognito profile.
* @param dataTypes An array of browsing data types to delete, represented as values from
* the shared enum {@link BrowsingDataType}.
* @param timePeriod The time period for which to delete the data.
*/
public void clearBrowsingDataIncognitoForTesting(
OnClearBrowsingDataListener listener, int[] dataTypes, @TimePeriod int timePeriod) {
assert mClearBrowsingDataListener == null;
mClearBrowsingDataListener = listener;
nativeClearBrowsingData(getProfile().getOffTheRecordProfile(), dataTypes, timePeriod,
new String[0], new int[0], new String[0], new int[0]);
}
/**
* This fetches sites (registerable domains) that we consider important. This combines many
* pieces of information, including site engagement and permissions. The callback is called
......
......@@ -137,6 +137,27 @@ public class BrowsingDataTest {
}
}
/**
* Test all data deletion for incognito profile. This only checks to see if an android specific
* code crashes or not. For details see, crbug.com/990624.
*/
@Test
@SmallTest
public void testAllDataDeletedForIncognito() throws Exception {
// TODO(roagarwal) : Crashes on BrowsingDataType.SITE_SETTINGS, BrowsingDataType.BOOKMARKS
// data types.
CallbackHelper helper = new CallbackHelper();
TestThreadUtils.runOnUiThreadBlocking(() -> {
BrowsingDataBridge.getInstance().clearBrowsingDataIncognitoForTesting(
helper::notifyCalled,
new int[] {BrowsingDataType.HISTORY, BrowsingDataType.CACHE,
BrowsingDataType.COOKIES, BrowsingDataType.PASSWORDS,
BrowsingDataType.FORM_DATA},
TimePeriod.LAST_HOUR);
});
helper.waitForCallback(0);
}
/**
* Test history deletion.
*/
......
......@@ -955,14 +955,16 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
// cache we should remove offline pages as well.
if ((remove_mask & content::BrowsingDataRemover::DATA_TYPE_CACHE) &&
offline_pages::IsOfflinePagesEnabled()) {
offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_)
->DeleteCachedPagesByURLPredicate(
filter,
base::AdaptCallbackForRepeating(
IgnoreArgument<
offline_pages::OfflinePageModel::DeletePageResult>(
CreateTaskCompletionClosure(
TracingDataType::kOfflinePages))));
auto* offline_page_model =
offline_pages::OfflinePageModelFactory::GetForBrowserContext(
profile_);
if (offline_page_model)
offline_page_model->DeleteCachedPagesByURLPredicate(
filter, base::AdaptCallbackForRepeating(
IgnoreArgument<
offline_pages::OfflinePageModel::DeletePageResult>(
CreateTaskCompletionClosure(
TracingDataType::kOfflinePages))));
}
#endif
......
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