| 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 13 matching lines...) Expand all Loading... |
| 24 // File name of the internal Flash plugin on different platforms. | 24 // File name of the internal Flash plugin on different platforms. |
| 25 const FilePath::CharType kInternalFlashPluginFileName[] = | 25 const FilePath::CharType kInternalFlashPluginFileName[] = |
| 26 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
| 27 FILE_PATH_LITERAL("Flash Player Plugin for Chrome.plugin"); | 27 FILE_PATH_LITERAL("Flash Player Plugin for Chrome.plugin"); |
| 28 #elif defined(OS_WIN) | 28 #elif defined(OS_WIN) |
| 29 FILE_PATH_LITERAL("gcswf32.dll"); | 29 FILE_PATH_LITERAL("gcswf32.dll"); |
| 30 #else // OS_LINUX, etc. | 30 #else // OS_LINUX, etc. |
| 31 FILE_PATH_LITERAL("libgcflashplayer.so"); | 31 FILE_PATH_LITERAL("libgcflashplayer.so"); |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 // File name of the pepper Flash plugin on different platforms. | |
| 35 const FilePath::CharType kPepperFlashPluginFileName[] = | |
| 36 #if defined(OS_MACOSX) | |
| 37 FILE_PATH_LITERAL("PepperFlashPlayer.plugin"); | |
| 38 #elif defined(OS_WIN) | |
| 39 FILE_PATH_LITERAL("pepflashplayer.dll"); | |
| 40 #else // OS_LINUX, etc. | |
| 41 FILE_PATH_LITERAL("libpepflashplayer.so"); | |
| 42 #endif | |
| 43 | |
| 44 // The pepper flash plugins are in a directory with this name. | |
| 45 const FilePath::CharType kPepperFlashBaseDirectory[] = | |
| 46 FILE_PATH_LITERAL("PepperFlash"); | |
| 47 | |
| 48 // File name of the internal PDF plugin on different platforms. | 34 // File name of the internal PDF plugin on different platforms. |
| 49 const FilePath::CharType kInternalPDFPluginFileName[] = | 35 const FilePath::CharType kInternalPDFPluginFileName[] = |
| 50 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 51 FILE_PATH_LITERAL("pdf.dll"); | 37 FILE_PATH_LITERAL("pdf.dll"); |
| 52 #elif defined(OS_MACOSX) | 38 #elif defined(OS_MACOSX) |
| 53 FILE_PATH_LITERAL("PDF.plugin"); | 39 FILE_PATH_LITERAL("PDF.plugin"); |
| 54 #else // Linux and Chrome OS | 40 #else // Linux and Chrome OS |
| 55 FILE_PATH_LITERAL("libpdf.so"); | 41 FILE_PATH_LITERAL("libpdf.so"); |
| 56 #endif | 42 #endif |
| 57 | 43 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 81 *result = result->Append("Internet Plug-Ins"); | 67 *result = result->Append("Internet Plug-Ins"); |
| 82 return true; | 68 return true; |
| 83 } | 69 } |
| 84 // In tests, just look in the module directory (below). | 70 // In tests, just look in the module directory (below). |
| 85 #endif | 71 #endif |
| 86 | 72 |
| 87 // The rest of the world expects plugins in the module directory. | 73 // The rest of the world expects plugins in the module directory. |
| 88 return PathService::Get(base::DIR_MODULE, result); | 74 return PathService::Get(base::DIR_MODULE, result); |
| 89 } | 75 } |
| 90 | 76 |
| 91 // Pepper flash plugins have the version encoded in the path itself | |
| 92 // so we need to enumerate the directories to find the full path | |
| 93 bool GetPepperFlashDirectory(FilePath* result) { | |
| 94 if (!GetInternalPluginsDirectory(result)) | |
| 95 return false; | |
| 96 *result = result->Append(kPepperFlashBaseDirectory); | |
| 97 Version latest("0.0"); | |
| 98 bool found = false; | |
| 99 file_util::FileEnumerator | |
| 100 file_enumerator(*result, false, file_util::FileEnumerator::DIRECTORIES); | |
| 101 for (FilePath path = file_enumerator.Next(); !path.value().empty(); | |
| 102 path = file_enumerator.Next()) { | |
| 103 Version version(path.BaseName().MaybeAsASCII()); | |
| 104 if (!version.IsValid()) | |
| 105 continue; | |
| 106 if (version.CompareTo(latest) > 0) { | |
| 107 latest = version; | |
| 108 *result = path; | |
| 109 found = true; | |
| 110 } | |
| 111 } | |
| 112 return found; | |
| 113 } | |
| 114 | |
| 115 bool PathProvider(int key, FilePath* result) { | 77 bool PathProvider(int key, FilePath* result) { |
| 116 // Some keys are just aliases... | 78 // Some keys are just aliases... |
| 117 switch (key) { | 79 switch (key) { |
| 118 case chrome::DIR_APP: | 80 case chrome::DIR_APP: |
| 119 return PathService::Get(base::DIR_MODULE, result); | 81 return PathService::Get(base::DIR_MODULE, result); |
| 120 case chrome::DIR_LOGS: | 82 case chrome::DIR_LOGS: |
| 121 #ifdef NDEBUG | 83 #ifdef NDEBUG |
| 122 // Release builds write to the data dir | 84 // Release builds write to the data dir |
| 123 return PathService::Get(chrome::DIR_USER_DATA, result); | 85 return PathService::Get(chrome::DIR_USER_DATA, result); |
| 124 #else | 86 #else |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 cur = cur.Append(FILE_PATH_LITERAL("script.log")); | 215 cur = cur.Append(FILE_PATH_LITERAL("script.log")); |
| 254 break; | 216 break; |
| 255 case chrome::FILE_FLASH_PLUGIN: | 217 case chrome::FILE_FLASH_PLUGIN: |
| 256 if (!GetInternalPluginsDirectory(&cur)) | 218 if (!GetInternalPluginsDirectory(&cur)) |
| 257 return false; | 219 return false; |
| 258 cur = cur.Append(kInternalFlashPluginFileName); | 220 cur = cur.Append(kInternalFlashPluginFileName); |
| 259 if (!file_util::PathExists(cur)) | 221 if (!file_util::PathExists(cur)) |
| 260 return false; | 222 return false; |
| 261 break; | 223 break; |
| 262 case chrome::FILE_PEPPER_FLASH_PLUGIN: | 224 case chrome::FILE_PEPPER_FLASH_PLUGIN: |
| 263 if (!GetPepperFlashDirectory(&cur)) | |
| 264 return false; | |
| 265 cur = cur.Append(kPepperFlashPluginFileName); | |
| 266 if (!file_util::PathExists(cur)) | |
| 267 return false; | 225 return false; |
| 268 break; | 226 break; |
| 269 case chrome::FILE_PDF_PLUGIN: | 227 case chrome::FILE_PDF_PLUGIN: |
| 270 if (!GetInternalPluginsDirectory(&cur)) | 228 if (!GetInternalPluginsDirectory(&cur)) |
| 271 return false; | 229 return false; |
| 272 cur = cur.Append(kInternalPDFPluginFileName); | 230 cur = cur.Append(kInternalPDFPluginFileName); |
| 273 break; | 231 break; |
| 274 case chrome::FILE_NACL_PLUGIN: | 232 case chrome::FILE_NACL_PLUGIN: |
| 275 if (!GetInternalPluginsDirectory(&cur)) | 233 if (!GetInternalPluginsDirectory(&cur)) |
| 276 return false; | 234 return false; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 return true; | 345 return true; |
| 388 } | 346 } |
| 389 | 347 |
| 390 // This cannot be done as a static initializer sadly since Visual Studio will | 348 // This cannot be done as a static initializer sadly since Visual Studio will |
| 391 // eliminate this object file if there is no direct entry point into it. | 349 // eliminate this object file if there is no direct entry point into it. |
| 392 void RegisterPathProvider() { | 350 void RegisterPathProvider() { |
| 393 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 351 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| 394 } | 352 } |
| 395 | 353 |
| 396 } // namespace chrome | 354 } // namespace chrome |
| OLD | NEW |