diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-19 20:34:23 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-19 20:34:23 +0000 |
commit | ffaee18e8a876257e5a9fed3eca6afcd60f481e1 (patch) | |
tree | eccb9ce482e600047b9e78aaf56ca048d2e9940e /chrome/browser/extensions | |
parent | c48ad0b05fa7c639f76c16909f8b0b32e24c559f (diff) | |
download | chromium_src-ffaee18e8a876257e5a9fed3eca6afcd60f481e1.zip chromium_src-ffaee18e8a876257e5a9fed3eca6afcd60f481e1.tar.gz chromium_src-ffaee18e8a876257e5a9fed3eca6afcd60f481e1.tar.bz2 |
Add support for GetHomeDir for Mac and Windows.
Unifies the Path Service's base::DIR_HOME on Posix and base::DIR_PROFILE on Windows to just be base::DIR_HOME everywhere, and DIR_HOME will now work on Mac.
This removes the AssertIOAllowed check in the Posix implementation because that was only executed in a fallback case that no developer is likely to ever hit. In addition, the we do call this type of function on the UI thread, so either we need to promote the assertion to be at the top of the function or delete it. It seemed unreasonable to disallow using this one key of the path service on the UI thread (the other ones are OK) so I just went for deleting the assertion.
R=benwells@chromium.org
Review URL: https://codereview.chromium.org/159833003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/api/file_system/file_system_api.cc | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/api/file_system/file_system_apitest.cc | 15 |
2 files changed, 4 insertions, 24 deletions
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc index 291cb09..1009c84 100644 --- a/chrome/browser/extensions/api/file_system/file_system_api.cc +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc @@ -128,18 +128,11 @@ base::FilePath PrettifyPath(const base::FilePath& source_path) { // Prettifies |source_path|, by replacing the user's home directory with "~" // (if applicable). base::FilePath PrettifyPath(const base::FilePath& source_path) { -#if defined(OS_WIN) || defined(OS_POSIX) -#if defined(OS_WIN) - int home_key = base::DIR_PROFILE; -#elif defined(OS_POSIX) - int home_key = base::DIR_HOME; -#endif base::FilePath home_path; base::FilePath display_path = base::FilePath::FromUTF8Unsafe("~"); - if (PathService::Get(home_key, &home_path) + if (PathService::Get(base::DIR_HOME, &home_path) && home_path.AppendRelativePath(source_path, &display_path)) return display_path; -#endif return source_path; } #endif // defined(OS_MACOSX) @@ -219,13 +212,11 @@ bool GetFileTypesFromAcceptOption( const char kLastChooseEntryDirectory[] = "last_choose_file_directory"; const int kGraylistedPaths[] = { + base::DIR_HOME, #if defined(OS_WIN) - base::DIR_PROFILE, base::DIR_PROGRAM_FILES, base::DIR_PROGRAM_FILESX86, base::DIR_WINDOWS, -#elif defined(OS_POSIX) - base::DIR_HOME, #endif }; diff --git a/chrome/browser/extensions/api/file_system/file_system_apitest.cc b/chrome/browser/extensions/api/file_system/file_system_apitest.cc index c878709..e8e1d71 100644 --- a/chrome/browser/extensions/api/file_system/file_system_apitest.cc +++ b/chrome/browser/extensions/api/file_system/file_system_apitest.cc @@ -57,13 +57,7 @@ void AddSavedEntry(const base::FilePath& path_to_save, extension->id(), "magic id", path_to_save, is_directory); } -#if defined(OS_WIN) || defined(OS_POSIX) -#if defined(OS_WIN) - const int kGraylistedPath = base::DIR_PROFILE; -#elif defined(OS_POSIX) - const int kGraylistedPath = base::DIR_HOME; -#endif -#endif +const int kGraylistedPath = base::DIR_HOME; } // namespace @@ -157,12 +151,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPath) { #if defined(OS_WIN) || defined(OS_POSIX) IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPathPrettify) { -#if defined(OS_WIN) - int override = base::DIR_PROFILE; -#elif defined(OS_POSIX) - int override = base::DIR_HOME; -#endif - ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(override, + ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(base::DIR_HOME, test_root_folder_, false)); base::FilePath test_file = test_root_folder_.AppendASCII("gold.txt"); |