Commit 6932703c authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Make "ChromeOS XKB" use background page instead of event page.

This is a temporal fix for the issue that non-Latin IMEs doesn't work.
The 'background.persistent' flag should be restored as soon as
possible after fixing the root cause of the issue.
Also, add some useful logs to debug the issue.

      chrome://inspect/#extensions.

Bug: 761714
Test: Manual. Confirm that the extension always appears on
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ia0a12a33036919dc2bec213fd11b49d3b7b9d54f
Reviewed-on: https://chromium-review.googlesource.com/660938
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarShu Chen <shuchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501211}
parent 7e104a64
...@@ -97,10 +97,18 @@ void DoLoadExtension(Profile* profile, ...@@ -97,10 +97,18 @@ void DoLoadExtension(Profile* profile,
extensions::ExtensionSystem::Get(profile); extensions::ExtensionSystem::Get(profile);
ExtensionService* extension_service = extension_system->extension_service(); ExtensionService* extension_service = extension_system->extension_service();
DCHECK(extension_service); DCHECK(extension_service);
if (extension_service->GetExtensionById(extension_id, false)) if (extension_service->GetExtensionById(extension_id, false)) {
VLOG(1) << "the IME extension(id=\"" << extension_id
<< "\") is already enabled";
return; return;
}
const std::string loaded_extension_id = const std::string loaded_extension_id =
GetComponentLoader(profile)->Add(manifest, file_path); GetComponentLoader(profile)->Add(manifest, file_path);
if (loaded_extension_id.empty()) {
LOG(ERROR) << "Failed to add an IME extension(id=\"" << extension_id
<< ", path=\"" << file_path << "\") to ComponentLoader";
return;
}
// Register IME extension with ExtensionPrefValueMap. // Register IME extension with ExtensionPrefValueMap.
ExtensionPrefValueMapFactory::GetForBrowserContext(profile) ExtensionPrefValueMapFactory::GetForBrowserContext(profile)
->RegisterExtension(extension_id, ->RegisterExtension(extension_id,
...@@ -108,6 +116,10 @@ void DoLoadExtension(Profile* profile, ...@@ -108,6 +116,10 @@ void DoLoadExtension(Profile* profile,
true, // is_enabled. true, // is_enabled.
true); // is_incognito_enabled. true); // is_incognito_enabled.
DCHECK_EQ(loaded_extension_id, extension_id); DCHECK_EQ(loaded_extension_id, extension_id);
if (!extension_service->IsExtensionEnabled(loaded_extension_id)) {
LOG(ERROR) << "An IME extension(id=\"" << loaded_extension_id
<< "\") is not enabled after loading";
}
} }
bool CheckFilePath(const base::FilePath* file_path) { bool CheckFilePath(const base::FilePath* file_path) {
...@@ -301,18 +313,29 @@ void ComponentExtensionIMEManagerImpl::ReadComponentExtensionsInfo( ...@@ -301,18 +313,29 @@ void ComponentExtensionIMEManagerImpl::ReadComponentExtensionsInfo(
rb.GetRawDataResource( rb.GetRawDataResource(
whitelisted_component_extension[i].manifest_resource_id) whitelisted_component_extension[i].manifest_resource_id)
.as_string(); .as_string();
if (component_ime.manifest.empty())
if (component_ime.manifest.empty()) {
LOG(ERROR) << "Couldn't get manifest from resource_id("
<< whitelisted_component_extension[i].manifest_resource_id
<< ")";
continue; continue;
}
std::unique_ptr<base::DictionaryValue> manifest = std::unique_ptr<base::DictionaryValue> manifest =
GetManifest(component_ime.manifest); GetManifest(component_ime.manifest);
if (!manifest.get()) if (!manifest.get()) {
LOG(ERROR) << "Failed to load invalid manifest: "
<< component_ime.manifest;
continue; continue;
}
if (!ReadExtensionInfo(*manifest.get(), if (!ReadExtensionInfo(*manifest.get(),
whitelisted_component_extension[i].id, whitelisted_component_extension[i].id,
&component_ime)) &component_ime)) {
LOG(ERROR) << "manifest doesn't have needed information for IME.";
continue; continue;
}
component_ime.id = whitelisted_component_extension[i].id; component_ime.id = whitelisted_component_extension[i].id;
if (!component_ime.path.IsAbsolute()) { if (!component_ime.path.IsAbsolute()) {
...@@ -324,8 +347,10 @@ void ComponentExtensionIMEManagerImpl::ReadComponentExtensionsInfo( ...@@ -324,8 +347,10 @@ void ComponentExtensionIMEManagerImpl::ReadComponentExtensionsInfo(
const base::ListValue* component_list; const base::ListValue* component_list;
if (!manifest->GetList(extensions::manifest_keys::kInputComponents, if (!manifest->GetList(extensions::manifest_keys::kInputComponents,
&component_list)) &component_list)) {
LOG(ERROR) << "No input_components is found in manifest.";
continue; continue;
}
for (size_t i = 0; i < component_list->GetSize(); ++i) { for (size_t i = 0; i < component_list->GetSize(); ++i) {
const base::DictionaryValue* dictionary; const base::DictionaryValue* dictionary;
......
...@@ -476,8 +476,11 @@ void InputMethodManagerImpl::StateImpl::ChangeInputMethod( ...@@ -476,8 +476,11 @@ void InputMethodManagerImpl::StateImpl::ChangeInputMethod(
if (!descriptor) { if (!descriptor) {
descriptor = manager_->LookupInputMethod( descriptor = manager_->LookupInputMethod(
manager_->util_.MigrateInputMethod(input_method_id), this); manager_->util_.MigrateInputMethod(input_method_id), this);
if (!descriptor) if (!descriptor) {
LOG(ERROR) << "Can't find InputMethodDescriptor for \"" << input_method_id
<< "\"";
return; return;
}
} }
// For 3rd party IME, when the user just logged in, SetEnabledExtensionImes // For 3rd party IME, when the user just logged in, SetEnabledExtensionImes
...@@ -521,6 +524,7 @@ void InputMethodManagerImpl::StateImpl::AddInputMethodExtension( ...@@ -521,6 +524,7 @@ void InputMethodManagerImpl::StateImpl::AddInputMethodExtension(
DCHECK(engine); DCHECK(engine);
manager_->engine_map_[profile][extension_id] = engine; manager_->engine_map_[profile][extension_id] = engine;
VLOG(1) << "Add an engine for \"" << extension_id << "\"";
bool contain = false; bool contain = false;
for (size_t i = 0; i < descriptors.size(); i++) { for (size_t i = 0; i < descriptors.size(); i++) {
...@@ -986,8 +990,10 @@ void InputMethodManagerImpl::ChangeInputMethodInternal( ...@@ -986,8 +990,10 @@ void InputMethodManagerImpl::ChangeInputMethodInternal(
bool show_message, bool show_message,
bool notify_menu) { bool notify_menu) {
// No need to switch input method when terminating. // No need to switch input method when terminating.
if (ui_session_ == STATE_TERMINATING) if (ui_session_ == STATE_TERMINATING) {
VLOG(1) << "No need to switch input method when terminating.";
return; return;
}
if (candidate_window_controller_.get()) if (candidate_window_controller_.get())
candidate_window_controller_->Hide(); candidate_window_controller_->Hide();
...@@ -1017,6 +1023,10 @@ void InputMethodManagerImpl::ChangeInputMethodInternal( ...@@ -1017,6 +1023,10 @@ void InputMethodManagerImpl::ChangeInputMethodInternal(
extension_ime_util::GetExtensionIDFromInputMethodID(descriptor.id()); extension_ime_util::GetExtensionIDFromInputMethodID(descriptor.id());
const std::string& component_id = const std::string& component_id =
extension_ime_util::GetComponentIDByInputMethodID(descriptor.id()); extension_ime_util::GetComponentIDByInputMethodID(descriptor.id());
if (engine_map_.find(profile) == engine_map_.end() ||
engine_map_[profile].find(extension_id) == engine_map_[profile].end()) {
LOG(ERROR) << "IMEEngine for \"" << extension_id << "\" is not registered";
}
engine = engine_map_[profile][extension_id]; engine = engine_map_[profile][extension_id];
ui::IMEBridge::Get()->SetCurrentEngineHandler(engine); ui::IMEBridge::Get()->SetCurrentEngineHandler(engine);
......
...@@ -34,8 +34,11 @@ ImeObserver::ImeObserver(const std::string& extension_id, Profile* profile) ...@@ -34,8 +34,11 @@ ImeObserver::ImeObserver(const std::string& extension_id, Profile* profile)
: extension_id_(extension_id), profile_(profile) {} : extension_id_(extension_id), profile_(profile) {}
void ImeObserver::OnActivate(const std::string& component_id) { void ImeObserver::OnActivate(const std::string& component_id) {
if (extension_id_.empty() || !HasListener(input_ime::OnActivate::kEventName)) if (extension_id_.empty() ||
!HasListener(input_ime::OnActivate::kEventName)) {
LOG(ERROR) << "Can't send onActivate event to \"" << extension_id_ << "\"";
return; return;
}
std::unique_ptr<base::ListValue> args(input_ime::OnActivate::Create( std::unique_ptr<base::ListValue> args(input_ime::OnActivate::Create(
component_id, input_ime::ParseScreenType(GetCurrentScreenType()))); component_id, input_ime::ParseScreenType(GetCurrentScreenType())));
......
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
], ],
"background": { "background": {
"page": "background.html", "page": "background.html",
"persistent": false // TODO(yhanada): Change to false after fixing crbug.com/761714.
"persistent": true
}, },
"content_scripts": [ "content_scripts": [
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment