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

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

Issue 9264004: Make almost all public functions in XKeyboard pure virtual (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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 "chrome/browser/chromeos/input_method/input_method_manager.h" 5 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include <glib.h> 9 #include <glib.h>
10 10
11 #include "unicode/uloc.h" 11 #include "unicode/uloc.h"
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
mazda 2012/01/20 02:31:43 #include "base/memory/scoped_ptr.h"
Yusuke Sato 2012/01/20 03:33:48 Done.
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/process_util.h" 16 #include "base/process_util.h"
17 #include "base/string_split.h" 17 #include "base/string_split.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/input_method/hotkey_manager.h" 21 #include "chrome/browser/chromeos/input_method/hotkey_manager.h"
22 #include "chrome/browser/chromeos/input_method/input_method_util.h" 22 #include "chrome/browser/chromeos/input_method/input_method_util.h"
23 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" 23 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h"
24 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 24 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 public: 140 public:
141 InputMethodManagerImpl() 141 InputMethodManagerImpl()
142 : ibus_controller_(IBusController::Create()), 142 : ibus_controller_(IBusController::Create()),
143 should_launch_ime_(false), 143 should_launch_ime_(false),
144 ime_connected_(false), 144 ime_connected_(false),
145 defer_ime_startup_(false), 145 defer_ime_startup_(false),
146 enable_auto_ime_shutdown_(true), 146 enable_auto_ime_shutdown_(true),
147 shutting_down_(false), 147 shutting_down_(false),
148 ibus_daemon_process_handle_(base::kNullProcessHandle), 148 ibus_daemon_process_handle_(base::kNullProcessHandle),
149 util_(ibus_controller_->GetSupportedInputMethods()), 149 util_(ibus_controller_->GetSupportedInputMethods()),
150 xkeyboard_(util_) { 150 xkeyboard_(XKeyboard::Create(util_)) {
151 // Observe APP_TERMINATING to stop input method daemon gracefully. 151 // Observe APP_TERMINATING to stop input method daemon gracefully.
152 // We should not use APP_EXITING here since logout might be canceled by 152 // We should not use APP_EXITING here since logout might be canceled by
153 // JavaScript after APP_EXITING is sent (crosbug.com/11055). 153 // JavaScript after APP_EXITING is sent (crosbug.com/11055).
154 // Note that even if we fail to stop input method daemon from 154 // Note that even if we fail to stop input method daemon from
155 // Chrome in case of a sudden crash, we have a way to do it from an 155 // Chrome in case of a sudden crash, we have a way to do it from an
156 // upstart script. See crosbug.com/6515 and crosbug.com/6995 for 156 // upstart script. See crosbug.com/6515 and crosbug.com/6995 for
157 // details. 157 // details.
158 notification_registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 158 notification_registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
159 content::NotificationService::AllSources()); 159 content::NotificationService::AllSources());
160 160
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 virtual void ClearAllVirtualKeyboardPreferences() { 515 virtual void ClearAllVirtualKeyboardPreferences() {
516 virtual_keyboard_selector_.ClearAllUserPreferences(); 516 virtual_keyboard_selector_.ClearAllUserPreferences();
517 UpdateVirtualKeyboardUI(); 517 UpdateVirtualKeyboardUI();
518 } 518 }
519 519
520 virtual InputMethodUtil* GetInputMethodUtil() { 520 virtual InputMethodUtil* GetInputMethodUtil() {
521 return &util_; 521 return &util_;
522 } 522 }
523 523
524 virtual XKeyboard* GetXKeyboard() { 524 virtual XKeyboard* GetXKeyboard() {
525 return &xkeyboard_; 525 return xkeyboard_.get();
526 } 526 }
527 527
528 virtual HotkeyManager* GetHotkeyManager() { 528 virtual HotkeyManager* GetHotkeyManager() {
529 return &hotkey_manager_; 529 return &hotkey_manager_;
530 } 530 }
531 531
532 virtual void HotkeyPressed(HotkeyManager* manager, int event_id) { 532 virtual void HotkeyPressed(HotkeyManager* manager, int event_id) {
533 const HotkeyEvent event = HotkeyEvent(event_id); 533 const HotkeyEvent event = HotkeyEvent(event_id);
534 switch (event) { 534 switch (event) {
535 case kPreviousInputMethod: 535 case kPreviousInputMethod:
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 // descriptor. This function updates states like current_input_method_ 943 // descriptor. This function updates states like current_input_method_
944 // and notifies observers about the change (that will update the 944 // and notifies observers about the change (that will update the
945 // preferences), hence this function should always be used even if you 945 // preferences), hence this function should always be used even if you
946 // just need to change the current keyboard layout. 946 // just need to change the current keyboard layout.
947 void ChangeCurrentInputMethod(const InputMethodDescriptor& new_input_method) { 947 void ChangeCurrentInputMethod(const InputMethodDescriptor& new_input_method) {
948 if (current_input_method_.id() != new_input_method.id()) { 948 if (current_input_method_.id() != new_input_method.id()) {
949 previous_input_method_ = current_input_method_; 949 previous_input_method_ = current_input_method_;
950 current_input_method_ = new_input_method; 950 current_input_method_ = new_input_method;
951 951
952 // Change the keyboard layout to a preferred layout for the input method. 952 // Change the keyboard layout to a preferred layout for the input method.
953 if (!xkeyboard_.SetCurrentKeyboardLayoutByName( 953 if (!xkeyboard_->SetCurrentKeyboardLayoutByName(
954 current_input_method_.keyboard_layout())) { 954 current_input_method_.keyboard_layout())) {
955 LOG(ERROR) << "Failed to change keyboard layout to " 955 LOG(ERROR) << "Failed to change keyboard layout to "
956 << current_input_method_.keyboard_layout(); 956 << current_input_method_.keyboard_layout();
957 } 957 }
958 958
959 // Save the input method names to the Pref. 959 // Save the input method names to the Pref.
960 if (!UpdateInputMethodPreference(&post_login_preference_observers_)) { 960 if (!UpdateInputMethodPreference(&post_login_preference_observers_)) {
961 // When both pre- and post-login observers are available, only notifies 961 // When both pre- and post-login observers are available, only notifies
962 // the latter one. 962 // the latter one.
963 UpdateInputMethodPreference(&pre_login_preference_observers_); 963 UpdateInputMethodPreference(&pre_login_preference_observers_);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 // information. e.g. "mozc-jp" to XK_ZenkakuHankaku, "mozc-jp" to XK_Henkan. 1408 // information. e.g. "mozc-jp" to XK_ZenkakuHankaku, "mozc-jp" to XK_Henkan.
1409 std::multimap<std::string, 1409 std::multimap<std::string,
1410 const InputMethodSpecificHotkeySetting*> extra_hotkeys_; 1410 const InputMethodSpecificHotkeySetting*> extra_hotkeys_;
1411 1411
1412 // An object which provides miscellaneous input method utility functions. Note 1412 // An object which provides miscellaneous input method utility functions. Note
1413 // that |util_| is required to initialize |xkeyboard_|. 1413 // that |util_| is required to initialize |xkeyboard_|.
1414 InputMethodUtil util_; 1414 InputMethodUtil util_;
1415 1415
1416 // An object for switching XKB layouts and keyboard status like caps lock and 1416 // An object for switching XKB layouts and keyboard status like caps lock and
1417 // auto-repeat interval. 1417 // auto-repeat interval.
1418 XKeyboard xkeyboard_; 1418 scoped_ptr<XKeyboard> xkeyboard_;
1419 1419
1420 // An object which detects Control+space and Shift+Alt key presses. 1420 // An object which detects Control+space and Shift+Alt key presses.
1421 HotkeyManager hotkey_manager_; 1421 HotkeyManager hotkey_manager_;
1422 1422
1423 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); 1423 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl);
1424 }; 1424 };
1425 1425
1426 // static 1426 // static
1427 InputMethodManager* InputMethodManager::GetInstance() { 1427 InputMethodManager* InputMethodManager::GetInstance() {
1428 return InputMethodManagerImpl::GetInstance(); 1428 return InputMethodManagerImpl::GetInstance();
1429 } 1429 }
1430 1430
1431 } // namespace input_method 1431 } // namespace input_method
1432 } // namespace chromeos 1432 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/xkeyboard.h » ('j') | chrome/browser/chromeos/input_method/xkeyboard.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698