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

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

Issue 147923005: Split ExtensionSystem interface from ExtensionSystemImpl implementation, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re^3base 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 | 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"
11 #include "chrome/browser/chromeos/extensions/input_method_api.h" 11 #include "chrome/browser/chromeos/extensions/input_method_api.h"
12 #include "chrome/browser/extensions/event_names.h" 12 #include "chrome/browser/extensions/event_names.h"
13 #include "chrome/browser/extensions/extension_system.h"
14 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
15 #include "extensions/browser/event_router.h" 14 #include "extensions/browser/event_router.h"
15 #include "extensions/browser/extension_system.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 ExtensionInputMethodEventRouter::ExtensionInputMethodEventRouter( 19 ExtensionInputMethodEventRouter::ExtensionInputMethodEventRouter(
20 content::BrowserContext* context) 20 content::BrowserContext* context)
21 : context_(context) { 21 : context_(context) {
22 input_method::InputMethodManager::Get()->AddObserver(this); 22 input_method::InputMethodManager::Get()->AddObserver(this);
23 } 23 }
24 24
25 ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() { 25 ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() {
26 input_method::InputMethodManager::Get()->RemoveObserver(this); 26 input_method::InputMethodManager::Get()->RemoveObserver(this);
27 } 27 }
28 28
29 void ExtensionInputMethodEventRouter::InputMethodChanged( 29 void ExtensionInputMethodEventRouter::InputMethodChanged(
30 input_method::InputMethodManager *manager, 30 input_method::InputMethodManager *manager,
31 bool show_message) { 31 bool show_message) {
32 extensions::EventRouter *router = 32 extensions::EventRouter *router =
33 extensions::ExtensionSystem::GetForBrowserContext(context_)-> 33 extensions::ExtensionSystem::Get(context_)->event_router();
34 event_router();
35 34
36 if (!router->HasEventListener(extensions::event_names::kOnInputMethodChanged)) 35 if (!router->HasEventListener(extensions::event_names::kOnInputMethodChanged))
37 return; 36 return;
38 37
39 scoped_ptr<base::ListValue> args(new base::ListValue()); 38 scoped_ptr<base::ListValue> args(new base::ListValue());
40 base::StringValue *input_method_name = new base::StringValue( 39 base::StringValue *input_method_name = new base::StringValue(
41 extensions::InputMethodAPI::GetInputMethodForXkb( 40 extensions::InputMethodAPI::GetInputMethodForXkb(
42 manager->GetCurrentInputMethod().id())); 41 manager->GetCurrentInputMethod().id()));
43 args->Append(input_method_name); 42 args->Append(input_method_name);
44 43
45 // The router will only send the event to extensions that are listening. 44 // The router will only send the event to extensions that are listening.
46 scoped_ptr<extensions::Event> event(new extensions::Event( 45 scoped_ptr<extensions::Event> event(new extensions::Event(
47 extensions::event_names::kOnInputMethodChanged, args.Pass())); 46 extensions::event_names::kOnInputMethodChanged, args.Pass()));
48 event->restrict_to_browser_context = context_; 47 event->restrict_to_browser_context = context_;
49 router->BroadcastEvent(event.Pass()); 48 router->BroadcastEvent(event.Pass());
50 } 49 }
51 50
52 } // namespace chromeos 51 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698