Commit 1090bf6c authored by Ryan Sturm's avatar Ryan Sturm Committed by Commit Bot

Clearing page load capping blacklist when user clears history

This call clears persisted state that is tied to navigation history.

Bug: 797981
Change-Id: Ie0e2224f673b07ef6edc80e30f0cbb518dea0029
Reviewed-on: https://chromium-review.googlesource.com/1119157Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Commit-Queue: Ryan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571329}
parent 2b15f5bd
......@@ -26,6 +26,9 @@
#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/data_use_measurement/page_load_capping/page_load_capping_blacklist.h"
#include "chrome/browser/data_use_measurement/page_load_capping/page_load_capping_service.h"
#include "chrome/browser/data_use_measurement/page_load_capping/page_load_capping_service_factory.h"
#include "chrome/browser/domain_reliability/service_factory.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
......@@ -569,6 +572,15 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
delete_end_);
}
// |previews_service| is null if |profile_| is off the record.
PageLoadCappingService* page_load_capping_service =
PageLoadCappingServiceFactory::GetForBrowserContext(profile_);
if (page_load_capping_service &&
page_load_capping_service->page_load_capping_blacklist()) {
page_load_capping_service->page_load_capping_blacklist()->ClearBlackList(
delete_begin_, delete_end_);
}
#if defined(OS_ANDROID)
OomInterventionDecider* oom_intervention_decider =
OomInterventionDecider::GetForBrowserContext(profile_);
......
......@@ -12,8 +12,11 @@
#include "base/strings/string_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
#include "chrome/browser/data_use_measurement/page_load_capping/chrome_page_load_capping_features.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
......@@ -21,6 +24,8 @@
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_delegate.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test_utils.h"
......@@ -412,3 +417,44 @@ IN_PROC_BROWSER_TEST_F(PageLoadCappingBrowserTest,
https_test_server_.reset();
}
IN_PROC_BROWSER_TEST_F(PageLoadCappingBrowserTest,
NavigationDataREmovedFromBlacklist) {
https_test_server_->RegisterRequestHandler(base::BindRepeating(
&PageLoadCappingBrowserTest::HandleRequest, base::Unretained(this)));
https_test_server_->ServeFilesFromSourceDirectory(base::FilePath(kDocRoot));
ASSERT_TRUE(https_test_server_->Start());
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
// Load a page and ignore the InfoBar.
ui_test_utils::NavigateToURL(
browser(), https_test_server_->GetURL("/page_capping.html"));
ASSERT_EQ(1u, InfoBarService::FromWebContents(contents)->infobar_count());
// Load a page and ignore the InfoBar.
ui_test_utils::NavigateToURL(
browser(), https_test_server_->GetURL("/page_capping.html"));
ASSERT_EQ(1u, InfoBarService::FromWebContents(contents)->infobar_count());
// Load a page and due to session policy blacklisting, the InfoBar should not
// show.
ui_test_utils::NavigateToURL(
browser(), https_test_server_->GetURL("/page_capping.html"));
ASSERT_EQ(0u, InfoBarService::FromWebContents(contents)->infobar_count());
// Clear the navigation history.
content::BrowsingDataRemover* remover =
content::BrowserContext::GetBrowsingDataRemover(browser()->profile());
remover->Remove(base::Time(), base::Time::Max(),
ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY,
content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB);
// After clearing history, the InfoBar should be allowed again.
ui_test_utils::NavigateToURL(
browser(), https_test_server_->GetURL("/page_capping.html"));
ASSERT_EQ(1u, InfoBarService::FromWebContents(contents)->infobar_count());
https_test_server_.reset();
}
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