| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 #if defined(OS_CHROMEOS) | 327 #if defined(OS_CHROMEOS) |
| 328 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { | 328 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { |
| 329 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) | 329 if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) |
| 330 return false; | 330 return false; |
| 331 cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); | 331 cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); |
| 332 break; | 332 break; |
| 333 } | 333 } |
| 334 #endif | 334 #endif |
| 335 case chrome::DIR_EXTERNAL_EXTENSIONS: | 335 case chrome::DIR_EXTERNAL_EXTENSIONS: |
| 336 #if defined(OS_MACOSX) | 336 #if defined(OS_MACOSX) |
| 337 if (!PathService::Get(base::DIR_EXE, &cur)) | 337 if (!chrome::GetGlobalApplicationSupportDirectory(&cur)) |
| 338 return false; | 338 return false; |
| 339 | 339 |
| 340 // On Mac, built-in extensions are in Contents/Extensions, a sibling of | 340 cur = cur.Append(FILE_PATH_LITERAL("Google")) |
| 341 // the App dir. If there are none, it may not exist. | 341 .Append(FILE_PATH_LITERAL("Chrome")) |
| 342 // TODO(skerner): Reading external extensions from a file inside the | 342 .Append(FILE_PATH_LITERAL("External Extensions")); |
| 343 // app budle causes several problems. Change this path to be outside | |
| 344 // the app bundle. crbug/67203 | |
| 345 cur = cur.DirName(); | |
| 346 cur = cur.Append(FILE_PATH_LITERAL("Extensions")); | |
| 347 create_dir = false; | 343 create_dir = false; |
| 348 #else | 344 #else |
| 349 if (!PathService::Get(base::DIR_MODULE, &cur)) | 345 if (!PathService::Get(base::DIR_MODULE, &cur)) |
| 350 return false; | 346 return false; |
| 351 | 347 |
| 352 cur = cur.Append(FILE_PATH_LITERAL("extensions")); | 348 cur = cur.Append(FILE_PATH_LITERAL("extensions")); |
| 353 create_dir = true; | 349 create_dir = true; |
| 354 #endif | 350 #endif |
| 355 break; | 351 break; |
| 352 |
| 353 #if defined(OS_MACOSX) |
| 354 case DIR_DEPRICATED_EXTERNAL_EXTENSIONS: |
| 355 // TODO(skerner): Reading external extensions from a file inside the |
| 356 // app budle causes several problems. Once users have a chance to |
| 357 // migrate, remove this path. crbug/67203 |
| 358 if (!PathService::Get(base::DIR_EXE, &cur)) |
| 359 return false; |
| 360 |
| 361 cur = cur.DirName(); |
| 362 cur = cur.Append(FILE_PATH_LITERAL("Extensions")); |
| 363 create_dir = false; |
| 364 |
| 365 break; |
| 366 #endif |
| 367 |
| 356 case chrome::DIR_DEFAULT_APPS: | 368 case chrome::DIR_DEFAULT_APPS: |
| 357 #if defined(OS_MACOSX) | 369 #if defined(OS_MACOSX) |
| 358 cur = base::mac::MainAppBundlePath(); | 370 cur = base::mac::MainAppBundlePath(); |
| 359 cur = cur.Append(FILE_PATH_LITERAL("Default Apps")); | 371 cur = cur.Append(FILE_PATH_LITERAL("Default Apps")); |
| 360 #else | 372 #else |
| 361 if (!PathService::Get(chrome::DIR_APP, &cur)) | 373 if (!PathService::Get(chrome::DIR_APP, &cur)) |
| 362 return false; | 374 return false; |
| 363 cur = cur.Append(FILE_PATH_LITERAL("default_apps")); | 375 cur = cur.Append(FILE_PATH_LITERAL("default_apps")); |
| 364 #endif | 376 #endif |
| 365 break; | 377 break; |
| 378 |
| 366 default: | 379 default: |
| 367 return false; | 380 return false; |
| 368 } | 381 } |
| 369 | 382 |
| 370 if (create_dir && !file_util::PathExists(cur) && | 383 if (create_dir && !file_util::PathExists(cur) && |
| 371 !file_util::CreateDirectory(cur)) | 384 !file_util::CreateDirectory(cur)) |
| 372 return false; | 385 return false; |
| 373 | 386 |
| 374 *result = cur; | 387 *result = cur; |
| 375 return true; | 388 return true; |
| 376 } | 389 } |
| 377 | 390 |
| 378 // This cannot be done as a static initializer sadly since Visual Studio will | 391 // This cannot be done as a static initializer sadly since Visual Studio will |
| 379 // eliminate this object file if there is no direct entry point into it. | 392 // eliminate this object file if there is no direct entry point into it. |
| 380 void RegisterPathProvider() { | 393 void RegisterPathProvider() { |
| 381 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 394 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| 382 } | 395 } |
| 383 | 396 |
| 384 } // namespace chrome | 397 } // namespace chrome |
| OLD | NEW |