Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/common/chrome_paths.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 cur = cur.Append(FILE_PATH_LITERAL("managed_users")); 401 cur = cur.Append(FILE_PATH_LITERAL("managed_users"));
402 break; 402 break;
403 #endif 403 #endif
404 // The following are only valid in the development environment, and 404 // The following are only valid in the development environment, and
405 // will fail if executed from an installed executable (because the 405 // will fail if executed from an installed executable (because the
406 // generated path won't exist). 406 // generated path won't exist).
407 case chrome::DIR_GEN_TEST_DATA: 407 case chrome::DIR_GEN_TEST_DATA:
408 if (!PathService::Get(base::DIR_MODULE, &cur)) 408 if (!PathService::Get(base::DIR_MODULE, &cur))
409 return false; 409 return false;
410 cur = cur.Append(FILE_PATH_LITERAL("test_data")); 410 cur = cur.Append(FILE_PATH_LITERAL("test_data"));
411 if (!file_util::PathExists(cur)) // We don't want to create this. 411 if (!base::PathExists(cur)) // We don't want to create this.
412 return false; 412 return false;
413 break; 413 break;
414 case chrome::DIR_TEST_DATA: 414 case chrome::DIR_TEST_DATA:
415 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) 415 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
416 return false; 416 return false;
417 cur = cur.Append(FILE_PATH_LITERAL("chrome")); 417 cur = cur.Append(FILE_PATH_LITERAL("chrome"));
418 cur = cur.Append(FILE_PATH_LITERAL("test")); 418 cur = cur.Append(FILE_PATH_LITERAL("test"));
419 cur = cur.Append(FILE_PATH_LITERAL("data")); 419 cur = cur.Append(FILE_PATH_LITERAL("data"));
420 if (!file_util::PathExists(cur)) // We don't want to create this. 420 if (!base::PathExists(cur)) // We don't want to create this.
421 return false; 421 return false;
422 break; 422 break;
423 case chrome::DIR_TEST_TOOLS: 423 case chrome::DIR_TEST_TOOLS:
424 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) 424 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
425 return false; 425 return false;
426 cur = cur.Append(FILE_PATH_LITERAL("chrome")); 426 cur = cur.Append(FILE_PATH_LITERAL("chrome"));
427 cur = cur.Append(FILE_PATH_LITERAL("tools")); 427 cur = cur.Append(FILE_PATH_LITERAL("tools"));
428 cur = cur.Append(FILE_PATH_LITERAL("test")); 428 cur = cur.Append(FILE_PATH_LITERAL("test"));
429 if (!file_util::PathExists(cur)) // We don't want to create this 429 if (!base::PathExists(cur)) // We don't want to create this
430 return false; 430 return false;
431 break; 431 break;
432 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) 432 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
433 case chrome::DIR_POLICY_FILES: { 433 case chrome::DIR_POLICY_FILES: {
434 #if defined(GOOGLE_CHROME_BUILD) 434 #if defined(GOOGLE_CHROME_BUILD)
435 cur = base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); 435 cur = base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies"));
436 #else 436 #else
437 cur = base::FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); 437 cur = base::FilePath(FILE_PATH_LITERAL("/etc/chromium/policies"));
438 #endif 438 #endif
439 break; 439 break;
440 } 440 }
441 #endif 441 #endif
442 #if defined(OS_MACOSX) && !defined(OS_IOS) 442 #if defined(OS_MACOSX) && !defined(OS_IOS)
443 case chrome::DIR_MANAGED_PREFS: { 443 case chrome::DIR_MANAGED_PREFS: {
444 if (!GetLocalLibraryDirectory(&cur)) 444 if (!GetLocalLibraryDirectory(&cur))
445 return false; 445 return false;
446 cur = cur.Append(FILE_PATH_LITERAL("Managed Preferences")); 446 cur = cur.Append(FILE_PATH_LITERAL("Managed Preferences"));
447 char* login = getlogin(); 447 char* login = getlogin();
448 if (!login) 448 if (!login)
449 return false; 449 return false;
450 cur = cur.AppendASCII(login); 450 cur = cur.AppendASCII(login);
451 if (!file_util::PathExists(cur)) // We don't want to create this. 451 if (!base::PathExists(cur)) // We don't want to create this.
452 return false; 452 return false;
453 break; 453 break;
454 } 454 }
455 #endif 455 #endif
456 #if defined(OS_CHROMEOS) || (defined(OS_MACOSX) && !defined(OS_IOS)) 456 #if defined(OS_CHROMEOS) || (defined(OS_MACOSX) && !defined(OS_IOS))
457 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { 457 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: {
458 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) 458 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
459 return false; 459 return false;
460 cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); 460 cur = cur.Append(FILE_PATH_LITERAL("External Extensions"));
461 break; 461 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (!PathService::Get(chrome::DIR_APP, &cur)) 493 if (!PathService::Get(chrome::DIR_APP, &cur))
494 return false; 494 return false;
495 cur = cur.Append(FILE_PATH_LITERAL("default_apps")); 495 cur = cur.Append(FILE_PATH_LITERAL("default_apps"));
496 #endif 496 #endif
497 break; 497 break;
498 498
499 default: 499 default:
500 return false; 500 return false;
501 } 501 }
502 502
503 if (create_dir && !file_util::PathExists(cur) && 503 if (create_dir && !base::PathExists(cur) &&
504 !file_util::CreateDirectory(cur)) 504 !file_util::CreateDirectory(cur))
505 return false; 505 return false;
506 506
507 *result = cur; 507 *result = cur;
508 return true; 508 return true;
509 } 509 }
510 510
511 // This cannot be done as a static initializer sadly since Visual Studio will 511 // This cannot be done as a static initializer sadly since Visual Studio will
512 // eliminate this object file if there is no direct entry point into it. 512 // eliminate this object file if there is no direct entry point into it.
513 void RegisterPathProvider() { 513 void RegisterPathProvider() {
514 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); 514 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
515 } 515 }
516 516
517 } // namespace chrome 517 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.cc ('k') | chrome/common/extensions/api/i18n/default_locale_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698