Home | History | Annotate | Download | only in common
      1 // Copyright (c) 2012 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 CHROME_COMMON_CHROME_PATHS_INTERNAL_H_
      6 #define CHROME_COMMON_CHROME_PATHS_INTERNAL_H_
      7 
      8 #include <string>
      9 
     10 #include "build/build_config.h"
     11 
     12 #if defined(OS_MACOSX)
     13 #if defined(__OBJC__)
     14 @class NSBundle;
     15 #else
     16 class NSBundle;
     17 #endif
     18 #endif
     19 
     20 namespace base {
     21 class FilePath;
     22 }
     23 
     24 namespace chrome {
     25 
     26 // Get the path to the user's data directory, regardless of whether
     27 // DIR_USER_DATA has been overridden by a command-line option.
     28 bool GetDefaultUserDataDirectory(base::FilePath* result);
     29 
     30 // This returns the base directory in which Chrome Frame stores user profiles.
     31 // Note that this cannot be wrapped in a preprocessor define since
     32 // CF and Google Chrome want to share the same binaries.
     33 bool GetChromeFrameUserDataDirectory(base::FilePath* result);
     34 
     35 // Get the path to the user's cache directory.  This is normally the
     36 // same as the profile directory, but on Linux it can also be
     37 // $XDG_CACHE_HOME and on Mac it can be under ~/Library/Caches.
     38 // Note that the Chrome cache directories are actually subdirectories
     39 // of this directory, with names like "Cache" and "Media Cache".
     40 // This will always fill in |result| with a directory, sometimes
     41 // just |profile_dir|.
     42 void GetUserCacheDirectory(const base::FilePath& profile_dir, base::FilePath* result);
     43 
     44 // Get the path to the user's documents directory.
     45 bool GetUserDocumentsDirectory(base::FilePath* result);
     46 
     47 #if defined(OS_WIN) || defined(OS_LINUX)
     48 // Gets the path to a safe default download directory for a user.
     49 bool GetUserDownloadsDirectorySafe(base::FilePath* result);
     50 #endif
     51 
     52 // Get the path to the user's downloads directory.
     53 bool GetUserDownloadsDirectory(base::FilePath* result);
     54 
     55 // Gets the path to the user's music directory.
     56 bool GetUserMusicDirectory(base::FilePath* result);
     57 
     58 // Gets the path to the user's pictures directory.
     59 bool GetUserPicturesDirectory(base::FilePath* result);
     60 
     61 // Gets the path to the user's videos directory.
     62 bool GetUserVideosDirectory(base::FilePath* result);
     63 
     64 #if defined(OS_MACOSX) && !defined(OS_IOS)
     65 // The "versioned directory" is a directory in the browser .app bundle.  It
     66 // contains the bulk of the application, except for the things that the system
     67 // requires be located at spepcific locations.  The versioned directory is
     68 // in the .app at Contents/Versions/w.x.y.z.
     69 base::FilePath GetVersionedDirectory();
     70 
     71 // This overrides the directory returned by |GetVersionedDirectory()|, to be
     72 // used when |GetVersionedDirectory()| can't automatically determine the proper
     73 // location. This is the case when the browser didn't load itself but by, e.g.,
     74 // the app mode loader. This should be called before |ChromeMain()|. This takes
     75 // ownership of the object |path| and the caller must not delete it.
     76 void SetOverrideVersionedDirectory(const base::FilePath* path);
     77 
     78 // Most of the application is further contained within the framework.  The
     79 // framework bundle is located within the versioned directory at a specific
     80 // path.  The only components in the versioned directory not included in the
     81 // framework are things that also depend on the framework, such as the helper
     82 // app bundle.
     83 base::FilePath GetFrameworkBundlePath();
     84 
     85 // Get the local library directory.
     86 bool GetLocalLibraryDirectory(base::FilePath* result);
     87 
     88 // Get the global Application Support directory (under /Library/).
     89 bool GetGlobalApplicationSupportDirectory(base::FilePath* result);
     90 
     91 // Returns the NSBundle for the outer browser application, even when running
     92 // inside the helper. In unbundled applications, such as tests, returns nil.
     93 NSBundle* OuterAppBundle();
     94 
     95 // Get the user data directory for the Chrome browser bundle at |bundle|.
     96 // |bundle| should be the same value that would be returned from +[NSBundle
     97 // mainBundle] if Chrome were launched normaly. This is used by app shims,
     98 // which run from a bundle which isn't Chrome itself, but which need access to
     99 // the user data directory to connect to a UNIX-domain socket therein.
    100 // Returns false if there was a problem fetching the app data directory.
    101 bool GetUserDataDirectoryForBrowserBundle(NSBundle* bundle,
    102                                           base::FilePath* result);
    103 
    104 #endif  // OS_MACOSX && !OS_IOS
    105 
    106 // Checks if the |process_type| has the rights to access the profile.
    107 bool ProcessNeedsProfileDir(const std::string& process_type);
    108 
    109 }  // namespace chrome
    110 
    111 #endif  // CHROME_COMMON_CHROME_PATHS_INTERNAL_H_
    112