| 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/ibus_controller_impl.h" | 5 #include "chrome/browser/chromeos/input_method/ibus_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> // for std::reverse. | 7 #include <algorithm> // for std::reverse. |
| 8 #include <cstdio> | 8 #include <cstdio> |
| 9 #include <cstring> // for std::strcmp. | 9 #include <cstring> // for std::strcmp. |
| 10 #include <set> | 10 #include <set> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 23 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 24 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 25 #include "chromeos/dbus/dbus_thread_manager.h" | 25 #include "chromeos/dbus/dbus_thread_manager.h" |
| 26 #include "chromeos/dbus/ibus/ibus_client.h" | 26 #include "chromeos/dbus/ibus/ibus_client.h" |
| 27 #include "chromeos/dbus/ibus/ibus_config_client.h" | 27 #include "chromeos/dbus/ibus/ibus_config_client.h" |
| 28 #include "chromeos/dbus/ibus/ibus_constants.h" | 28 #include "chromeos/dbus/ibus/ibus_constants.h" |
| 29 #include "chromeos/dbus/ibus/ibus_input_context_client.h" | 29 #include "chromeos/dbus/ibus/ibus_input_context_client.h" |
| 30 #include "chromeos/dbus/ibus/ibus_panel_service.h" | 30 #include "chromeos/dbus/ibus/ibus_panel_service.h" |
| 31 #include "chromeos/dbus/ibus/ibus_property.h" | 31 #include "chromeos/dbus/ibus/ibus_property.h" |
| 32 #include "chromeos/ime/extension_ime_util.h" |
| 32 #include "chromeos/ime/input_method_config.h" | 33 #include "chromeos/ime/input_method_config.h" |
| 33 #include "chromeos/ime/input_method_property.h" | 34 #include "chromeos/ime/input_method_property.h" |
| 34 #include "ui/aura/client/aura_constants.h" | 35 #include "ui/aura/client/aura_constants.h" |
| 35 #include "ui/aura/root_window.h" | 36 #include "ui/aura/root_window.h" |
| 36 #include "ui/base/ime/input_method_ibus.h" | 37 #include "ui/base/ime/input_method_ibus.h" |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 // Finds a property which has |new_prop.key| from |prop_list|, and replaces the | 41 // Finds a property which has |new_prop.key| from |prop_list|, and replaces the |
| 41 // property with |new_prop|. Returns true if such a property is found. | 42 // property with |new_prop|. Returns true if such a property is found. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 194 } |
| 194 | 195 |
| 195 IBusControllerImpl::~IBusControllerImpl() { | 196 IBusControllerImpl::~IBusControllerImpl() { |
| 196 IBusDaemonController::GetInstance()->RemoveObserver(this); | 197 IBusDaemonController::GetInstance()->RemoveObserver(this); |
| 197 } | 198 } |
| 198 | 199 |
| 199 bool IBusControllerImpl::ChangeInputMethod(const std::string& id) { | 200 bool IBusControllerImpl::ChangeInputMethod(const std::string& id) { |
| 200 // Sanity checks. | 201 // Sanity checks. |
| 201 DCHECK(!InputMethodUtil::IsKeyboardLayout(id)); | 202 DCHECK(!InputMethodUtil::IsKeyboardLayout(id)); |
| 202 if (!whitelist_.InputMethodIdIsWhitelisted(id) && | 203 if (!whitelist_.InputMethodIdIsWhitelisted(id) && |
| 203 !InputMethodUtil::IsExtensionInputMethod(id)) | 204 !extension_ime_util::IsExtensionIME(id)) |
| 204 return false; | 205 return false; |
| 205 | 206 |
| 206 // Clear input method properties unconditionally if |id| is not equal to | 207 // Clear input method properties unconditionally if |id| is not equal to |
| 207 // |current_input_method_id_|. | 208 // |current_input_method_id_|. |
| 208 // | 209 // |
| 209 // When switching to another input method and no text area is focused, | 210 // When switching to another input method and no text area is focused, |
| 210 // RegisterProperties signal for the new input method will NOT be sent | 211 // RegisterProperties signal for the new input method will NOT be sent |
| 211 // until a text area is focused. Therefore, we have to clear the old input | 212 // until a text area is focused. Therefore, we have to clear the old input |
| 212 // method properties here to keep the input method switcher status | 213 // method properties here to keep the input method switcher status |
| 213 // consistent. | 214 // consistent. |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 385 |
| 385 // static | 386 // static |
| 386 bool IBusControllerImpl::FindAndUpdatePropertyForTesting( | 387 bool IBusControllerImpl::FindAndUpdatePropertyForTesting( |
| 387 const chromeos::input_method::InputMethodProperty& new_prop, | 388 const chromeos::input_method::InputMethodProperty& new_prop, |
| 388 chromeos::input_method::InputMethodPropertyList* prop_list) { | 389 chromeos::input_method::InputMethodPropertyList* prop_list) { |
| 389 return FindAndUpdateProperty(new_prop, prop_list); | 390 return FindAndUpdateProperty(new_prop, prop_list); |
| 390 } | 391 } |
| 391 | 392 |
| 392 } // namespace input_method | 393 } // namespace input_method |
| 393 } // namespace chromeos | 394 } // namespace chromeos |
| OLD | NEW |