OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 case chrome::FILE_CHROMEOS_API: | 273 case chrome::FILE_CHROMEOS_API: |
274 if (!PathService::Get(base::DIR_MODULE, &cur)) | 274 if (!PathService::Get(base::DIR_MODULE, &cur)) |
275 return false; | 275 return false; |
276 cur = cur.Append(FILE_PATH_LITERAL("chromeos")); | 276 cur = cur.Append(FILE_PATH_LITERAL("chromeos")); |
277 cur = cur.Append(FILE_PATH_LITERAL("libcros.so")); | 277 cur = cur.Append(FILE_PATH_LITERAL("libcros.so")); |
278 break; | 278 break; |
279 #endif | 279 #endif |
280 // The following are only valid in the development environment, and | 280 // The following are only valid in the development environment, and |
281 // will fail if executed from an installed executable (because the | 281 // will fail if executed from an installed executable (because the |
282 // generated path won't exist). | 282 // generated path won't exist). |
| 283 case chrome::DIR_GEN_TEST_DATA: |
| 284 if (!PathService::Get(base::DIR_MODULE, &cur)) |
| 285 return false; |
| 286 cur = cur.Append(FILE_PATH_LITERAL("test_data")); |
| 287 if (!file_util::PathExists(cur)) // We don't want to create this. |
| 288 return false; |
| 289 break; |
283 case chrome::DIR_TEST_DATA: | 290 case chrome::DIR_TEST_DATA: |
284 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) | 291 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) |
285 return false; | 292 return false; |
286 cur = cur.Append(FILE_PATH_LITERAL("chrome")); | 293 cur = cur.Append(FILE_PATH_LITERAL("chrome")); |
287 cur = cur.Append(FILE_PATH_LITERAL("test")); | 294 cur = cur.Append(FILE_PATH_LITERAL("test")); |
288 cur = cur.Append(FILE_PATH_LITERAL("data")); | 295 cur = cur.Append(FILE_PATH_LITERAL("data")); |
289 if (!file_util::PathExists(cur)) // we don't want to create this | 296 if (!file_util::PathExists(cur)) // We don't want to create this. |
290 return false; | 297 return false; |
291 break; | 298 break; |
292 case chrome::DIR_TEST_TOOLS: | 299 case chrome::DIR_TEST_TOOLS: |
293 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) | 300 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) |
294 return false; | 301 return false; |
295 cur = cur.Append(FILE_PATH_LITERAL("chrome")); | 302 cur = cur.Append(FILE_PATH_LITERAL("chrome")); |
296 cur = cur.Append(FILE_PATH_LITERAL("tools")); | 303 cur = cur.Append(FILE_PATH_LITERAL("tools")); |
297 cur = cur.Append(FILE_PATH_LITERAL("test")); | 304 cur = cur.Append(FILE_PATH_LITERAL("test")); |
298 if (!file_util::PathExists(cur)) // we don't want to create this | 305 if (!file_util::PathExists(cur)) // We don't want to create this |
299 return false; | 306 return false; |
300 break; | 307 break; |
301 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 308 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
302 case chrome::DIR_POLICY_FILES: { | 309 case chrome::DIR_POLICY_FILES: { |
303 #if defined(GOOGLE_CHROME_BUILD) | 310 #if defined(GOOGLE_CHROME_BUILD) |
304 cur = FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); | 311 cur = FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); |
305 #else | 312 #else |
306 cur = FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); | 313 cur = FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); |
307 #endif | 314 #endif |
308 break; | 315 break; |
309 } | 316 } |
310 #endif | 317 #endif |
311 #if defined(OS_MACOSX) | 318 #if defined(OS_MACOSX) |
312 case chrome::DIR_MANAGED_PREFS: { | 319 case chrome::DIR_MANAGED_PREFS: { |
313 if (!GetLocalLibraryDirectory(&cur)) | 320 if (!GetLocalLibraryDirectory(&cur)) |
314 return false; | 321 return false; |
315 cur = cur.Append(FILE_PATH_LITERAL("Managed Preferences")); | 322 cur = cur.Append(FILE_PATH_LITERAL("Managed Preferences")); |
316 char* login = getlogin(); | 323 char* login = getlogin(); |
317 if (!login) | 324 if (!login) |
318 return false; | 325 return false; |
319 cur = cur.AppendASCII(login); | 326 cur = cur.AppendASCII(login); |
320 if (!file_util::PathExists(cur)) // we don't want to create this | 327 if (!file_util::PathExists(cur)) // We don't want to create this. |
321 return false; | 328 return false; |
322 break; | 329 break; |
323 } | 330 } |
324 #endif | 331 #endif |
325 #if defined(OS_CHROMEOS) | 332 #if defined(OS_CHROMEOS) |
326 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { | 333 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { |
327 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) | 334 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) |
328 return false; | 335 return false; |
329 cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); | 336 cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); |
330 break; | 337 break; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 return true; | 393 return true; |
387 } | 394 } |
388 | 395 |
389 // This cannot be done as a static initializer sadly since Visual Studio will | 396 // This cannot be done as a static initializer sadly since Visual Studio will |
390 // eliminate this object file if there is no direct entry point into it. | 397 // eliminate this object file if there is no direct entry point into it. |
391 void RegisterPathProvider() { | 398 void RegisterPathProvider() { |
392 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 399 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
393 } | 400 } |
394 | 401 |
395 } // namespace chrome | 402 } // namespace chrome |
OLD | NEW |