Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Unified Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 2248403002: Implement origin-based deletion of plugin data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/browsing_data_remover_unittest.cc
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 3364e1dded129fa6b8a28bd689dbfe806e5798df..407ad02b9c8facd4ba821eb0c108f3314112bfd0 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -109,6 +109,10 @@
#include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
#endif
+#if defined(ENABLE_PLUGINS)
+#include "chrome/browser/browsing_data/mock_browsing_data_flash_lso_helper.h"
+#endif
+
class MockExtensionSpecialStoragePolicy;
using content::BrowserThread;
@@ -1053,6 +1057,59 @@ class RemovePermissionPromptCountsTest {
DISALLOW_COPY_AND_ASSIGN(RemovePermissionPromptCountsTest);
};
+#if defined(ENABLE_PLUGINS)
+// A small modification to MockBrowsingDataFlashLSOHelper so that it responds
+// immediately and does not wait for the Notify() call. Otherwise it would
+// deadlock BrowsingDataRemover::RemoveImpl.
+class TestBrowsingDataFlashLSOHelper : public MockBrowsingDataFlashLSOHelper {
+ public:
+ explicit TestBrowsingDataFlashLSOHelper(TestingProfile* profile)
+ : MockBrowsingDataFlashLSOHelper(profile) {}
+
+ void StartFetching(const GetSitesWithFlashDataCallback& callback) override {
+ MockBrowsingDataFlashLSOHelper::StartFetching(callback);
+ Notify();
+ }
+
+ private:
+ ~TestBrowsingDataFlashLSOHelper() override {}
+
+ DISALLOW_COPY_AND_ASSIGN(TestBrowsingDataFlashLSOHelper);
+};
+
+class RemovePluginDataTester {
+ public:
+ explicit RemovePluginDataTester(TestingProfile* profile)
+ : helper_(new TestBrowsingDataFlashLSOHelper(profile)) {
+ BrowsingDataRemoverFactory::GetForBrowserContext(profile)
+ ->OverrideFlashLSOHelperForTesting(helper_);
+ }
+
+ void AddDomain(const std::string& domain) {
+ helper_->AddFlashLSODomain(domain);
+ }
+
+ const std::vector<std::string>& GetDomains() {
+ // TestBrowsingDataFlashLSOHelper is synchronous, so we can immediately
+ // return the fetched domains.
+ helper_->StartFetching(
+ base::Bind(&RemovePluginDataTester::OnSitesWithFlashDataFetched,
+ base::Unretained(this)));
+ return domains_;
+ }
+
+ private:
+ void OnSitesWithFlashDataFetched(const std::vector<std::string>& sites) {
+ domains_ = sites;
+ }
+
+ std::vector<std::string> domains_;
+ scoped_refptr<TestBrowsingDataFlashLSOHelper> helper_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemovePluginDataTester);
+};
+#endif
+
// Test Class ----------------------------------------------------------------
class BrowsingDataRemoverTest : public testing::Test {
@@ -2737,6 +2794,35 @@ TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) {
}
}
+#if defined(ENABLE_PLUGINS)
+TEST_F(BrowsingDataRemoverTest, RemovePluginData) {
+ RemovePluginDataTester tester(GetProfile());
+
+ tester.AddDomain(kOrigin1.host());
+ tester.AddDomain(kOrigin2.host());
+ tester.AddDomain(kOrigin3.host());
+
+ std::vector<std::string> expected = {
+ kOrigin1.host(), kOrigin2.host(), kOrigin3.host() };
+ EXPECT_EQ(expected, tester.GetDomains());
+
+ // Delete data with a filter for the registrable domain of |kOrigin3|.
+ RegistrableDomainFilterBuilder filter_builder(
+ RegistrableDomainFilterBuilder::WHITELIST);
+ filter_builder.AddRegisterableDomain(kTestRegisterableDomain3);
+ BlockUntilOriginDataRemoved(browsing_data::ALL_TIME,
+ BrowsingDataRemover::REMOVE_PLUGIN_DATA,
+ filter_builder);
+
+ // Plugin data for |kOrigin3.host()| should have been removed.
+ expected.pop_back();
+ EXPECT_EQ(expected, tester.GetDomains());
+
+ // TODO(msramek): Mock PluginDataRemover and test the complete deletion
+ // of plugin data as well.
+}
+#endif
+
class MultipleTasksObserver {
public:
// A simple implementation of BrowsingDataRemover::Observer.
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | chrome/browser/browsing_data/cookies_tree_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698