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

Side by Side Diff: chrome/browser/chromeos/extensions/input_method_event_router.cc

Issue 9999018: chrome/browser/chromeos/input_method/ refactoring [part 6 of 6] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 | Annotate | Revision Log
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 "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 14 matching lines...) Expand all
25 25
26 ExtensionInputMethodEventRouter::ExtensionInputMethodEventRouter() { 26 ExtensionInputMethodEventRouter::ExtensionInputMethodEventRouter() {
27 input_method::InputMethodManager::GetInstance()->AddObserver(this); 27 input_method::InputMethodManager::GetInstance()->AddObserver(this);
28 } 28 }
29 29
30 ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() { 30 ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() {
31 input_method::InputMethodManager::GetInstance()->RemoveObserver(this); 31 input_method::InputMethodManager::GetInstance()->RemoveObserver(this);
32 } 32 }
33 33
34 void ExtensionInputMethodEventRouter::InputMethodChanged( 34 void ExtensionInputMethodEventRouter::InputMethodChanged(
35 input_method::InputMethodManager *manager, 35 input_method::InputMethodManager *manager) {
36 const input_method::InputMethodDescriptor &current_input_method,
37 size_t num_active_input_methods) {
38 Profile *profile = ProfileManager::GetDefaultProfile(); 36 Profile *profile = ProfileManager::GetDefaultProfile();
39 ExtensionEventRouter *router = profile->GetExtensionEventRouter(); 37 ExtensionEventRouter *router = profile->GetExtensionEventRouter();
40 38
41 if (!router->HasEventListener(extension_event_names::kOnInputMethodChanged)) 39 if (!router->HasEventListener(extension_event_names::kOnInputMethodChanged))
42 return; 40 return;
43 41
44 ListValue args; 42 ListValue args;
45 StringValue *input_method_name = 43 StringValue *input_method_name = new StringValue(
46 new StringValue(GetInputMethodForXkb(current_input_method.id())); 44 GetInputMethodForXkb(manager->GetCurrentInputMethod().id()));
47 args.Append(input_method_name); 45 args.Append(input_method_name);
48 std::string args_json; 46 std::string args_json;
49 base::JSONWriter::Write(&args, &args_json); 47 base::JSONWriter::Write(&args, &args_json);
50 48
51 // The router will only send the event to extensions that are listening. 49 // The router will only send the event to extensions that are listening.
52 router->DispatchEventToRenderers( 50 router->DispatchEventToRenderers(
53 extension_event_names::kOnInputMethodChanged, 51 extension_event_names::kOnInputMethodChanged,
54 args_json, profile, GURL()); 52 args_json, profile, GURL());
55 } 53 }
56 54
57 void ExtensionInputMethodEventRouter::ActiveInputMethodsChanged(
58 input_method::InputMethodManager *manager,
59 const input_method::InputMethodDescriptor &current_input_method,
60 size_t num_active_input_methods) {
61 }
62
63 void ExtensionInputMethodEventRouter::PropertyListChanged(
64 input_method::InputMethodManager *manager,
65 const input_method::InputMethodPropertyList &current_ime_properties) {
66 }
67
68 std::string ExtensionInputMethodEventRouter::GetInputMethodForXkb( 55 std::string ExtensionInputMethodEventRouter::GetInputMethodForXkb(
69 const std::string& xkb_id) { 56 const std::string& xkb_id) {
70 size_t prefix_length = std::string(kXkbPrefix).length(); 57 size_t prefix_length = std::string(kXkbPrefix).length();
71 DCHECK(xkb_id.substr(0, prefix_length) == kXkbPrefix); 58 DCHECK(xkb_id.substr(0, prefix_length) == kXkbPrefix);
72 return xkb_id.substr(prefix_length); 59 return xkb_id.substr(prefix_length);
73 } 60 }
74 61
75 } // namespace chromeos 62 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698