Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "app/app_paths.h" | 5 #include "app/app_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/path_service.h" | 10 #include "base/path_service.h" |
| 11 | 11 |
| 12 namespace app { | 12 namespace app { |
| 13 | 13 |
| 14 bool PathProvider(int key, FilePath* result) { | 14 bool PathProvider(int key, FilePath* result) { |
| 15 // Assume that we will not need to create the directory if it does not exist. | 15 // Assume that we will not need to create the directory if it does not exist. |
| 16 // This flag can be set to true for the cases where we want to create it. | 16 // This flag can be set to true for the cases where we want to create it. |
| 17 bool create_dir = false; | 17 bool create_dir = false; |
| 18 | 18 |
| 19 FilePath cur; | 19 FilePath cur; |
| 20 switch (key) { | 20 switch (key) { |
| 21 #if !defined(OS_MACOSX) | |
|
Mark Mentovai
2009/07/13 16:15:21
Nobody will ever ask for DIR_THEMES on the Mac?
Avi (use Gerrit)
2009/07/13 16:33:53
They don't now, and if they start to, it'll be pre
| |
| 22 // These are not "themes" that are user-created, but rather the dlls and | |
| 23 // pak files. On the Mac, we keep the pak files in the lproj folders. | |
| 21 case app::DIR_THEMES: | 24 case app::DIR_THEMES: |
| 22 if (!PathService::Get(base::DIR_MODULE, &cur)) | 25 if (!PathService::Get(base::DIR_MODULE, &cur)) |
| 23 return false; | 26 return false; |
| 24 cur = cur.Append(FILE_PATH_LITERAL("themes")); | 27 cur = cur.Append(FILE_PATH_LITERAL("themes")); |
| 25 create_dir = true; | 28 create_dir = true; |
| 26 break; | 29 break; |
| 30 #endif | |
| 27 case app::DIR_LOCALES: | 31 case app::DIR_LOCALES: |
| 28 if (!PathService::Get(base::DIR_MODULE, &cur)) | 32 if (!PathService::Get(base::DIR_MODULE, &cur)) |
| 29 return false; | 33 return false; |
| 30 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 31 // On Mac, locale files are in Contents/Resources, a sibling of the | 35 // On Mac, locale files are in Contents/Resources, a sibling of the |
| 32 // App dir. | 36 // App dir. |
| 33 cur = cur.DirName(); | 37 cur = cur.DirName(); |
| 34 cur = cur.Append(FILE_PATH_LITERAL("Resources")); | 38 cur = cur.Append(FILE_PATH_LITERAL("Resources")); |
| 35 #else | 39 #else |
| 36 cur = cur.Append(FILE_PATH_LITERAL("locales")); | 40 cur = cur.Append(FILE_PATH_LITERAL("locales")); |
| 37 #endif | 41 #endif |
| 38 create_dir = true; | 42 create_dir = true; |
| 39 break; | 43 break; |
| 40 case app::DIR_EXTERNAL_EXTENSIONS: | 44 case app::DIR_EXTERNAL_EXTENSIONS: |
| 41 if (!PathService::Get(base::DIR_MODULE, &cur)) | 45 if (!PathService::Get(base::DIR_MODULE, &cur)) |
| 42 return false; | 46 return false; |
| 47 #if defined(OS_MACOSX) | |
|
Mark Mentovai
2009/07/13 16:15:21
Do we support multiple extensions dirs?
Avi (use Gerrit)
2009/07/13 16:33:53
This is for extensions that ship with the app; thi
| |
| 48 // On Mac, built-in extensions are in Contents/Extensions, a sibling of | |
| 49 // the App dir. If there are none, it may not exist. | |
| 50 cur = cur.DirName(); | |
| 51 cur = cur.Append(FILE_PATH_LITERAL("Extensions")); | |
| 52 create_dir = false; | |
| 53 #else | |
| 43 cur = cur.Append(FILE_PATH_LITERAL("extensions")); | 54 cur = cur.Append(FILE_PATH_LITERAL("extensions")); |
| 44 create_dir = true; | 55 create_dir = true; |
| 56 #endif | |
| 45 break; | 57 break; |
| 46 // The following are only valid in the development environment, and | 58 // The following are only valid in the development environment, and |
| 47 // will fail if executed from an installed executable (because the | 59 // will fail if executed from an installed executable (because the |
| 48 // generated path won't exist). | 60 // generated path won't exist). |
| 49 case app::DIR_TEST_DATA: | 61 case app::DIR_TEST_DATA: |
| 50 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) | 62 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) |
| 51 return false; | 63 return false; |
| 52 cur = cur.Append(FILE_PATH_LITERAL("app")); | 64 cur = cur.Append(FILE_PATH_LITERAL("app")); |
| 53 cur = cur.Append(FILE_PATH_LITERAL("test")); | 65 cur = cur.Append(FILE_PATH_LITERAL("test")); |
| 54 cur = cur.Append(FILE_PATH_LITERAL("data")); | 66 cur = cur.Append(FILE_PATH_LITERAL("data")); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 67 return true; | 79 return true; |
| 68 } | 80 } |
| 69 | 81 |
| 70 // This cannot be done as a static initializer sadly since Visual Studio will | 82 // This cannot be done as a static initializer sadly since Visual Studio will |
| 71 // eliminate this object file if there is no direct entry point into it. | 83 // eliminate this object file if there is no direct entry point into it. |
| 72 void RegisterPathProvider() { | 84 void RegisterPathProvider() { |
| 73 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 85 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| 74 } | 86 } |
| 75 | 87 |
| 76 } // namespace app | 88 } // namespace app |
| OLD | NEW |