OLD | NEW |
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 "input_method_event_router.h" | 5 #include "input_method_event_router.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 ExtensionEventRouter *router = profile->GetExtensionEventRouter(); | 39 ExtensionEventRouter *router = profile->GetExtensionEventRouter(); |
40 | 40 |
41 if (!router->HasEventListener(extension_event_names::kOnInputMethodChanged)) | 41 if (!router->HasEventListener(extension_event_names::kOnInputMethodChanged)) |
42 return; | 42 return; |
43 | 43 |
44 ListValue args; | 44 ListValue args; |
45 StringValue *input_method_name = | 45 StringValue *input_method_name = |
46 new StringValue(GetInputMethodForXkb(current_input_method.id())); | 46 new StringValue(GetInputMethodForXkb(current_input_method.id())); |
47 args.Append(input_method_name); | 47 args.Append(input_method_name); |
48 std::string args_json; | 48 std::string args_json; |
49 base::JSONWriter::Write(&args, false, &args_json); | 49 base::JSONWriter::Write(&args, &args_json); |
50 | 50 |
51 // The router will only send the event to extensions that are listening. | 51 // The router will only send the event to extensions that are listening. |
52 router->DispatchEventToRenderers( | 52 router->DispatchEventToRenderers( |
53 extension_event_names::kOnInputMethodChanged, | 53 extension_event_names::kOnInputMethodChanged, |
54 args_json, profile, GURL()); | 54 args_json, profile, GURL()); |
55 } | 55 } |
56 | 56 |
57 void ExtensionInputMethodEventRouter::ActiveInputMethodsChanged( | 57 void ExtensionInputMethodEventRouter::ActiveInputMethodsChanged( |
58 input_method::InputMethodManager *manager, | 58 input_method::InputMethodManager *manager, |
59 const input_method::InputMethodDescriptor ¤t_input_method, | 59 const input_method::InputMethodDescriptor ¤t_input_method, |
60 size_t num_active_input_methods) { | 60 size_t num_active_input_methods) { |
61 } | 61 } |
62 | 62 |
63 void ExtensionInputMethodEventRouter::PropertyListChanged( | 63 void ExtensionInputMethodEventRouter::PropertyListChanged( |
64 input_method::InputMethodManager *manager, | 64 input_method::InputMethodManager *manager, |
65 const input_method::InputMethodPropertyList ¤t_ime_properties) { | 65 const input_method::InputMethodPropertyList ¤t_ime_properties) { |
66 } | 66 } |
67 | 67 |
68 std::string ExtensionInputMethodEventRouter::GetInputMethodForXkb( | 68 std::string ExtensionInputMethodEventRouter::GetInputMethodForXkb( |
69 const std::string& xkb_id) { | 69 const std::string& xkb_id) { |
70 size_t prefix_length = std::string(kXkbPrefix).length(); | 70 size_t prefix_length = std::string(kXkbPrefix).length(); |
71 DCHECK(xkb_id.substr(0, prefix_length) == kXkbPrefix); | 71 DCHECK(xkb_id.substr(0, prefix_length) == kXkbPrefix); |
72 return xkb_id.substr(prefix_length); | 72 return xkb_id.substr(prefix_length); |
73 } | 73 } |
74 | 74 |
75 } // namespace chromeos | 75 } // namespace chromeos |
OLD | NEW |