diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-24 21:13:14 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-24 21:13:14 +0000 |
commit | 61621d1f632ae1180325c25accd223921440d788 (patch) | |
tree | 568eb464f617548275d6611d6d86914c5263910c /chrome/common/chrome_paths.cc | |
parent | b097c4ffdce84568bfbf77af3038685271af1d8a (diff) | |
download | chromium_src-61621d1f632ae1180325c25accd223921440d788.zip chromium_src-61621d1f632ae1180325c25accd223921440d788.tar.gz chromium_src-61621d1f632ae1180325c25accd223921440d788.tar.bz2 |
Revert r3932 in an attempt to unbreak the tree.
Review URL: http://codereview.chromium.org/8161
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/chrome_paths.cc')
-rw-r--r-- | chrome/common/chrome_paths.cc | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index 71b3d3d..9d6da38 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -2,30 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "build/build_config.h" - -#if defined(OS_WIN) #include <windows.h> #include <shellapi.h> #include <shlobj.h> -#endif #include "chrome/common/chrome_paths.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/logging.h" #include "base/path_service.h" -#include "base/sys_info.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" namespace chrome { +bool GetUserDirectory(int directory_type, std::wstring* result) { + wchar_t path_buf[MAX_PATH]; + if (FAILED(SHGetFolderPath(NULL, directory_type, NULL, + SHGFP_TYPE_CURRENT, path_buf))) + return false; + result->assign(path_buf); + return true; +} + // Gets the default user data directory, regardless of whether // DIR_USER_DATA has been overridden by a command-line option. bool GetDefaultUserDataDirectory(std::wstring* result) { -#if defined(OS_WIN) if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) return false; #if defined(GOOGLE_CHROME_BUILD) @@ -34,11 +36,6 @@ bool GetDefaultUserDataDirectory(std::wstring* result) { file_util::AppendToPath(result, chrome::kBrowserAppName); file_util::AppendToPath(result, chrome::kUserDataDirname); return true; -#else // defined(OS_WIN) - // TODO(port): Decide what to do on other platforms. - NOTIMPLEMENTED(); - return false; -#endif // defined(OS_WIN) } bool GetGearsPluginPathFromCommandLine(std::wstring *path) { @@ -67,6 +64,14 @@ bool PathProvider(int key, std::wstring* result) { return PathService::Get(base::FILE_MODULE, result); } + // We need to go compute the value. It would be nice to support paths with + // names longer than MAX_PATH, but the system functions don't seem to be + // designed for it either, with the exception of GetTempPath (but other + // things will surely break if the temp path is too long, so we don't bother + // handling it. + wchar_t system_buffer[MAX_PATH]; + system_buffer[0] = 0; + // Assume that we will need to create the directory if it does not already // exist. This flag can be set to true to prevent checking. bool exists = false; @@ -78,20 +83,8 @@ bool PathProvider(int key, std::wstring* result) { return false; break; case chrome::DIR_USER_DOCUMENTS: -#if defined(OS_WIN) - { - wchar_t path_buf[MAX_PATH]; - if (FAILED(SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, - SHGFP_TYPE_CURRENT, path_buf))) - return false; - cur.assign(path_buf); - } -#else - // TODO(port): Get the path (possibly using xdg-user-dirs) - // or decide we don't need it on other platforms. - NOTIMPLEMENTED(); - return false; -#endif + if (!GetUserDirectory(CSIDL_MYDOCUMENTS, &cur)) + return false; break; case chrome::DIR_CRASH_DUMPS: // The crash reports are always stored relative to the default user data @@ -103,26 +96,10 @@ bool PathProvider(int key, std::wstring* result) { file_util::AppendToPath(&cur, L"Crash Reports"); break; case chrome::DIR_USER_DESKTOP: -#if defined(OS_WIN) - { - // We need to go compute the value. It would be nice to support paths - // with names longer than MAX_PATH, but the system functions don't seem - // to be designed for it either, with the exception of GetTempPath - // (but other things will surely break if the temp path is too long, - // so we don't bother handling it. - wchar_t system_buffer[MAX_PATH]; - system_buffer[0] = 0; - if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, - SHGFP_TYPE_CURRENT, system_buffer))) - return false; - cur.assign(system_buffer); - } -#else - // TODO(port): Get the path (possibly using xdg-user-dirs) - // or decide we don't need it on other platforms. - NOTIMPLEMENTED(); - return false; -#endif + if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, + SHGFP_TYPE_CURRENT, system_buffer))) + return false; + cur = system_buffer; exists = true; break; case chrome::DIR_RESOURCES: @@ -154,12 +131,7 @@ bool PathProvider(int key, std::wstring* result) { break; case chrome::DIR_USER_SCRIPTS: // TODO(aa): Figure out where the script directory should live. -#if defined(OS_WIN) cur = L"C:\\SCRIPTS\\"; -#else - NOTIMPLEMENTED(); - return false; -#endif exists = true; // don't trigger directory creation code break; case chrome::FILE_LOCAL_STATE: |