| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 *result = result->Append("Internet Plug-Ins"); | 66 *result = result->Append("Internet Plug-Ins"); |
| 67 return true; | 67 return true; |
| 68 } | 68 } |
| 69 // In tests, just look in the module directory (below). | 69 // In tests, just look in the module directory (below). |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 // The rest of the world expects plugins in the module directory. | 72 // The rest of the world expects plugins in the module directory. |
| 73 return PathService::Get(base::DIR_MODULE, result); | 73 return PathService::Get(base::DIR_MODULE, result); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool GetGearsPluginPathFromCommandLine(FilePath* path) { | |
| 77 #ifndef NDEBUG | |
| 78 // for debugging, support a cmd line based override | |
| 79 FilePath plugin_path = | |
| 80 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | |
| 81 switches::kGearsPluginPathOverride); | |
| 82 *path = plugin_path; | |
| 83 return !plugin_path.empty(); | |
| 84 #else | |
| 85 return false; | |
| 86 #endif | |
| 87 } | |
| 88 | |
| 89 bool PathProvider(int key, FilePath* result) { | 76 bool PathProvider(int key, FilePath* result) { |
| 90 // Some keys are just aliases... | 77 // Some keys are just aliases... |
| 91 switch (key) { | 78 switch (key) { |
| 92 case chrome::DIR_APP: | 79 case chrome::DIR_APP: |
| 93 return PathService::Get(base::DIR_MODULE, result); | 80 return PathService::Get(base::DIR_MODULE, result); |
| 94 case chrome::DIR_LOGS: | 81 case chrome::DIR_LOGS: |
| 95 #ifdef NDEBUG | 82 #ifdef NDEBUG |
| 96 // Release builds write to the data dir | 83 // Release builds write to the data dir |
| 97 return PathService::Get(chrome::DIR_USER_DATA, result); | 84 return PathService::Get(chrome::DIR_USER_DATA, result); |
| 98 #else | 85 #else |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 case chrome::FILE_LOCAL_STATE: | 198 case chrome::FILE_LOCAL_STATE: |
| 212 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) | 199 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) |
| 213 return false; | 200 return false; |
| 214 cur = cur.Append(chrome::kLocalStateFilename); | 201 cur = cur.Append(chrome::kLocalStateFilename); |
| 215 break; | 202 break; |
| 216 case chrome::FILE_RECORDED_SCRIPT: | 203 case chrome::FILE_RECORDED_SCRIPT: |
| 217 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) | 204 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) |
| 218 return false; | 205 return false; |
| 219 cur = cur.Append(FILE_PATH_LITERAL("script.log")); | 206 cur = cur.Append(FILE_PATH_LITERAL("script.log")); |
| 220 break; | 207 break; |
| 221 case chrome::FILE_GEARS_PLUGIN: | |
| 222 if (!GetGearsPluginPathFromCommandLine(&cur)) { | |
| 223 #if defined(OS_WIN) | |
| 224 // Search for gears.dll alongside chrome.dll first. This new model | |
| 225 // allows us to package gears.dll with the Chrome installer and update | |
| 226 // it while Chrome is running. | |
| 227 if (!GetInternalPluginsDirectory(&cur)) | |
| 228 return false; | |
| 229 cur = cur.Append(FILE_PATH_LITERAL("gears.dll")); | |
| 230 | |
| 231 if (!file_util::PathExists(cur)) { | |
| 232 if (!PathService::Get(base::DIR_EXE, &cur)) | |
| 233 return false; | |
| 234 cur = cur.Append(FILE_PATH_LITERAL("plugins")); | |
| 235 cur = cur.Append(FILE_PATH_LITERAL("gears")); | |
| 236 cur = cur.Append(FILE_PATH_LITERAL("gears.dll")); | |
| 237 } | |
| 238 #else | |
| 239 // No gears.dll on non-Windows systems. | |
| 240 return false; | |
| 241 #endif | |
| 242 } | |
| 243 break; | |
| 244 case chrome::FILE_FLASH_PLUGIN: | 208 case chrome::FILE_FLASH_PLUGIN: |
| 245 if (!GetInternalPluginsDirectory(&cur)) | 209 if (!GetInternalPluginsDirectory(&cur)) |
| 246 return false; | 210 return false; |
| 247 cur = cur.Append(kInternalFlashPluginFileName); | 211 cur = cur.Append(kInternalFlashPluginFileName); |
| 248 if (!file_util::PathExists(cur)) | 212 if (!file_util::PathExists(cur)) |
| 249 return false; | 213 return false; |
| 250 break; | 214 break; |
| 251 case chrome::FILE_PDF_PLUGIN: | 215 case chrome::FILE_PDF_PLUGIN: |
| 252 if (!GetInternalPluginsDirectory(&cur)) | 216 if (!GetInternalPluginsDirectory(&cur)) |
| 253 return false; | 217 return false; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return true; | 312 return true; |
| 349 } | 313 } |
| 350 | 314 |
| 351 // This cannot be done as a static initializer sadly since Visual Studio will | 315 // This cannot be done as a static initializer sadly since Visual Studio will |
| 352 // eliminate this object file if there is no direct entry point into it. | 316 // eliminate this object file if there is no direct entry point into it. |
| 353 void RegisterPathProvider() { | 317 void RegisterPathProvider() { |
| 354 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 318 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| 355 } | 319 } |
| 356 | 320 |
| 357 } // namespace chrome | 321 } // namespace chrome |
| OLD | NEW |