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

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: Fix initial locale load, when no user is active yet. 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 CHECK(static_cast<content::BrowserContext*>(profile) == context_);
robliao 2015/05/06 18:20:32 This will trigger a chrome crash if it fails. How
Alexander Alekseev 2015/05/07 15:21:57 Here is crbug.com/483258 - what happens (crash) wh
robliao 2015/05/08 17:30:20 Add a comment about the use of the CHECK here then
Alexander Alekseev 2015/05/12 17:30:45 I've replaced CHECK with DCHECK and comment. I'll
31 extensions::EventRouter* router = extensions::EventRouter::Get(context_); 34 extensions::EventRouter* router = extensions::EventRouter::Get(context_);
32 35
33 if (!router->HasEventListener( 36 if (!router->HasEventListener(
34 extensions::InputMethodAPI::kOnInputMethodChanged)) { 37 extensions::InputMethodAPI::kOnInputMethodChanged)) {
35 return; 38 return;
36 } 39 }
37 40
38 scoped_ptr<base::ListValue> args(new base::ListValue()); 41 scoped_ptr<base::ListValue> args(new base::ListValue());
39 base::StringValue* input_method_name = 42 base::StringValue* input_method_name =
40 new base::StringValue(extensions::InputMethodAPI::GetInputMethodForXkb( 43 new base::StringValue(extensions::InputMethodAPI::GetInputMethodForXkb(
41 manager->GetActiveIMEState()->GetCurrentInputMethod().id())); 44 manager->GetActiveIMEState()->GetCurrentInputMethod().id()));
42 args->Append(input_method_name); 45 args->Append(input_method_name);
43 46
44 // The router will only send the event to extensions that are listening. 47 // The router will only send the event to extensions that are listening.
45 scoped_ptr<extensions::Event> event(new extensions::Event( 48 scoped_ptr<extensions::Event> event(new extensions::Event(
46 extensions::InputMethodAPI::kOnInputMethodChanged, args.Pass())); 49 extensions::InputMethodAPI::kOnInputMethodChanged, args.Pass()));
47 event->restrict_to_browser_context = context_; 50 event->restrict_to_browser_context = context_;
48 router->BroadcastEvent(event.Pass()); 51 router->BroadcastEvent(event.Pass());
49 } 52 }
50 53
51 } // namespace chromeos 54 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698