| OLD | NEW |
| 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 "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
| 16 #include "base/string_split.h" | 16 #include "base/string_split.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 20 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 21 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
| 21 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" | 22 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" |
| 22 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 23 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 23 #include "chrome/browser/chromeos/language_preferences.h" | 24 #include "chrome/browser/chromeos/language_preferences.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
| 27 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| 29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 30 #include "ui/base/accelerators/accelerator.h" | 31 #include "ui/base/accelerators/accelerator.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 public IBusController::Observer { | 149 public IBusController::Observer { |
| 149 public: | 150 public: |
| 150 InputMethodManagerImpl() | 151 InputMethodManagerImpl() |
| 151 : ibus_controller_(IBusController::Create()), | 152 : ibus_controller_(IBusController::Create()), |
| 152 should_hide_properties_(true), | 153 should_hide_properties_(true), |
| 153 should_launch_ime_(false), | 154 should_launch_ime_(false), |
| 154 ime_connected_(false), | 155 ime_connected_(false), |
| 155 enable_auto_ime_shutdown_(true), | 156 enable_auto_ime_shutdown_(true), |
| 156 shutting_down_(false), | 157 shutting_down_(false), |
| 157 ibus_daemon_process_handle_(base::kNullProcessHandle), | 158 ibus_daemon_process_handle_(base::kNullProcessHandle), |
| 158 util_(ibus_controller_->GetSupportedInputMethods()), | 159 util_(whitelist_.GetSupportedInputMethods()), |
| 159 xkeyboard_(XKeyboard::Create(util_)), | 160 xkeyboard_(XKeyboard::Create(util_)), |
| 160 ignore_hotkeys_(false) { | 161 ignore_hotkeys_(false) { |
| 161 // Observe APP_TERMINATING to stop input method daemon gracefully. | 162 // Observe APP_TERMINATING to stop input method daemon gracefully. |
| 162 // We should not use APP_EXITING here since logout might be canceled by | 163 // We should not use APP_EXITING here since logout might be canceled by |
| 163 // JavaScript after APP_EXITING is sent (crosbug.com/11055). | 164 // JavaScript after APP_EXITING is sent (crosbug.com/11055). |
| 164 // Note that even if we fail to stop input method daemon from | 165 // Note that even if we fail to stop input method daemon from |
| 165 // Chrome in case of a sudden crash, we have a way to do it from an | 166 // Chrome in case of a sudden crash, we have a way to do it from an |
| 166 // upstart script. See crosbug.com/6515 and crosbug.com/6995 for | 167 // upstart script. See crosbug.com/6515 and crosbug.com/6995 for |
| 167 // details. | 168 // details. |
| 168 notification_registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 169 notification_registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 290 } |
| 290 return result; | 291 return result; |
| 291 } | 292 } |
| 292 | 293 |
| 293 virtual size_t GetNumActiveInputMethods() { | 294 virtual size_t GetNumActiveInputMethods() { |
| 294 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); | 295 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); |
| 295 return input_methods->size(); | 296 return input_methods->size(); |
| 296 } | 297 } |
| 297 | 298 |
| 298 virtual InputMethodDescriptors* GetSupportedInputMethods() { | 299 virtual InputMethodDescriptors* GetSupportedInputMethods() { |
| 299 return ibus_controller_->GetSupportedInputMethods(); | 300 return whitelist_.GetSupportedInputMethods(); |
| 300 } | 301 } |
| 301 | 302 |
| 302 virtual void ChangeInputMethod(const std::string& input_method_id) { | 303 virtual void ChangeInputMethod(const std::string& input_method_id) { |
| 303 // Changing the input method isn't guaranteed to succeed here, but we | 304 // Changing the input method isn't guaranteed to succeed here, but we |
| 304 // should remember the last one regardless. See comments in | 305 // should remember the last one regardless. See comments in |
| 305 // FlushImeConfig() for details. | 306 // FlushImeConfig() for details. |
| 306 tentative_current_input_method_id_ = input_method_id; | 307 tentative_current_input_method_id_ = input_method_id; |
| 307 | 308 |
| 308 if (InputMethodUtil::IsKeyboardLayout(input_method_id) | 309 if (InputMethodUtil::IsKeyboardLayout(input_method_id) |
| 309 #if !defined(USE_AURA) | 310 #if !defined(USE_AURA) |
| (...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 // those created by extension. | 1520 // those created by extension. |
| 1520 std::map<std::string, InputMethodDescriptor> extra_input_method_ids_; | 1521 std::map<std::string, InputMethodDescriptor> extra_input_method_ids_; |
| 1521 | 1522 |
| 1522 #if !defined(USE_AURA) | 1523 #if !defined(USE_AURA) |
| 1523 // A muitlmap from input method id to input method specific hotkey | 1524 // A muitlmap from input method id to input method specific hotkey |
| 1524 // information. e.g. "mozc-jp" to XK_ZenkakuHankaku, "mozc-jp" to XK_Henkan. | 1525 // information. e.g. "mozc-jp" to XK_ZenkakuHankaku, "mozc-jp" to XK_Henkan. |
| 1525 std::multimap<std::string, | 1526 std::multimap<std::string, |
| 1526 const InputMethodSpecificHotkeySetting*> extra_hotkeys_; | 1527 const InputMethodSpecificHotkeySetting*> extra_hotkeys_; |
| 1527 #endif | 1528 #endif |
| 1528 | 1529 |
| 1530 InputMethodWhitelist whitelist_; |
| 1531 |
| 1529 // An object which provides miscellaneous input method utility functions. Note | 1532 // An object which provides miscellaneous input method utility functions. Note |
| 1530 // that |util_| is required to initialize |xkeyboard_|. | 1533 // that |util_| is required to initialize |xkeyboard_|. |
| 1531 InputMethodUtil util_; | 1534 InputMethodUtil util_; |
| 1532 | 1535 |
| 1533 // An object for switching XKB layouts and keyboard status like caps lock and | 1536 // An object for switching XKB layouts and keyboard status like caps lock and |
| 1534 // auto-repeat interval. | 1537 // auto-repeat interval. |
| 1535 scoped_ptr<XKeyboard> xkeyboard_; | 1538 scoped_ptr<XKeyboard> xkeyboard_; |
| 1536 | 1539 |
| 1537 #if !defined(USE_AURA) | 1540 #if !defined(USE_AURA) |
| 1538 // An object which detects Control+space and Shift+Alt key presses. | 1541 // An object which detects Control+space and Shift+Alt key presses. |
| 1539 HotkeyManager hotkey_manager_; | 1542 HotkeyManager hotkey_manager_; |
| 1540 #endif | 1543 #endif |
| 1541 | 1544 |
| 1542 // true when DisableHotkeys() is called to temporarily disable IME hotkeys. | 1545 // true when DisableHotkeys() is called to temporarily disable IME hotkeys. |
| 1543 // EnableHotkeys() resets the flag to the default value, false. | 1546 // EnableHotkeys() resets the flag to the default value, false. |
| 1544 bool ignore_hotkeys_; | 1547 bool ignore_hotkeys_; |
| 1545 | 1548 |
| 1546 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); | 1549 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); |
| 1547 }; | 1550 }; |
| 1548 | 1551 |
| 1549 // static | 1552 // static |
| 1550 InputMethodManager* InputMethodManager::GetInstance() { | 1553 InputMethodManager* InputMethodManager::GetInstance() { |
| 1551 return InputMethodManagerImpl::GetInstance(); | 1554 return InputMethodManagerImpl::GetInstance(); |
| 1552 } | 1555 } |
| 1553 | 1556 |
| 1554 } // namespace input_method | 1557 } // namespace input_method |
| 1555 } // namespace chromeos | 1558 } // namespace chromeos |
| OLD | NEW |