Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4559)

Unified Diff: chrome/browser/extensions/api/input_ime/input_ime_api.cc

Issue 162973002: [IME] Releases key events to default handler if no handler in the active IME extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/input_ime/input_ime_api.cc
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api.cc b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
index 07670feb37fe5f3c134fb6b35376749aeba97325..738c73ffc171988de0a205239cd74c315140a601 100644
--- a/chrome/browser/extensions/api/input_ime/input_ime_api.cc
+++ b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
@@ -164,9 +164,17 @@ class ImeObserver : public InputMethodEngineInterface::Observer {
if (profile_ == NULL || extension_id_.empty())
return;
- std::string request_id =
- extensions::InputImeEventRouter::GetInstance()->AddRequest(engine_id,
- key_data);
+ extensions::InputImeEventRouter* ime_event_router =
+ extensions::InputImeEventRouter::GetInstance();
+
+ std::string request_id = ime_event_router->AddRequest(engine_id, key_data);
Hiro Komatsu 2014/02/14 05:32:15 const.
Shu Chen 2014/02/14 05:41:57 Done.
+
+ // If there is no listener for the event, no need to dispatch the event to
+ // extension. Instead, releases the key event for default system behavior.
+ if (!HasKeyEventListener()) {
+ ime_event_router->OnKeyEventHandled(extension_id_, request_id, false);
+ return;
+ }
input_ime::KeyboardEvent key_data_value;
key_data_value.type = input_ime::KeyboardEvent::ParseType(event.type);
@@ -268,6 +276,13 @@ class ImeObserver : public InputMethodEngineInterface::Observer {
}
private:
+ bool HasKeyEventListener() const {
+ return extensions::ExtensionSystem::Get(profile_)
+ ->event_router()
+ ->ExtensionHasEventListener(extension_id_,
+ input_ime::OnKeyEvent::kEventName);
+ }
+
Profile* profile_;
std::string extension_id_;
std::string engine_id_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698