Index: chrome/browser/extensions/component_loader.cc |
diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc |
index f2b5152ab795f9a9ee8ff46e4062e9d8f2b7679f..4095d83f3e86374dd747ed2420444491dbe43bfb 100644 |
--- a/chrome/browser/extensions/component_loader.cc |
+++ b/chrome/browser/extensions/component_loader.cc |
@@ -28,6 +28,7 @@ |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/plugin_service.h" |
+#include "extensions/common/constants.h" |
#include "extensions/common/extension.h" |
#include "extensions/common/extension_l10n_util.h" |
#include "extensions/common/file_util.h" |
@@ -86,14 +87,20 @@ std::string GenerateId(const base::DictionaryValue* manifest, |
#if defined(OS_CHROMEOS) |
scoped_ptr<base::DictionaryValue> |
LoadManifestOnFileThread( |
- const base::FilePath& chromevox_path, const char* manifest_filename) { |
+ const base::FilePath& root_directory, |
+ const base::FilePath::CharType* manifest_filename) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
std::string error; |
scoped_ptr<base::DictionaryValue> manifest( |
- file_util::LoadManifest(chromevox_path, manifest_filename, &error)); |
- CHECK(manifest) << error; |
+ file_util::LoadManifest(root_directory, manifest_filename, &error)); |
+ if (!manifest) { |
+ LOG(ERROR) << "Can't load " |
+ << root_directory.Append(manifest_filename).AsUTF8Unsafe() |
not at google - send to devlin
2015/06/01 17:39:37
Annoying that FilePath doesn't define <<
|
+ << ": " << error; |
+ return nullptr; |
+ } |
bool localized = extension_l10n_util::LocalizeExtension( |
- chromevox_path, manifest.get(), &error); |
+ root_directory, manifest.get(), &error); |
CHECK(localized) << error; |
return manifest.Pass(); |
} |
@@ -375,45 +382,33 @@ void ComponentLoader::AddNetworkSpeechSynthesisExtension() { |
#if defined(OS_CHROMEOS) |
void ComponentLoader::AddChromeVoxExtension( |
const base::Closure& done_cb) { |
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
base::FilePath resources_path; |
- PathService::Get(chrome::DIR_RESOURCES, &resources_path); |
+ CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path)); |
base::FilePath chromevox_path = |
resources_path.Append(extension_misc::kChromeVoxExtensionPath); |
- const char* manifest_filename = |
- IsNormalSession() ? extension_misc::kChromeVoxManifestFilename |
- : extension_misc::kChromeVoxGuestManifestFilename; |
- |
- BrowserThread::PostTaskAndReplyWithResult( |
- BrowserThread::FILE, |
- FROM_HERE, |
- base::Bind(&LoadManifestOnFileThread, chromevox_path, manifest_filename), |
- base::Bind(&ComponentLoader::AddChromeVoxExtensionWithManifest, |
+ const base::FilePath::CharType* manifest_filename = |
+ IsNormalSession() ? extensions::kManifestFilename |
+ : extension_misc::kGuestManifestFilename; |
+ AddWithManifestFile( |
+ manifest_filename, |
+ chromevox_path, |
+ extension_misc::kChromeVoxExtensionId, |
+ done_cb); |
+} |
+ |
+void ComponentLoader::AddChromeOsSpeechSynthesisExtension() { |
+ const base::FilePath::CharType* manifest_filename = |
+ IsNormalSession() ? extensions::kManifestFilename |
+ : extension_misc::kGuestManifestFilename; |
+ AddWithManifestFile( |
+ manifest_filename, |
+ base::FilePath(extension_misc::kSpeechSynthesisExtensionPath), |
+ extension_misc::kSpeechSynthesisExtensionId, |
+ base::Bind(&ComponentLoader::EnableFileSystemInGuestMode, |
weak_factory_.GetWeakPtr(), |
- chromevox_path, |
- done_cb)); |
-} |
- |
-void ComponentLoader::AddChromeVoxExtensionWithManifest( |
- const base::FilePath& chromevox_path, |
- const base::Closure& done_cb, |
- scoped_ptr<base::DictionaryValue> manifest) { |
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
- std::string extension_id = Add(manifest.release(), chromevox_path); |
- CHECK_EQ(extension_misc::kChromeVoxExtensionId, extension_id); |
- if (!done_cb.is_null()) |
- done_cb.Run(); |
-} |
- |
-std::string ComponentLoader::AddChromeOsSpeechSynthesisExtension() { |
- int idr = IsNormalSession() ? IDR_SPEECH_SYNTHESIS_MANIFEST |
- : IDR_SPEECH_SYNTHESIS_GUEST_MANIFEST; |
- std::string id = Add(idr, |
- base::FilePath(extension_misc::kSpeechSynthesisExtensionPath)); |
- EnableFileSystemInGuestMode(id); |
- return id; |
+ extension_misc::kChromeVoxExtensionId)); |
} |
#endif |
@@ -694,4 +689,37 @@ void ComponentLoader::EnableFileSystemInGuestMode(const std::string& id) { |
#endif |
} |
+#if defined(OS_CHROMEOS) |
+void ComponentLoader::AddWithManifestFile( |
+ const base::FilePath::CharType* manifest_filename, |
+ const base::FilePath& root_directory, |
+ const char* extension_id, |
+ const base::Closure& done_cb) { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ BrowserThread::PostTaskAndReplyWithResult( |
+ BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(&LoadManifestOnFileThread, root_directory, manifest_filename), |
+ base::Bind(&ComponentLoader::FinishAddWithManifestFile, |
+ weak_factory_.GetWeakPtr(), |
+ root_directory, |
+ extension_id, |
+ done_cb)); |
+} |
+ |
+void ComponentLoader::FinishAddWithManifestFile( |
+ const base::FilePath& root_directory, |
+ const char* extension_id, |
+ const base::Closure& done_cb, |
+ scoped_ptr<base::DictionaryValue> manifest) { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ if (!manifest) |
+ return; // Error already logged. |
+ std::string actual_extension_id = Add(manifest.release(), root_directory); |
+ CHECK_EQ(extension_id, actual_extension_id); |
+ if (!done_cb.is_null()) |
+ done_cb.Run(); |
+} |
+#endif |
+ |
} // namespace extensions |