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/browser/extensions/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 component_extensions_.begin(); | 261 component_extensions_.begin(); |
262 for (; it != component_extensions_.end(); ++it) | 262 for (; it != component_extensions_.end(); ++it) |
263 if (it->extension_id == id) | 263 if (it->extension_id == id) |
264 return true; | 264 return true; |
265 return false; | 265 return false; |
266 } | 266 } |
267 | 267 |
268 void ComponentLoader::AddFileManagerExtension() { | 268 void ComponentLoader::AddFileManagerExtension() { |
269 #if defined(OS_CHROMEOS) | 269 #if defined(OS_CHROMEOS) |
270 #ifndef NDEBUG | 270 #ifndef NDEBUG |
271 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 271 const base::CommandLine* command_line = |
| 272 base::CommandLine::ForCurrentProcess(); |
272 if (command_line->HasSwitch(switches::kFileManagerExtensionPath)) { | 273 if (command_line->HasSwitch(switches::kFileManagerExtensionPath)) { |
273 base::FilePath filemgr_extension_path( | 274 base::FilePath filemgr_extension_path( |
274 command_line->GetSwitchValuePath(switches::kFileManagerExtensionPath)); | 275 command_line->GetSwitchValuePath(switches::kFileManagerExtensionPath)); |
275 AddWithNameAndDescription(IDR_FILEMANAGER_MANIFEST, | 276 AddWithNameAndDescription(IDR_FILEMANAGER_MANIFEST, |
276 filemgr_extension_path, | 277 filemgr_extension_path, |
277 IDS_FILEMANAGER_APP_NAME, | 278 IDS_FILEMANAGER_APP_NAME, |
278 IDS_FILEMANAGER_APP_DESCRIPTION); | 279 IDS_FILEMANAGER_APP_DESCRIPTION); |
279 return; | 280 return; |
280 } | 281 } |
281 #endif // NDEBUG | 282 #endif // NDEBUG |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 #if defined(OS_CHROMEOS) | 349 #if defined(OS_CHROMEOS) |
349 void ComponentLoader::AddChromeVoxExtension( | 350 void ComponentLoader::AddChromeVoxExtension( |
350 const base::Closure& done_cb) { | 351 const base::Closure& done_cb) { |
351 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 352 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
352 base::FilePath resources_path; | 353 base::FilePath resources_path; |
353 PathService::Get(chrome::DIR_RESOURCES, &resources_path); | 354 PathService::Get(chrome::DIR_RESOURCES, &resources_path); |
354 | 355 |
355 base::FilePath chromevox_path = | 356 base::FilePath chromevox_path = |
356 resources_path.Append(extension_misc::kChromeVoxExtensionPath); | 357 resources_path.Append(extension_misc::kChromeVoxExtensionPath); |
357 | 358 |
358 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 359 const base::CommandLine* command_line = |
| 360 base::CommandLine::ForCurrentProcess(); |
359 bool is_guest = command_line->HasSwitch(chromeos::switches::kGuestSession); | 361 bool is_guest = command_line->HasSwitch(chromeos::switches::kGuestSession); |
360 const char* manifest_filename = | 362 const char* manifest_filename = |
361 is_guest ? extension_misc::kChromeVoxGuestManifestFilename | 363 is_guest ? extension_misc::kChromeVoxGuestManifestFilename |
362 : extension_misc::kChromeVoxManifestFilename; | 364 : extension_misc::kChromeVoxManifestFilename; |
363 | 365 |
364 BrowserThread::PostTaskAndReplyWithResult( | 366 BrowserThread::PostTaskAndReplyWithResult( |
365 BrowserThread::FILE, | 367 BrowserThread::FILE, |
366 FROM_HERE, | 368 FROM_HERE, |
367 base::Bind(&LoadManifestOnFileThread, chromevox_path, manifest_filename), | 369 base::Bind(&LoadManifestOnFileThread, chromevox_path, manifest_filename), |
368 base::Bind(&ComponentLoader::AddChromeVoxExtensionWithManifest, | 370 base::Bind(&ComponentLoader::AddChromeVoxExtensionWithManifest, |
369 weak_factory_.GetWeakPtr(), | 371 weak_factory_.GetWeakPtr(), |
370 chromevox_path, | 372 chromevox_path, |
371 done_cb)); | 373 done_cb)); |
372 } | 374 } |
373 | 375 |
374 void ComponentLoader::AddChromeVoxExtensionWithManifest( | 376 void ComponentLoader::AddChromeVoxExtensionWithManifest( |
375 const base::FilePath& chromevox_path, | 377 const base::FilePath& chromevox_path, |
376 const base::Closure& done_cb, | 378 const base::Closure& done_cb, |
377 scoped_ptr<base::DictionaryValue> manifest) { | 379 scoped_ptr<base::DictionaryValue> manifest) { |
378 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 380 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
379 std::string extension_id = Add(manifest.release(), chromevox_path); | 381 std::string extension_id = Add(manifest.release(), chromevox_path); |
380 CHECK_EQ(extension_misc::kChromeVoxExtensionId, extension_id); | 382 CHECK_EQ(extension_misc::kChromeVoxExtensionId, extension_id); |
381 if (!done_cb.is_null()) | 383 if (!done_cb.is_null()) |
382 done_cb.Run(); | 384 done_cb.Run(); |
383 } | 385 } |
384 | 386 |
385 std::string ComponentLoader::AddChromeOsSpeechSynthesisExtension() { | 387 std::string ComponentLoader::AddChromeOsSpeechSynthesisExtension() { |
386 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 388 const base::CommandLine* command_line = |
| 389 base::CommandLine::ForCurrentProcess(); |
387 int idr = command_line->HasSwitch(chromeos::switches::kGuestSession) ? | 390 int idr = command_line->HasSwitch(chromeos::switches::kGuestSession) ? |
388 IDR_SPEECH_SYNTHESIS_GUEST_MANIFEST : IDR_SPEECH_SYNTHESIS_MANIFEST; | 391 IDR_SPEECH_SYNTHESIS_GUEST_MANIFEST : IDR_SPEECH_SYNTHESIS_MANIFEST; |
389 std::string id = Add(idr, | 392 std::string id = Add(idr, |
390 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath)); | 393 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath)); |
391 EnableFileSystemInGuestMode(id); | 394 EnableFileSystemInGuestMode(id); |
392 return id; | 395 return id; |
393 } | 396 } |
394 #endif | 397 #endif |
395 | 398 |
396 void ComponentLoader::AddWithNameAndDescription( | 399 void ComponentLoader::AddWithNameAndDescription( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 455 |
453 #if defined(GOOGLE_CHROME_BUILD) | 456 #if defined(GOOGLE_CHROME_BUILD) |
454 if (browser_defaults::enable_help_app) { | 457 if (browser_defaults::enable_help_app) { |
455 Add(IDR_HELP_MANIFEST, base::FilePath(FILE_PATH_LITERAL( | 458 Add(IDR_HELP_MANIFEST, base::FilePath(FILE_PATH_LITERAL( |
456 "/usr/share/chromeos-assets/helpapp"))); | 459 "/usr/share/chromeos-assets/helpapp"))); |
457 } | 460 } |
458 #endif | 461 #endif |
459 | 462 |
460 // Skip all other extensions that require user session presence. | 463 // Skip all other extensions that require user session presence. |
461 if (!skip_session_components) { | 464 if (!skip_session_components) { |
462 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 465 const base::CommandLine* command_line = |
| 466 base::CommandLine::ForCurrentProcess(); |
463 if (!command_line->HasSwitch(chromeos::switches::kGuestSession)) | 467 if (!command_line->HasSwitch(chromeos::switches::kGuestSession)) |
464 Add(IDR_BOOKMARKS_MANIFEST, | 468 Add(IDR_BOOKMARKS_MANIFEST, |
465 base::FilePath(FILE_PATH_LITERAL("bookmark_manager"))); | 469 base::FilePath(FILE_PATH_LITERAL("bookmark_manager"))); |
466 | 470 |
467 Add(IDR_CROSH_BUILTIN_MANIFEST, base::FilePath(FILE_PATH_LITERAL( | 471 Add(IDR_CROSH_BUILTIN_MANIFEST, base::FilePath(FILE_PATH_LITERAL( |
468 "/usr/share/chromeos-assets/crosh_builtin"))); | 472 "/usr/share/chromeos-assets/crosh_builtin"))); |
469 } | 473 } |
470 #else // !defined(OS_CHROMEOS) | 474 #else // !defined(OS_CHROMEOS) |
471 DCHECK(!skip_session_components); | 475 DCHECK(!skip_session_components); |
472 Add(IDR_BOOKMARKS_MANIFEST, | 476 Add(IDR_BOOKMARKS_MANIFEST, |
(...skipping 21 matching lines...) Expand all Loading... |
494 | 498 |
495 // Component extensions needed for kiosk apps. | 499 // Component extensions needed for kiosk apps. |
496 AddFileManagerExtension(); | 500 AddFileManagerExtension(); |
497 | 501 |
498 // Add virtual keyboard. | 502 // Add virtual keyboard. |
499 AddKeyboardApp(); | 503 AddKeyboardApp(); |
500 } | 504 } |
501 | 505 |
502 void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( | 506 void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( |
503 bool skip_session_components) { | 507 bool skip_session_components) { |
504 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 508 const base::CommandLine* command_line = |
| 509 base::CommandLine::ForCurrentProcess(); |
505 | 510 |
506 // Component extensions with background pages are not enabled during tests | 511 // Component extensions with background pages are not enabled during tests |
507 // because they generate a lot of background behavior that can interfere. | 512 // because they generate a lot of background behavior that can interfere. |
508 if (!enable_background_extensions_during_testing && | 513 if (!enable_background_extensions_during_testing && |
509 (command_line->HasSwitch(switches::kTestType) || | 514 (command_line->HasSwitch(switches::kTestType) || |
510 command_line->HasSwitch( | 515 command_line->HasSwitch( |
511 switches::kDisableComponentExtensionsWithBackgroundPages))) { | 516 switches::kDisableComponentExtensionsWithBackgroundPages))) { |
512 return; | 517 return; |
513 } | 518 } |
514 | 519 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 void ComponentLoader::UnloadComponent(ComponentExtensionInfo* component) { | 635 void ComponentLoader::UnloadComponent(ComponentExtensionInfo* component) { |
631 delete component->manifest; | 636 delete component->manifest; |
632 if (extension_service_->is_ready()) { | 637 if (extension_service_->is_ready()) { |
633 extension_service_-> | 638 extension_service_-> |
634 RemoveComponentExtension(component->extension_id); | 639 RemoveComponentExtension(component->extension_id); |
635 } | 640 } |
636 } | 641 } |
637 | 642 |
638 void ComponentLoader::EnableFileSystemInGuestMode(const std::string& id) { | 643 void ComponentLoader::EnableFileSystemInGuestMode(const std::string& id) { |
639 #if defined(OS_CHROMEOS) | 644 #if defined(OS_CHROMEOS) |
640 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 645 const base::CommandLine* command_line = |
| 646 base::CommandLine::ForCurrentProcess(); |
641 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { | 647 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { |
642 // TODO(dpolukhin): Hack to enable HTML5 temporary file system for | 648 // TODO(dpolukhin): Hack to enable HTML5 temporary file system for |
643 // the extension. Some component extensions don't work without temporary | 649 // the extension. Some component extensions don't work without temporary |
644 // file system access. Make sure temporary file system is enabled in the off | 650 // file system access. Make sure temporary file system is enabled in the off |
645 // the record browser context (as that is the one used in guest session). | 651 // the record browser context (as that is the one used in guest session). |
646 content::BrowserContext* off_the_record_context = | 652 content::BrowserContext* off_the_record_context = |
647 ExtensionsBrowserClient::Get()->GetOffTheRecordContext( | 653 ExtensionsBrowserClient::Get()->GetOffTheRecordContext( |
648 browser_context_); | 654 browser_context_); |
649 GURL site = content::SiteInstance::GetSiteForURL( | 655 GURL site = content::SiteInstance::GetSiteForURL( |
650 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); | 656 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); |
651 storage::FileSystemContext* file_system_context = | 657 storage::FileSystemContext* file_system_context = |
652 content::BrowserContext::GetStoragePartitionForSite( | 658 content::BrowserContext::GetStoragePartitionForSite( |
653 off_the_record_context, site)->GetFileSystemContext(); | 659 off_the_record_context, site)->GetFileSystemContext(); |
654 file_system_context->EnableTemporaryFileSystemInIncognito(); | 660 file_system_context->EnableTemporaryFileSystemInIncognito(); |
655 } | 661 } |
656 #endif | 662 #endif |
657 } | 663 } |
658 | 664 |
659 } // namespace extensions | 665 } // namespace extensions |
OLD | NEW |