| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 base::FilePath(FILE_PATH_LITERAL("image_loader"))); | 367 base::FilePath(FILE_PATH_LITERAL("image_loader"))); |
| 368 #endif // defined(IMAGE_LOADER_EXTENSION) | 368 #endif // defined(IMAGE_LOADER_EXTENSION) |
| 369 } | 369 } |
| 370 | 370 |
| 371 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { | 371 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { |
| 372 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, | 372 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, |
| 373 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); | 373 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); |
| 374 } | 374 } |
| 375 | 375 |
| 376 #if defined(OS_CHROMEOS) | 376 #if defined(OS_CHROMEOS) |
| 377 void ComponentLoader::AddChromeVoxExtension( | |
| 378 const base::Closure& done_cb) { | |
| 379 base::FilePath resources_path; | |
| 380 CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path)); | |
| 381 | |
| 382 base::FilePath chromevox_path = | |
| 383 resources_path.Append(extension_misc::kChromeVoxExtensionPath); | |
| 384 | |
| 385 const base::FilePath::CharType* manifest_filename = | |
| 386 IsNormalSession() ? extensions::kManifestFilename | |
| 387 : extension_misc::kGuestManifestFilename; | |
| 388 AddWithManifestFile( | |
| 389 manifest_filename, | |
| 390 chromevox_path, | |
| 391 extension_misc::kChromeVoxExtensionId, | |
| 392 done_cb); | |
| 393 } | |
| 394 | |
| 395 void ComponentLoader::AddChromeOsSpeechSynthesisExtension() { | 377 void ComponentLoader::AddChromeOsSpeechSynthesisExtension() { |
| 396 const base::FilePath::CharType* manifest_filename = | 378 AddComponentFromDir( |
| 397 IsNormalSession() ? extensions::kManifestFilename | |
| 398 : extension_misc::kGuestManifestFilename; | |
| 399 AddWithManifestFile( | |
| 400 manifest_filename, | |
| 401 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath), | 379 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath), |
| 402 extension_misc::kSpeechSynthesisExtensionId, | 380 extension_misc::kSpeechSynthesisExtensionId, |
| 403 base::Bind(&ComponentLoader::EnableFileSystemInGuestMode, | 381 base::Bind(&ComponentLoader::EnableFileSystemInGuestMode, |
| 404 weak_factory_.GetWeakPtr(), | 382 weak_factory_.GetWeakPtr(), |
| 405 extension_misc::kChromeVoxExtensionId)); | 383 extension_misc::kChromeVoxExtensionId)); |
| 406 } | 384 } |
| 407 #endif | 385 #endif |
| 408 | 386 |
| 409 void ComponentLoader::AddWithNameAndDescription( | 387 void ComponentLoader::AddWithNameAndDescription( |
| 410 int manifest_resource_id, | 388 int manifest_resource_id, |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 base::FilePath(FILE_PATH_LITERAL("chromeos/first_run/app"))); | 593 base::FilePath(FILE_PATH_LITERAL("chromeos/first_run/app"))); |
| 616 | 594 |
| 617 Add(IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST, | 595 Add(IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST, |
| 618 base::FilePath(extension_misc::kConnectivityDiagnosticsPath)); | 596 base::FilePath(extension_misc::kConnectivityDiagnosticsPath)); |
| 619 Add(IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST, | 597 Add(IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST, |
| 620 base::FilePath(extension_misc::kConnectivityDiagnosticsLauncherPath)); | 598 base::FilePath(extension_misc::kConnectivityDiagnosticsLauncherPath)); |
| 621 | 599 |
| 622 Add(IDR_ARC_SUPPORT_MANIFEST, | 600 Add(IDR_ARC_SUPPORT_MANIFEST, |
| 623 base::FilePath(FILE_PATH_LITERAL("chromeos/arc_support"))); | 601 base::FilePath(FILE_PATH_LITERAL("chromeos/arc_support"))); |
| 624 } | 602 } |
| 625 | |
| 626 // Load ChromeVox extension now if spoken feedback is enabled. | |
| 627 if (chromeos::AccessibilityManager::Get() && | |
| 628 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { | |
| 629 AddChromeVoxExtension(base::Closure()); | |
| 630 } | |
| 631 #endif // defined(OS_CHROMEOS) | 603 #endif // defined(OS_CHROMEOS) |
| 632 | 604 |
| 633 #if defined(GOOGLE_CHROME_BUILD) | 605 #if defined(GOOGLE_CHROME_BUILD) |
| 634 #if !defined(OS_CHROMEOS) // http://crbug.com/314799 | 606 #if !defined(OS_CHROMEOS) // http://crbug.com/314799 |
| 635 AddNetworkSpeechSynthesisExtension(); | 607 AddNetworkSpeechSynthesisExtension(); |
| 636 #endif | 608 #endif |
| 637 | 609 |
| 638 #endif // defined(GOOGLE_CHROME_BUILD) | 610 #endif // defined(GOOGLE_CHROME_BUILD) |
| 639 | 611 |
| 640 Add(IDR_CRYPTOTOKEN_MANIFEST, | 612 Add(IDR_CRYPTOTOKEN_MANIFEST, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); | 651 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); |
| 680 storage::FileSystemContext* file_system_context = | 652 storage::FileSystemContext* file_system_context = |
| 681 content::BrowserContext::GetStoragePartitionForSite( | 653 content::BrowserContext::GetStoragePartitionForSite( |
| 682 off_the_record_context, site)->GetFileSystemContext(); | 654 off_the_record_context, site)->GetFileSystemContext(); |
| 683 file_system_context->EnableTemporaryFileSystemInIncognito(); | 655 file_system_context->EnableTemporaryFileSystemInIncognito(); |
| 684 } | 656 } |
| 685 #endif | 657 #endif |
| 686 } | 658 } |
| 687 | 659 |
| 688 #if defined(OS_CHROMEOS) | 660 #if defined(OS_CHROMEOS) |
| 689 void ComponentLoader::AddWithManifestFile( | 661 void ComponentLoader::AddComponentFromDir( |
| 690 const base::FilePath::CharType* manifest_filename, | |
| 691 const base::FilePath& root_directory, | 662 const base::FilePath& root_directory, |
| 692 const char* extension_id, | 663 const char* extension_id, |
| 693 const base::Closure& done_cb) { | 664 const base::Closure& done_cb) { |
| 694 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 665 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 666 const base::FilePath::CharType* manifest_filename = |
| 667 IsNormalSession() ? extensions::kManifestFilename |
| 668 : extension_misc::kGuestManifestFilename; |
| 695 BrowserThread::PostTaskAndReplyWithResult( | 669 BrowserThread::PostTaskAndReplyWithResult( |
| 696 BrowserThread::FILE, | 670 BrowserThread::FILE, |
| 697 FROM_HERE, | 671 FROM_HERE, |
| 698 base::Bind(&LoadManifestOnFileThread, root_directory, manifest_filename), | 672 base::Bind(&LoadManifestOnFileThread, root_directory, manifest_filename), |
| 699 base::Bind(&ComponentLoader::FinishAddWithManifestFile, | 673 base::Bind(&ComponentLoader::FinishAddComponentFromDir, |
| 700 weak_factory_.GetWeakPtr(), | 674 weak_factory_.GetWeakPtr(), |
| 701 root_directory, | 675 root_directory, |
| 702 extension_id, | 676 extension_id, |
| 703 done_cb)); | 677 done_cb)); |
| 704 } | 678 } |
| 705 | 679 |
| 706 void ComponentLoader::FinishAddWithManifestFile( | 680 void ComponentLoader::FinishAddComponentFromDir( |
| 707 const base::FilePath& root_directory, | 681 const base::FilePath& root_directory, |
| 708 const char* extension_id, | 682 const char* extension_id, |
| 709 const base::Closure& done_cb, | 683 const base::Closure& done_cb, |
| 710 std::unique_ptr<base::DictionaryValue> manifest) { | 684 std::unique_ptr<base::DictionaryValue> manifest) { |
| 711 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 685 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 712 if (!manifest) | 686 if (!manifest) |
| 713 return; // Error already logged. | 687 return; // Error already logged. |
| 714 std::string actual_extension_id = Add( | 688 std::string actual_extension_id = Add( |
| 715 manifest.release(), | 689 manifest.release(), |
| 716 root_directory, | 690 root_directory, |
| 717 false); | 691 false); |
| 718 CHECK_EQ(extension_id, actual_extension_id); | 692 CHECK_EQ(extension_id, actual_extension_id); |
| 719 if (!done_cb.is_null()) | 693 if (!done_cb.is_null()) |
| 720 done_cb.Run(); | 694 done_cb.Run(); |
| 721 } | 695 } |
| 722 #endif | 696 #endif |
| 723 | 697 |
| 724 } // namespace extensions | 698 } // namespace extensions |
| OLD | NEW |