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