Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef _nsXREDirProvider_h__ |
michael@0 | 7 | #define _nsXREDirProvider_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIDirectoryService.h" |
michael@0 | 10 | #include "nsIProfileMigrator.h" |
michael@0 | 11 | #include "nsIFile.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "nsCOMPtr.h" |
michael@0 | 14 | #include "nsCOMArray.h" |
michael@0 | 15 | #include "mozilla/Attributes.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsXREDirProvider MOZ_FINAL : public nsIDirectoryServiceProvider2, |
michael@0 | 18 | public nsIProfileStartup |
michael@0 | 19 | { |
michael@0 | 20 | public: |
michael@0 | 21 | // we use a custom isupports implementation (no refcount) |
michael@0 | 22 | NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); |
michael@0 | 23 | NS_IMETHOD_(MozExternalRefCountType) AddRef(void); |
michael@0 | 24 | NS_IMETHOD_(MozExternalRefCountType) Release(void); |
michael@0 | 25 | |
michael@0 | 26 | NS_DECL_NSIDIRECTORYSERVICEPROVIDER |
michael@0 | 27 | NS_DECL_NSIDIRECTORYSERVICEPROVIDER2 |
michael@0 | 28 | NS_DECL_NSIPROFILESTARTUP |
michael@0 | 29 | |
michael@0 | 30 | nsXREDirProvider(); |
michael@0 | 31 | |
michael@0 | 32 | // if aXULAppDir is null, use gArgv[0] |
michael@0 | 33 | nsresult Initialize(nsIFile *aXULAppDir, |
michael@0 | 34 | nsIFile *aGREDir, |
michael@0 | 35 | nsIDirectoryServiceProvider* aAppProvider = nullptr); |
michael@0 | 36 | ~nsXREDirProvider(); |
michael@0 | 37 | |
michael@0 | 38 | static nsXREDirProvider* GetSingleton(); |
michael@0 | 39 | |
michael@0 | 40 | nsresult GetUserProfilesRootDir(nsIFile** aResult, |
michael@0 | 41 | const nsACString* aProfileName, |
michael@0 | 42 | const nsACString* aAppName, |
michael@0 | 43 | const nsACString* aVendorName); |
michael@0 | 44 | nsresult GetUserProfilesLocalDir(nsIFile** aResult, |
michael@0 | 45 | const nsACString* aProfileName, |
michael@0 | 46 | const nsACString* aAppName, |
michael@0 | 47 | const nsACString* aVendorName); |
michael@0 | 48 | |
michael@0 | 49 | // We only set the profile dir, we don't ensure that it exists; |
michael@0 | 50 | // that is the responsibility of the toolkit profile service. |
michael@0 | 51 | // We also don't fire profile-changed notifications... that is |
michael@0 | 52 | // the responsibility of the apprunner. |
michael@0 | 53 | nsresult SetProfile(nsIFile* aProfileDir, nsIFile* aProfileLocalDir); |
michael@0 | 54 | |
michael@0 | 55 | void DoShutdown(); |
michael@0 | 56 | |
michael@0 | 57 | nsresult GetProfileDefaultsDir(nsIFile* *aResult); |
michael@0 | 58 | |
michael@0 | 59 | nsresult GetUserAppDataDirectory(nsIFile* *aFile) { |
michael@0 | 60 | return GetUserDataDirectory(aFile, false, nullptr, nullptr, nullptr); |
michael@0 | 61 | } |
michael@0 | 62 | nsresult GetUserLocalDataDirectory(nsIFile* *aFile) { |
michael@0 | 63 | return GetUserDataDirectory(aFile, true, nullptr, nullptr, nullptr); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | // By default GetUserDataDirectory gets profile path from gAppData, |
michael@0 | 67 | // but that can be overridden by using aProfileName/aAppName/aVendorName. |
michael@0 | 68 | nsresult GetUserDataDirectory(nsIFile** aFile, bool aLocal, |
michael@0 | 69 | const nsACString* aProfileName, |
michael@0 | 70 | const nsACString* aAppName, |
michael@0 | 71 | const nsACString* aVendorName); |
michael@0 | 72 | |
michael@0 | 73 | /* make sure you clone it, if you need to do stuff to it */ |
michael@0 | 74 | nsIFile* GetGREDir() { return mGREDir; } |
michael@0 | 75 | nsIFile* GetAppDir() { |
michael@0 | 76 | if (mXULAppDir) |
michael@0 | 77 | return mXULAppDir; |
michael@0 | 78 | return mGREDir; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | /** |
michael@0 | 82 | * Get the directory under which update directory is created. |
michael@0 | 83 | * This method may be called before XPCOM is started. aResult |
michael@0 | 84 | * is a clone, it may be modified. |
michael@0 | 85 | */ |
michael@0 | 86 | nsresult GetUpdateRootDir(nsIFile* *aResult); |
michael@0 | 87 | |
michael@0 | 88 | /** |
michael@0 | 89 | * Get the profile startup directory as determined by this class or by |
michael@0 | 90 | * mAppProvider. This method may be called before XPCOM is started. aResult |
michael@0 | 91 | * is a clone, it may be modified. |
michael@0 | 92 | */ |
michael@0 | 93 | nsresult GetProfileStartupDir(nsIFile* *aResult); |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Get the profile directory as determined by this class or by an |
michael@0 | 97 | * embedder-provided XPCOM directory provider. Only call this method |
michael@0 | 98 | * when XPCOM is initialized! aResult is a clone, it may be modified. |
michael@0 | 99 | */ |
michael@0 | 100 | nsresult GetProfileDir(nsIFile* *aResult); |
michael@0 | 101 | |
michael@0 | 102 | protected: |
michael@0 | 103 | nsresult GetFilesInternal(const char* aProperty, nsISimpleEnumerator** aResult); |
michael@0 | 104 | nsresult GetUserDataDirectoryHome(nsIFile* *aFile, bool aLocal); |
michael@0 | 105 | nsresult GetSysUserExtensionsDirectory(nsIFile* *aFile); |
michael@0 | 106 | #if defined(XP_UNIX) || defined(XP_MACOSX) |
michael@0 | 107 | static nsresult GetSystemExtensionsDirectory(nsIFile** aFile); |
michael@0 | 108 | #endif |
michael@0 | 109 | static nsresult EnsureDirectoryExists(nsIFile* aDirectory); |
michael@0 | 110 | void EnsureProfileFileExists(nsIFile* aFile); |
michael@0 | 111 | |
michael@0 | 112 | // Determine the profile path within the UAppData directory. This is different |
michael@0 | 113 | // on every major platform. |
michael@0 | 114 | static nsresult AppendProfilePath(nsIFile* aFile, |
michael@0 | 115 | const nsACString* aProfileName, |
michael@0 | 116 | const nsACString* aAppName, |
michael@0 | 117 | const nsACString* aVendorName, |
michael@0 | 118 | bool aLocal); |
michael@0 | 119 | |
michael@0 | 120 | static nsresult AppendSysUserExtensionPath(nsIFile* aFile); |
michael@0 | 121 | |
michael@0 | 122 | // Internal helper that splits a path into components using the '/' and '\\' |
michael@0 | 123 | // delimiters. |
michael@0 | 124 | static inline nsresult AppendProfileString(nsIFile* aFile, const char* aPath); |
michael@0 | 125 | |
michael@0 | 126 | // Calculate and register extension and theme bundle directories. |
michael@0 | 127 | void LoadExtensionBundleDirectories(); |
michael@0 | 128 | |
michael@0 | 129 | // Calculate and register app-bundled extension directories. |
michael@0 | 130 | void LoadAppBundleDirs(); |
michael@0 | 131 | |
michael@0 | 132 | void Append(nsIFile* aDirectory); |
michael@0 | 133 | |
michael@0 | 134 | nsCOMPtr<nsIDirectoryServiceProvider> mAppProvider; |
michael@0 | 135 | nsCOMPtr<nsIFile> mGREDir; |
michael@0 | 136 | nsCOMPtr<nsIFile> mXULAppDir; |
michael@0 | 137 | nsCOMPtr<nsIFile> mProfileDir; |
michael@0 | 138 | nsCOMPtr<nsIFile> mProfileLocalDir; |
michael@0 | 139 | bool mProfileNotified; |
michael@0 | 140 | nsCOMArray<nsIFile> mAppBundleDirectories; |
michael@0 | 141 | nsCOMArray<nsIFile> mExtensionDirectories; |
michael@0 | 142 | nsCOMArray<nsIFile> mThemeDirectories; |
michael@0 | 143 | }; |
michael@0 | 144 | |
michael@0 | 145 | #endif |