1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_clearsitedata_h 8 #define mozilla_clearsitedata_h 9 10 #include "nsIObserver.h" 11 #include "nsTArray.h" 12 13 class nsIHttpChannel; 14 class nsIPrincipal; 15 class nsIURI; 16 17 namespace mozilla { 18 19 class ClearSiteData final : public nsIObserver { 20 public: 21 NS_DECL_ISUPPORTS 22 NS_DECL_NSIOBSERVER 23 24 static void Initialize(); 25 26 private: 27 ClearSiteData(); 28 ~ClearSiteData(); 29 30 static void Shutdown(); 31 32 class PendingCleanupHolder; 33 34 // Starts the cleanup if the channel contains the Clear-Site-Data header and 35 // if the URI is secure. 36 void ClearDataFromChannel(nsIHttpChannel* aChannel); 37 38 // From the Clear-Site-Data header, it returns a bitmap with Type values. 39 uint32_t ParseHeader(nsIHttpChannel* aChannel, nsIURI* aURI) const; 40 41 enum Type { 42 eCache = 0x01, 43 eCookies = 0x02, 44 eStorage = 0x04, 45 }; 46 47 // This method writes a console message when a cleanup operation is going to 48 // be executed. 49 void LogOpToConsole(nsIHttpChannel* aChannel, nsIURI* aURI, Type aType) const; 50 51 // Logging of an unknown type value. 52 void LogErrorToConsole(nsIHttpChannel* aChannel, nsIURI* aURI, 53 const nsACString& aUnknownType) const; 54 55 void LogToConsoleInternal(nsIHttpChannel* aChannel, nsIURI* aURI, 56 const char* aMsg, 57 const nsTArray<nsString>& aParams) const; 58 59 // This method converts a Type to the corrisponding string format. 60 void TypeToString(Type aType, nsAString& aStr) const; 61 }; 62 63 } // namespace mozilla 64 65 #endif // mozilla_clearsitedata_h 66