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 "chrome/browser/chromeos/extensions/input_method_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 bool show_message) { | 36 bool show_message) { |
37 // This should probably be CHECK, as delivering event to a wrong | 37 // This should probably be CHECK, as delivering event to a wrong |
38 // profile means delivering it to a wrong extension instance. | 38 // profile means delivering it to a wrong extension instance. |
39 DCHECK(profile->IsSameProfile(Profile::FromBrowserContext(context_))); | 39 DCHECK(profile->IsSameProfile(Profile::FromBrowserContext(context_))); |
40 extensions::EventRouter* router = extensions::EventRouter::Get(context_); | 40 extensions::EventRouter* router = extensions::EventRouter::Get(context_); |
41 | 41 |
42 if (!router->HasEventListener(OnChanged::kEventName)) | 42 if (!router->HasEventListener(OnChanged::kEventName)) |
43 return; | 43 return; |
44 | 44 |
45 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 45 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
46 args->Append(new base::StringValue( | 46 args->AppendString( |
47 manager->GetActiveIMEState()->GetCurrentInputMethod().id())); | 47 manager->GetActiveIMEState()->GetCurrentInputMethod().id()); |
48 | 48 |
49 // 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. |
50 std::unique_ptr<extensions::Event> event( | 50 std::unique_ptr<extensions::Event> event( |
51 new extensions::Event(extensions::events::INPUT_METHOD_PRIVATE_ON_CHANGED, | 51 new extensions::Event(extensions::events::INPUT_METHOD_PRIVATE_ON_CHANGED, |
52 OnChanged::kEventName, std::move(args))); | 52 OnChanged::kEventName, std::move(args))); |
53 event->restrict_to_browser_context = context_; | 53 event->restrict_to_browser_context = context_; |
54 router->BroadcastEvent(std::move(event)); | 54 router->BroadcastEvent(std::move(event)); |
55 } | 55 } |
56 | 56 |
57 } // namespace chromeos | 57 } // namespace chromeos |
OLD | NEW |