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

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

Powered by Google App Engine
This is Rietveld 408576698