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

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

Issue 1573903002: Change some functions in ImeEngineObserver as not ChromeOS-only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 7ebccf2ca14eae90789b8a1edfc4ca79f38a6a7d..82380d870900a1ba56f38cbe18d684b4c6c3c002 100644
--- a/chrome/browser/extensions/api/input_ime/input_ime_api.cc
+++ b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
@@ -20,6 +20,19 @@ namespace ui {
ImeObserver::ImeObserver(const std::string& extension_id, Profile* profile)
: extension_id_(extension_id), profile_(profile) {}
+void ImeObserver::OnActivate(const std::string& component_id) {
+ if (extension_id_.empty() || !HasListener(input_ime::OnActivate::kEventName))
+ return;
+
+ scoped_ptr<base::ListValue> args(input_ime::OnActivate::Create(
+ component_id,
+ input_ime::ParseScreenType(GetCurrentScreenType())));
+
+ DispatchEventToExtension(extensions::events::INPUT_IME_ON_ACTIVATE,
+ input_ime::OnActivate::kEventName,
+ std::move(args));
+}
+
void ImeObserver::OnFocus(
const IMEEngineHandlerInterface::InputContext& context) {
if (extension_id_.empty() || !HasListener(input_ime::OnFocus::kEventName))
@@ -115,6 +128,32 @@ void ImeObserver::OnDeactivated(const std::string& component_id) {
void ImeObserver::OnCompositionBoundsChanged(
const std::vector<gfx::Rect>& bounds) {}
+bool ImeObserver::IsInterestedInKeyEvent() const {
+ return ShouldForwardKeyEvent();
+}
+
+void ImeObserver::OnSurroundingTextChanged(const std::string& component_id,
+ const std::string& text,
+ int cursor_pos,
+ int anchor_pos,
+ int offset_pos) {
+ if (extension_id_.empty() ||
+ !HasListener(input_ime::OnSurroundingTextChanged::kEventName))
+ return;
+
+ input_ime::OnSurroundingTextChanged::SurroundingInfo info;
+ info.text = text;
+ info.focus = cursor_pos;
+ info.anchor = anchor_pos;
+ info.offset = offset_pos;
+ scoped_ptr<base::ListValue> args(
+ input_ime::OnSurroundingTextChanged::Create(component_id, info));
+
+ DispatchEventToExtension(
+ extensions::events::INPUT_IME_ON_SURROUNDING_TEXT_CHANGED,
+ input_ime::OnSurroundingTextChanged::kEventName, std::move(args));
+}
+
bool ImeObserver::ShouldForwardKeyEvent() const {
// Only forward key events to extension if there are non-lazy listeners
// for onKeyEvent. Because if something wrong with the lazy background

Powered by Google App Engine
This is Rietveld 408576698