| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/chrome_paths.h" | 5 #include "chrome/common/chrome_paths.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | |
| 9 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 13 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 14 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/chrome_paths_internal.h" | 14 #include "chrome/common/chrome_paths_internal.h" |
| 16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 17 | 16 |
| 18 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // app bundle), if we're called from a unittest, we'll already | 53 // app bundle), if we're called from a unittest, we'll already |
| 55 // outside the bundle so use the exe dir. | 54 // outside the bundle so use the exe dir. |
| 56 // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium. | 55 // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium. |
| 57 *result = result->DirName(); | 56 *result = result->DirName(); |
| 58 *result = result->DirName(); | 57 *result = result->DirName(); |
| 59 *result = result->DirName(); | 58 *result = result->DirName(); |
| 60 } | 59 } |
| 61 return true; | 60 return true; |
| 62 #else | 61 #else |
| 63 return PathService::Get(base::DIR_EXE, result); | 62 return PathService::Get(base::DIR_EXE, result); |
| 64 #endif // defined(OS_MACOSX) | 63 #endif // defined(OS_MACOSX) |
| 65 #endif // NDEBUG | 64 #endif // NDEBUG |
| 66 case chrome::FILE_RESOURCE_MODULE: | 65 case chrome::FILE_RESOURCE_MODULE: |
| 67 return PathService::Get(base::FILE_MODULE, result); | 66 return PathService::Get(base::FILE_MODULE, result); |
| 68 } | 67 } |
| 69 | 68 |
| 70 // Assume that we will not need to create the directory if it does not exist. | 69 // Assume that we will not need to create the directory if it does not exist. |
| 71 // This flag can be set to true for the cases where we want to create it. | 70 // This flag can be set to true for the cases where we want to create it. |
| 72 bool create_dir = false; | 71 bool create_dir = false; |
| 73 | 72 |
| 74 FilePath cur; | 73 FilePath cur; |
| 75 switch (key) { | 74 switch (key) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 89 #endif | 88 #endif |
| 90 break; | 89 break; |
| 91 case chrome::DIR_USER_DOCUMENTS: | 90 case chrome::DIR_USER_DOCUMENTS: |
| 92 if (!GetUserDocumentsDirectory(&cur)) | 91 if (!GetUserDocumentsDirectory(&cur)) |
| 93 return false; | 92 return false; |
| 94 create_dir = true; | 93 create_dir = true; |
| 95 break; | 94 break; |
| 96 case chrome::DIR_DEFAULT_DOWNLOADS: | 95 case chrome::DIR_DEFAULT_DOWNLOADS: |
| 97 if (!GetUserDownloadsDirectory(&cur)) | 96 if (!GetUserDownloadsDirectory(&cur)) |
| 98 return false; | 97 return false; |
| 99 create_dir = true; | 98 // Do not create the download directory here, we have done it twice now |
| 99 // and annoyed a lot of users. |
| 100 break; | 100 break; |
| 101 case chrome::DIR_CRASH_DUMPS: | 101 case chrome::DIR_CRASH_DUMPS: |
| 102 // The crash reports are always stored relative to the default user data | 102 // The crash reports are always stored relative to the default user data |
| 103 // directory. This avoids the problem of having to re-initialize the | 103 // directory. This avoids the problem of having to re-initialize the |
| 104 // exception handler after parsing command line options, which may | 104 // exception handler after parsing command line options, which may |
| 105 // override the location of the app's profile directory. | 105 // override the location of the app's profile directory. |
| 106 if (!GetDefaultUserDataDirectory(&cur)) | 106 if (!GetDefaultUserDataDirectory(&cur)) |
| 107 return false; | 107 return false; |
| 108 cur = cur.Append(FILE_PATH_LITERAL("Crash Reports")); | 108 cur = cur.Append(FILE_PATH_LITERAL("Crash Reports")); |
| 109 create_dir = true; | 109 create_dir = true; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return true; | 213 return true; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // This cannot be done as a static initializer sadly since Visual Studio will | 216 // This cannot be done as a static initializer sadly since Visual Studio will |
| 217 // eliminate this object file if there is no direct entry point into it. | 217 // eliminate this object file if there is no direct entry point into it. |
| 218 void RegisterPathProvider() { | 218 void RegisterPathProvider() { |
| 219 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 219 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace chrome | 222 } // namespace chrome |
| OLD | NEW |