Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc |
| diff --git a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc |
| index 876e2682ffdd1026c583ac111e43d856db12830c..b93dda54799edc141f73d58926dece47d38a4023 100644 |
| --- a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc |
| +++ b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc |
| @@ -22,9 +22,11 @@ |
| #include "chrome/grit/browser_resources.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "chromeos/ime/extension_ime_util.h" |
| +#include "content/public/browser/browser_thread.h" |
| #include "extensions/browser/extension_system.h" |
| #include "extensions/common/extension.h" |
| #include "extensions/common/extension_l10n_util.h" |
| +#include "extensions/common/file_util.h" |
| #include "extensions/common/manifest_constants.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| @@ -238,10 +240,24 @@ extensions::ComponentLoader* GetComponentLoader(Profile* profile) { |
| ExtensionService* extension_service = extension_system->extension_service(); |
| return extension_service->component_loader(); |
| } |
| + |
| +void CheckFilePath(const base::FilePath* file_path, bool* result) { |
| + *result = base::PathExists(*file_path); |
| +} |
| + |
| +void OnFilePathChecked(Profile* profile, |
| + const std::string* manifest, |
| + const base::FilePath* file_path, |
| + bool* result) { |
| + if (*result) |
| + GetComponentLoader(profile)->Add(*manifest, *file_path); |
| + else |
| + LOG(ERROR) << "IME extension file path not exists: " << file_path->value(); |
| +} |
| + |
| } // namespace |
| -ComponentExtensionIMEManagerImpl::ComponentExtensionIMEManagerImpl() |
| - : weak_ptr_factory_(this) { |
| +ComponentExtensionIMEManagerImpl::ComponentExtensionIMEManagerImpl() { |
| ReadComponentExtensionsInfo(&component_extension_list_); |
| } |
| @@ -261,6 +277,29 @@ bool ComponentExtensionIMEManagerImpl::Load(Profile* profile, |
| ExtensionService* extension_service = extension_system->extension_service(); |
| if (extension_service->GetExtensionById(extension_id, false)) |
| return false; |
| + |
| + // If current environment is linux_chromeos, check the existence of file path |
| + // to avoid unnecessary extension loading and InputMethodEngine creation, so |
| + // that the virtual keyboard web content url won't be override by IME |
| + // component extensions. |
| + if (!base::SysInfo::IsRunningOnChromeOS()) { |
| + bool* exists = new bool; |
| + *exists = false; |
| + base::FilePath* copied_file_path = new base::FilePath(file_path); |
| + |
| + content::BrowserThread::PostTaskAndReply( |
|
Seigo Nonaka
2014/08/25 02:01:08
Probably, you may want to use PostTaskAndReplyWIth
Shu Chen
2014/08/25 02:31:08
Done.
|
| + content::BrowserThread::FILE, |
| + FROM_HERE, |
| + base::Bind(&CheckFilePath, |
| + base::Unretained(copied_file_path), |
| + base::Unretained(exists)), |
| + base::Bind(&OnFilePathChecked, |
| + base::Unretained(profile), |
| + base::Owned(new std::string(manifest)), |
| + base::Owned(copied_file_path), |
| + base::Owned(exists))); |
| + return false; |
|
Seigo Nonaka
2014/08/25 02:01:08
is it okay to return false here? Probably at least
Shu Chen
2014/08/25 02:31:08
Done. I've made the return type as void.
|
| + } |
| const std::string loaded_extension_id = |
| GetComponentLoader(profile)->Add(manifest, file_path); |
| DCHECK_EQ(loaded_extension_id, extension_id); |