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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_configuration.cc

Issue 12221045: Calling IBusBridge::Initialize/Shutdown function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing CHECK, IBusBridge::Get is also used for availability check. Created 7 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
« no previous file with comments | « no previous file | chromeos/ime/ibus_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/input_method/input_method_configuration.h" 5 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" 11 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h"
11 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" 12 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h"
12 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" 13 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h"
13 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" 14 #include "chrome/browser/chromeos/input_method/input_method_persistence.h"
15 #include "chromeos/ime/ibus_bridge.h"
14 16
15 namespace chromeos { 17 namespace chromeos {
16 namespace input_method { 18 namespace input_method {
17 19
18 namespace { 20 namespace {
19 InputMethodManager* g_input_method_manager = NULL; 21 InputMethodManager* g_input_method_manager = NULL;
20 InputMethodPersistence* g_input_method_persistence = NULL; 22 InputMethodPersistence* g_input_method_persistence = NULL;
21 BrowserStateMonitor* g_browser_state_monitor = NULL; 23 BrowserStateMonitor* g_browser_state_monitor = NULL;
22 } // namespace 24 } // namespace
23 25
24 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, 26 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl,
25 InputMethodPersistence* input_method_persistence, 27 InputMethodPersistence* input_method_persistence,
26 InputMethodManager::State new_state) { 28 InputMethodManager::State new_state) {
27 input_method_persistence->OnSessionStateChange(new_state); 29 input_method_persistence->OnSessionStateChange(new_state);
28 input_method_manager_impl->SetState(new_state); 30 input_method_manager_impl->SetState(new_state);
29 } 31 }
30 32
31 void Initialize() { 33 void Initialize() {
32 DCHECK(!g_input_method_manager); 34 DCHECK(!g_input_method_manager);
33 35
36 if (!base::chromeos::IsRunningOnChromeOS()) {
37 // IBusBridge is for ChromeOS on desktop Linux not for ChromeOS Devices or
38 // production at this moment.
39 // TODO(nona): Remove this condition when ibus-daemon is gone.
40 // (crbug.com/170671)
41 IBusBridge::Initialize();
42 }
43
34 InputMethodManagerImpl* impl = new InputMethodManagerImpl( 44 InputMethodManagerImpl* impl = new InputMethodManagerImpl(
35 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); 45 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl));
36 impl->Init(); 46 impl->Init();
37 g_input_method_manager = impl; 47 g_input_method_manager = impl;
38 g_input_method_persistence = 48 g_input_method_persistence =
39 new InputMethodPersistence(g_input_method_manager); 49 new InputMethodPersistence(g_input_method_manager);
40 g_browser_state_monitor = new BrowserStateMonitor( 50 g_browser_state_monitor = new BrowserStateMonitor(
41 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence)); 51 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence));
42 52
43 DVLOG(1) << "InputMethodManager initialized"; 53 DVLOG(1) << "InputMethodManager initialized";
44 } 54 }
45 55
46 void InitializeForTesting(InputMethodManager* mock_manager) { 56 void InitializeForTesting(InputMethodManager* mock_manager) {
47 DCHECK(!g_input_method_manager); 57 DCHECK(!g_input_method_manager);
48 g_input_method_manager = mock_manager; 58 g_input_method_manager = mock_manager;
49 DVLOG(1) << "InputMethodManager for testing initialized"; 59 DVLOG(1) << "InputMethodManager for testing initialized";
50 } 60 }
51 61
52 void Shutdown() { 62 void Shutdown() {
53 delete g_browser_state_monitor; 63 delete g_browser_state_monitor;
54 g_browser_state_monitor = NULL; 64 g_browser_state_monitor = NULL;
55 65
56 delete g_input_method_persistence; 66 delete g_input_method_persistence;
57 g_input_method_persistence = NULL; 67 g_input_method_persistence = NULL;
58 68
59 delete g_input_method_manager; 69 delete g_input_method_manager;
60 g_input_method_manager = NULL; 70 g_input_method_manager = NULL;
61 71
72 if (IBusBridge::Get()) {
73 // TODO(nona): Remove this condition when ibus-daemon is gone.
74 IBusBridge::Shutdown();
75 }
76
62 DVLOG(1) << "InputMethodManager shutdown"; 77 DVLOG(1) << "InputMethodManager shutdown";
63 } 78 }
64 79
65 InputMethodManager* GetInputMethodManager() { 80 InputMethodManager* GetInputMethodManager() {
66 DCHECK(g_input_method_manager); 81 DCHECK(g_input_method_manager);
67 return g_input_method_manager; 82 return g_input_method_manager;
68 } 83 }
69 84
70 } // namespace input_method 85 } // namespace input_method
71 } // namespace chromeos 86 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/ime/ibus_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698