ThirdPartyUtil.h (1521B)
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 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef ThirdPartyUtil_h__ 8 #define ThirdPartyUtil_h__ 9 10 #include "ErrorList.h" 11 #include "mozIThirdPartyUtil.h" 12 #include "mozilla/RefPtr.h" 13 #include "nsIEffectiveTLDService.h" 14 #include "nsISupports.h" 15 #include "nsString.h" 16 17 class mozIDOMWindowProxy; 18 class nsEffectiveTLDService; 19 class nsIChannel; 20 class nsIPrincipal; 21 class nsIURI; 22 class nsPIDOMWindowOuter; 23 24 namespace mozilla::dom { 25 class WindowGlobalParent; 26 } // namespace mozilla::dom 27 28 class ThirdPartyUtil final : public mozIThirdPartyUtil { 29 public: 30 NS_DECL_THREADSAFE_ISUPPORTS 31 NS_DECL_MOZITHIRDPARTYUTIL 32 33 nsresult Init(); 34 35 static void Startup(); 36 static ThirdPartyUtil* GetInstance(); 37 38 nsresult IsThirdPartyGlobal(mozilla::dom::WindowGlobalParent* aWindowGlobal, 39 bool* aResult); 40 41 private: 42 ~ThirdPartyUtil(); 43 44 bool IsThirdPartyInternal(const nsCString& aFirstDomain, 45 const nsCString& aSecondDomain) { 46 // Check strict equality. 47 return aFirstDomain != aSecondDomain; 48 } 49 nsresult IsThirdPartyInternal(const nsCString& aFirstDomain, 50 nsIURI* aSecondURI, bool* aResult); 51 52 RefPtr<nsIEffectiveTLDService> mTLDService; 53 }; 54 55 #endif