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