1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_BROWSING_DATA_SAME_SITE_DATA_REMOVER_IMPL_H_ 6 #define CONTENT_BROWSER_BROWSING_DATA_SAME_SITE_DATA_REMOVER_IMPL_H_ 7 8 #include <set> 9 #include <string> 10 11 #include "base/callback.h" 12 #include "content/public/browser/browser_context.h" 13 14 namespace net { 15 class CookieStore; 16 } 17 18 namespace content { 19 20 class CONTENT_EXPORT SameSiteDataRemoverImpl { 21 public: 22 explicit SameSiteDataRemoverImpl(BrowserContext* browser_context); 23 ~SameSiteDataRemoverImpl(); 24 25 // Returns a set containing domains associated with deleted SameSite=None 26 // cookies. 27 const std::set<std::string>& GetDeletedDomainsForTesting(); 28 29 // Deletes cookies with SameSite attribute value NO_RESTRICTION 30 // from the CookieStore and stores domains of deleted cookies in the 31 // same_site_none_domains_ vector. The closure is called after cookies 32 // have been deleted. 33 void DeleteSameSiteNoneCookies(base::OnceClosure closure); 34 35 // Clears additional storage for domains that have cookies with SameSite value 36 // NO_RESTRICTION from the StoragePartition. Storage is cleared based on the 37 // domains of the cookies deleted in DeleteSameSiteNoneCookies(). 38 // 39 // This is called safely on an instance which is destroyed after the function 40 // call since it's not needed for the function execution. 41 void ClearStoragePartitionData(base::OnceClosure closure); 42 43 // For testing purposes only. 44 void OverrideStoragePartitionForTesting(StoragePartition* storage_partition); 45 46 private: 47 BrowserContext* browser_context_; 48 StoragePartition* storage_partition_; 49 std::set<std::string> same_site_none_domains_; 50 51 DISALLOW_COPY_AND_ASSIGN(SameSiteDataRemoverImpl); 52 }; 53 54 } // namespace content 55 56 #endif // CONTENT_BROWSER_BROWSING_DATA_SAME_SITE_DATA_REMOVER_IMPL_H_ 57