| 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" | 8 #include "base/file_path.h" | 
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 30   return false; | 30   return false; | 
| 31 #endif | 31 #endif | 
| 32 } | 32 } | 
| 33 | 33 | 
| 34 bool PathProvider(int key, FilePath* result) { | 34 bool PathProvider(int key, FilePath* result) { | 
| 35   // Some keys are just aliases... | 35   // Some keys are just aliases... | 
| 36   switch (key) { | 36   switch (key) { | 
| 37     case chrome::DIR_APP: | 37     case chrome::DIR_APP: | 
| 38       return PathService::Get(base::DIR_MODULE, result); | 38       return PathService::Get(base::DIR_MODULE, result); | 
| 39     case chrome::DIR_LOGS: | 39     case chrome::DIR_LOGS: | 
| 40 #ifndef NDEBUG | 40 #ifdef NDEBUG | 
|  | 41       // Release builds write to the data dir | 
| 41       return PathService::Get(chrome::DIR_USER_DATA, result); | 42       return PathService::Get(chrome::DIR_USER_DATA, result); | 
| 42 #else | 43 #else | 
|  | 44       // Debug builds write next to the binary (in the build tree) | 
| 43       return PathService::Get(base::DIR_EXE, result); | 45       return PathService::Get(base::DIR_EXE, result); | 
| 44 #endif | 46 #endif | 
| 45     case chrome::FILE_RESOURCE_MODULE: | 47     case chrome::FILE_RESOURCE_MODULE: | 
| 46       return PathService::Get(base::FILE_MODULE, result); | 48       return PathService::Get(base::FILE_MODULE, result); | 
| 47   } | 49   } | 
| 48 | 50 | 
| 49   // Assume that we will not need to create the directory if it does not exist. | 51   // Assume that we will not need to create the directory if it does not exist. | 
| 50   // This flag can be set to true for the cases where we want to create it. | 52   // This flag can be set to true for the cases where we want to create it. | 
| 51   bool create_dir = false; | 53   bool create_dir = false; | 
| 52 | 54 | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 154       break; | 156       break; | 
| 155     case chrome::DIR_TEST_TOOLS: | 157     case chrome::DIR_TEST_TOOLS: | 
| 156       if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) | 158       if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) | 
| 157         return false; | 159         return false; | 
| 158       cur = cur.Append(FILE_PATH_LITERAL("chrome")); | 160       cur = cur.Append(FILE_PATH_LITERAL("chrome")); | 
| 159       cur = cur.Append(FILE_PATH_LITERAL("tools")); | 161       cur = cur.Append(FILE_PATH_LITERAL("tools")); | 
| 160       cur = cur.Append(FILE_PATH_LITERAL("test")); | 162       cur = cur.Append(FILE_PATH_LITERAL("test")); | 
| 161       if (!file_util::PathExists(cur))  // we don't want to create this | 163       if (!file_util::PathExists(cur))  // we don't want to create this | 
| 162         return false; | 164         return false; | 
| 163       break; | 165       break; | 
| 164     case chrome::FILE_PYTHON_RUNTIME: |  | 
| 165       if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) |  | 
| 166         return false; |  | 
| 167       cur = cur.Append(FILE_PATH_LITERAL("third_party")); |  | 
| 168       cur = cur.Append(FILE_PATH_LITERAL("python_24")); |  | 
| 169       cur = cur.Append(FILE_PATH_LITERAL("python.exe")); |  | 
| 170       if (!file_util::PathExists(cur))  // we don't want to create this |  | 
| 171         return false; |  | 
| 172       break; |  | 
| 173     case chrome::FILE_TEST_SERVER: |  | 
| 174       if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) |  | 
| 175         return false; |  | 
| 176       cur = cur.Append(FILE_PATH_LITERAL("net")); |  | 
| 177       cur = cur.Append(FILE_PATH_LITERAL("tools")); |  | 
| 178       cur = cur.Append(FILE_PATH_LITERAL("test")); |  | 
| 179       cur = cur.Append(FILE_PATH_LITERAL("testserver")); |  | 
| 180       cur = cur.Append(FILE_PATH_LITERAL("testserver.py")); |  | 
| 181       if (!file_util::PathExists(cur))  // we don't want to create this |  | 
| 182         return false; |  | 
| 183       break; |  | 
| 184     default: | 166     default: | 
| 185       return false; | 167       return false; | 
| 186   } | 168   } | 
| 187 | 169 | 
| 188   if (create_dir && !file_util::PathExists(cur) && | 170   if (create_dir && !file_util::PathExists(cur) && | 
| 189       !file_util::CreateDirectory(cur)) | 171       !file_util::CreateDirectory(cur)) | 
| 190     return false; | 172     return false; | 
| 191 | 173 | 
| 192   *result = cur; | 174   *result = cur; | 
| 193   return true; | 175   return true; | 
| 194 } | 176 } | 
| 195 | 177 | 
| 196 // This cannot be done as a static initializer sadly since Visual Studio will | 178 // This cannot be done as a static initializer sadly since Visual Studio will | 
| 197 // eliminate this object file if there is no direct entry point into it. | 179 // eliminate this object file if there is no direct entry point into it. | 
| 198 void RegisterPathProvider() { | 180 void RegisterPathProvider() { | 
| 199   PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 181   PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 
| 200 } | 182 } | 
| 201 | 183 | 
| 202 }  // namespace chrome | 184 }  // namespace chrome | 
| OLD | NEW | 
|---|