OLD | NEW |
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/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 *result = result->Append("Internet Plug-Ins"); | 78 *result = result->Append("Internet Plug-Ins"); |
79 return true; | 79 return true; |
80 } | 80 } |
81 // In tests, just look in the module directory (below). | 81 // In tests, just look in the module directory (below). |
82 #endif | 82 #endif |
83 | 83 |
84 // The rest of the world expects plugins in the module directory. | 84 // The rest of the world expects plugins in the module directory. |
85 return PathService::Get(base::DIR_MODULE, result); | 85 return PathService::Get(base::DIR_MODULE, result); |
86 } | 86 } |
87 | 87 |
| 88 // Gets the path for bundled implementations of components. Note that these |
| 89 // implementations should not be used if higher-versioned component-updated |
| 90 // implementations are available in DIR_USER_DATA. |
| 91 bool GetComponentDirectory(base::FilePath* result) { |
| 92 #if defined(OS_MACOSX) |
| 93 // If called from Chrome, return the framework's Libraries directory. |
| 94 if (base::mac::AmIBundled()) { |
| 95 *result = chrome::GetFrameworkBundlePath(); |
| 96 DCHECK(!result->empty()); |
| 97 *result = result->Append("Libraries"); |
| 98 return true; |
| 99 } |
| 100 // In tests, just look in the module directory (below). |
| 101 #endif |
| 102 |
| 103 // The rest of the world expects components in the module directory. |
| 104 return PathService::Get(base::DIR_MODULE, result); |
| 105 } |
| 106 |
88 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
89 // Gets the Pepper Flash path if installed on the system. | 108 // Gets the Pepper Flash path if installed on the system. |
90 bool GetSystemFlashFilename(base::FilePath* out_path) { | 109 bool GetSystemFlashFilename(base::FilePath* out_path) { |
91 const wchar_t kPepperFlashRegistryRoot[] = | 110 const wchar_t kPepperFlashRegistryRoot[] = |
92 L"SOFTWARE\\Macromedia\\FlashPlayerPepper"; | 111 L"SOFTWARE\\Macromedia\\FlashPlayerPepper"; |
93 const wchar_t kFlashPlayerPathValueName[] = L"PlayerPath"; | 112 const wchar_t kFlashPlayerPathValueName[] = L"PlayerPath"; |
94 | 113 |
95 base::win::RegKey path_key(HKEY_LOCAL_MACHINE, kPepperFlashRegistryRoot, | 114 base::win::RegKey path_key(HKEY_LOCAL_MACHINE, kPepperFlashRegistryRoot, |
96 KEY_READ); | 115 KEY_READ); |
97 base::string16 path_str; | 116 base::string16 path_str; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (!PathService::Get(base::DIR_EXE, &cur)) | 268 if (!PathService::Get(base::DIR_EXE, &cur)) |
250 return false; | 269 return false; |
251 #endif | 270 #endif |
252 cur = cur.Append(FILE_PATH_LITERAL("Dictionaries")); | 271 cur = cur.Append(FILE_PATH_LITERAL("Dictionaries")); |
253 create_dir = true; | 272 create_dir = true; |
254 break; | 273 break; |
255 case chrome::DIR_INTERNAL_PLUGINS: | 274 case chrome::DIR_INTERNAL_PLUGINS: |
256 if (!GetInternalPluginsDirectory(&cur)) | 275 if (!GetInternalPluginsDirectory(&cur)) |
257 return false; | 276 return false; |
258 break; | 277 break; |
| 278 case chrome::DIR_COMPONENTS: |
| 279 if (!GetComponentDirectory(&cur)) |
| 280 return false; |
| 281 break; |
259 case chrome::DIR_PEPPER_FLASH_PLUGIN: | 282 case chrome::DIR_PEPPER_FLASH_PLUGIN: |
260 if (!GetInternalPluginsDirectory(&cur)) | 283 if (!GetInternalPluginsDirectory(&cur)) |
261 return false; | 284 return false; |
262 cur = cur.Append(kPepperFlashBaseDirectory); | 285 cur = cur.Append(kPepperFlashBaseDirectory); |
263 break; | 286 break; |
264 case chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN: | 287 case chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN: |
265 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) | 288 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) |
266 return false; | 289 return false; |
267 cur = cur.Append(kPepperFlashBaseDirectory); | 290 cur = cur.Append(kPepperFlashBaseDirectory); |
268 break; | 291 break; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 589 |
567 void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir) { | 590 void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir) { |
568 g_invalid_specified_user_data_dir.Get() = user_data_dir; | 591 g_invalid_specified_user_data_dir.Get() = user_data_dir; |
569 } | 592 } |
570 | 593 |
571 const base::FilePath& GetInvalidSpecifiedUserDataDir() { | 594 const base::FilePath& GetInvalidSpecifiedUserDataDir() { |
572 return g_invalid_specified_user_data_dir.Get(); | 595 return g_invalid_specified_user_data_dir.Get(); |
573 } | 596 } |
574 | 597 |
575 } // namespace chrome | 598 } // namespace chrome |
OLD | NEW |