toolkit/xre/nsXREDirProvider.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial