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

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

Issue 1055863002: ChromeOS: switch UI language before apps are loaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove empty line. Created 5 years, 7 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
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/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 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/profiles/profile.h"
12 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
13 #include "extensions/browser/event_router.h" 14 #include "extensions/browser/event_router.h"
14 #include "extensions/browser/extension_system.h" 15 #include "extensions/browser/extension_system.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 ExtensionInputMethodEventRouter::ExtensionInputMethodEventRouter( 19 ExtensionInputMethodEventRouter::ExtensionInputMethodEventRouter(
19 content::BrowserContext* context) 20 content::BrowserContext* context)
20 : context_(context) { 21 : context_(context) {
21 input_method::InputMethodManager::Get()->AddObserver(this); 22 input_method::InputMethodManager::Get()->AddObserver(this);
22 } 23 }
23 24
24 ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() { 25 ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() {
25 input_method::InputMethodManager::Get()->RemoveObserver(this); 26 input_method::InputMethodManager::Get()->RemoveObserver(this);
26 } 27 }
27 28
28 void ExtensionInputMethodEventRouter::InputMethodChanged( 29 void ExtensionInputMethodEventRouter::InputMethodChanged(
29 input_method::InputMethodManager *manager, 30 input_method::InputMethodManager* manager,
31 Profile* profile,
30 bool show_message) { 32 bool show_message) {
33 // This should probably be CHECK, as delivering event to a wrong
34 // profile means delivering it to a wrong extension instance.
35 DCHECK(profile->IsSameProfile(Profile::FromBrowserContext(context_)));
31 extensions::EventRouter* router = extensions::EventRouter::Get(context_); 36 extensions::EventRouter* router = extensions::EventRouter::Get(context_);
32 37
33 if (!router->HasEventListener( 38 if (!router->HasEventListener(
34 extensions::InputMethodAPI::kOnInputMethodChanged)) { 39 extensions::InputMethodAPI::kOnInputMethodChanged)) {
35 return; 40 return;
36 } 41 }
37 42
38 scoped_ptr<base::ListValue> args(new base::ListValue()); 43 scoped_ptr<base::ListValue> args(new base::ListValue());
39 base::StringValue* input_method_name = 44 base::StringValue* input_method_name =
40 new base::StringValue(extensions::InputMethodAPI::GetInputMethodForXkb( 45 new base::StringValue(extensions::InputMethodAPI::GetInputMethodForXkb(
41 manager->GetActiveIMEState()->GetCurrentInputMethod().id())); 46 manager->GetActiveIMEState()->GetCurrentInputMethod().id()));
42 args->Append(input_method_name); 47 args->Append(input_method_name);
43 48
44 // 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.
45 scoped_ptr<extensions::Event> event(new extensions::Event( 50 scoped_ptr<extensions::Event> event(new extensions::Event(
46 extensions::InputMethodAPI::kOnInputMethodChanged, args.Pass())); 51 extensions::InputMethodAPI::kOnInputMethodChanged, args.Pass()));
47 event->restrict_to_browser_context = context_; 52 event->restrict_to_browser_context = context_;
48 router->BroadcastEvent(event.Pass()); 53 router->BroadcastEvent(event.Pass());
49 } 54 }
50 55
51 } // namespace chromeos 56 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/input_method_event_router.h ('k') | chrome/browser/chromeos/input_method/accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698