BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / input_method_configuration.cc
blob23dc5b83c30ede89a1f3cfe76d2f6dfb6d417f6a
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chromeos/input_method/accessibility.h"
11 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h"
12 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h"
13 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h"
14 #include "chrome/browser/chromeos/input_method/input_method_persistence.h"
15 #include "ui/base/ime/chromeos/ime_bridge.h"
17 namespace chromeos {
18 namespace input_method {
20 namespace {
21 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl,
22 InputMethodPersistence* input_method_persistence,
23 InputMethodManager::UISessionState new_ui_session) {
24 input_method_persistence->OnSessionStateChange(new_ui_session);
25 input_method_manager_impl->SetUISessionState(new_ui_session);
28 bool g_disable_extension_loading = false;
30 class InputMethodConfiguration {
31 public:
32 InputMethodConfiguration() {}
33 virtual ~InputMethodConfiguration() {}
35 void Initialize() {
36 IMEBridge::Initialize();
38 InputMethodManagerImpl* impl = new InputMethodManagerImpl(
39 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl),
40 !g_disable_extension_loading);
41 InputMethodManager::Initialize(impl);
43 DCHECK(InputMethodManager::Get());
45 accessibility_.reset(new Accessibility(impl));
46 input_method_persistence_.reset(new InputMethodPersistence(impl));
47 browser_state_monitor_.reset(new BrowserStateMonitor(
48 base::Bind(&OnSessionStateChange,
49 impl,
50 input_method_persistence_.get())));
52 DVLOG(1) << "InputMethodManager initialized";
55 void InitializeForTesting(InputMethodManager* mock_manager) {
56 InputMethodManager::Initialize(mock_manager);
57 DVLOG(1) << "InputMethodManager for testing initialized";
60 void Shutdown() {
61 accessibility_.reset();
62 browser_state_monitor_.reset();
63 input_method_persistence_.reset();
65 InputMethodManager::Shutdown();
67 IMEBridge::Shutdown();
69 DVLOG(1) << "InputMethodManager shutdown";
72 private:
73 scoped_ptr<Accessibility> accessibility_;
74 scoped_ptr<BrowserStateMonitor> browser_state_monitor_;
75 scoped_ptr<InputMethodPersistence> input_method_persistence_;
78 InputMethodConfiguration* g_input_method_configuration = NULL;
80 } // namespace
82 void Initialize() {
83 if (!g_input_method_configuration)
84 g_input_method_configuration = new InputMethodConfiguration();
85 g_input_method_configuration->Initialize();
88 void InitializeForTesting(InputMethodManager* mock_manager) {
89 if (!g_input_method_configuration)
90 g_input_method_configuration = new InputMethodConfiguration();
91 g_input_method_configuration->InitializeForTesting(mock_manager);
94 void DisableExtensionLoading() {
95 g_disable_extension_loading = true;
98 void Shutdown() {
99 if (!g_input_method_configuration)
100 return;
102 g_input_method_configuration->Shutdown();
103 delete g_input_method_configuration;
104 g_input_method_configuration = NULL;
107 } // namespace input_method
108 } // namespace chromeos