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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" 10 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 args.Pass()); 157 args.Pass());
158 } 158 }
159 159
160 virtual void OnKeyEvent( 160 virtual void OnKeyEvent(
161 const std::string& engine_id, 161 const std::string& engine_id,
162 const InputMethodEngineInterface::KeyboardEvent& event, 162 const InputMethodEngineInterface::KeyboardEvent& event,
163 chromeos::input_method::KeyEventHandle* key_data) OVERRIDE { 163 chromeos::input_method::KeyEventHandle* key_data) OVERRIDE {
164 if (profile_ == NULL || extension_id_.empty()) 164 if (profile_ == NULL || extension_id_.empty())
165 return; 165 return;
166 166
167 std::string request_id = 167 extensions::InputImeEventRouter* ime_event_router =
168 extensions::InputImeEventRouter::GetInstance()->AddRequest(engine_id, 168 extensions::InputImeEventRouter::GetInstance();
169 key_data); 169
170 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.
171
172 // If there is no listener for the event, no need to dispatch the event to
173 // extension. Instead, releases the key event for default system behavior.
174 if (!HasKeyEventListener()) {
175 ime_event_router->OnKeyEventHandled(extension_id_, request_id, false);
176 return;
177 }
170 178
171 input_ime::KeyboardEvent key_data_value; 179 input_ime::KeyboardEvent key_data_value;
172 key_data_value.type = input_ime::KeyboardEvent::ParseType(event.type); 180 key_data_value.type = input_ime::KeyboardEvent::ParseType(event.type);
173 key_data_value.request_id = request_id; 181 key_data_value.request_id = request_id;
174 key_data_value.key = event.key; 182 key_data_value.key = event.key;
175 key_data_value.code = event.code; 183 key_data_value.code = event.code;
176 key_data_value.alt_key.reset(new bool(event.alt_key)); 184 key_data_value.alt_key.reset(new bool(event.alt_key));
177 key_data_value.ctrl_key.reset(new bool(event.ctrl_key)); 185 key_data_value.ctrl_key.reset(new bool(event.ctrl_key));
178 key_data_value.shift_key.reset(new bool(event.shift_key)); 186 key_data_value.shift_key.reset(new bool(event.shift_key));
179 key_data_value.caps_lock.reset(new bool(event.caps_lock)); 187 key_data_value.caps_lock.reset(new bool(event.caps_lock));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 269
262 scoped_ptr<base::ListValue> args(input_ime::OnReset::Create(engine_id)); 270 scoped_ptr<base::ListValue> args(input_ime::OnReset::Create(engine_id));
263 271
264 DispatchEventToExtension(profile_, 272 DispatchEventToExtension(profile_,
265 extension_id_, 273 extension_id_,
266 input_ime::OnReset::kEventName, 274 input_ime::OnReset::kEventName,
267 args.Pass()); 275 args.Pass());
268 } 276 }
269 277
270 private: 278 private:
279 bool HasKeyEventListener() const {
280 return extensions::ExtensionSystem::Get(profile_)
281 ->event_router()
282 ->ExtensionHasEventListener(extension_id_,
283 input_ime::OnKeyEvent::kEventName);
284 }
285
271 Profile* profile_; 286 Profile* profile_;
272 std::string extension_id_; 287 std::string extension_id_;
273 std::string engine_id_; 288 std::string engine_id_;
274 289
275 DISALLOW_COPY_AND_ASSIGN(ImeObserver); 290 DISALLOW_COPY_AND_ASSIGN(ImeObserver);
276 }; 291 };
277 292
278 } // namespace chromeos 293 } // namespace chromeos
279 294
280 namespace extensions { 295 namespace extensions {
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 if (input_components->size() > 0) 822 if (input_components->size() > 0)
808 input_ime_event_router()->UnregisterAllImes(profile_, extension->id()); 823 input_ime_event_router()->UnregisterAllImes(profile_, extension->id());
809 } 824 }
810 } 825 }
811 826
812 InputImeEventRouter* InputImeAPI::input_ime_event_router() { 827 InputImeEventRouter* InputImeAPI::input_ime_event_router() {
813 return InputImeEventRouter::GetInstance(); 828 return InputImeEventRouter::GetInstance();
814 } 829 }
815 830
816 } // namespace extensions 831 } // namespace extensions
OLDNEW
« 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