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_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
6 | 6 |
7 #include <algorithm> // std::find | 7 #include <algorithm> // std::find |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
31 #include "chromeos/ime/component_extension_ime_manager.h" | 31 #include "chromeos/ime/component_extension_ime_manager.h" |
32 #include "chromeos/ime/extension_ime_util.h" | 32 #include "chromeos/ime/extension_ime_util.h" |
33 #include "chromeos/ime/fake_ime_keyboard.h" | 33 #include "chromeos/ime/fake_ime_keyboard.h" |
34 #include "chromeos/ime/ime_keyboard.h" | 34 #include "chromeos/ime/ime_keyboard.h" |
35 #include "chromeos/ime/input_method_delegate.h" | 35 #include "chromeos/ime/input_method_delegate.h" |
36 #include "components/user_manager/user_manager.h" | 36 #include "components/user_manager/user_manager.h" |
37 #include "third_party/icu/source/common/unicode/uloc.h" | 37 #include "third_party/icu/source/common/unicode/uloc.h" |
38 #include "ui/base/accelerators/accelerator.h" | 38 #include "ui/base/accelerators/accelerator.h" |
| 39 #include "ui/keyboard/keyboard_controller.h" |
| 40 #include "ui/keyboard/keyboard_util.h" |
39 | 41 |
40 namespace chromeos { | 42 namespace chromeos { |
41 namespace input_method { | 43 namespace input_method { |
42 | 44 |
43 namespace { | 45 namespace { |
44 | 46 |
45 bool Contains(const std::vector<std::string>& container, | 47 bool Contains(const std::vector<std::string>& container, |
46 const std::string& value) { | 48 const std::string& value) { |
47 return std::find(container.begin(), container.end(), value) != | 49 return std::find(container.begin(), container.end(), value) != |
48 container.end(); | 50 container.end(); |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 // This must be after |current_input_method| has been set to new input | 909 // This must be after |current_input_method| has been set to new input |
908 // method, because engine's Enable() method needs to access it. | 910 // method, because engine's Enable() method needs to access it. |
909 const std::string& extension_id = | 911 const std::string& extension_id = |
910 extension_ime_util::GetExtensionIDFromInputMethodID(descriptor.id()); | 912 extension_ime_util::GetExtensionIDFromInputMethodID(descriptor.id()); |
911 const std::string& component_id = | 913 const std::string& component_id = |
912 extension_ime_util::GetComponentIDByInputMethodID(descriptor.id()); | 914 extension_ime_util::GetComponentIDByInputMethodID(descriptor.id()); |
913 engine = engine_map_[extension_id]; | 915 engine = engine_map_[extension_id]; |
914 | 916 |
915 IMEBridge::Get()->SetCurrentEngineHandler(engine); | 917 IMEBridge::Get()->SetCurrentEngineHandler(engine); |
916 | 918 |
917 if (engine) | 919 if (engine) { |
918 engine->Enable(component_id); | 920 engine->Enable(component_id); |
| 921 } else { |
| 922 // If no engine to enable, cancel the virtual keyboard url override so that |
| 923 // it can use the fallback system virtual keyboard UI. |
| 924 keyboard::SetOverrideContentUrl(GURL()); |
| 925 keyboard::KeyboardController* keyboard_controller = |
| 926 keyboard::KeyboardController::GetInstance(); |
| 927 if (keyboard_controller) |
| 928 keyboard_controller->Reload(); |
| 929 } |
919 | 930 |
920 // Change the keyboard layout to a preferred layout for the input method. | 931 // Change the keyboard layout to a preferred layout for the input method. |
921 if (!keyboard_->SetCurrentKeyboardLayoutByName( | 932 if (!keyboard_->SetCurrentKeyboardLayoutByName( |
922 descriptor.GetPreferredKeyboardLayout())) { | 933 descriptor.GetPreferredKeyboardLayout())) { |
923 LOG(ERROR) << "Failed to change keyboard layout to " | 934 LOG(ERROR) << "Failed to change keyboard layout to " |
924 << descriptor.GetPreferredKeyboardLayout(); | 935 << descriptor.GetPreferredKeyboardLayout(); |
925 } | 936 } |
926 | 937 |
927 // Update input method indicators (e.g. "US", "DV") in Chrome windows. | 938 // Update input method indicators (e.g. "US", "DV") in Chrome windows. |
928 FOR_EACH_OBSERVER(InputMethodManager::Observer, | 939 FOR_EACH_OBSERVER(InputMethodManager::Observer, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 if (candidate_window_controller_.get()) | 1049 if (candidate_window_controller_.get()) |
1039 return; | 1050 return; |
1040 | 1051 |
1041 candidate_window_controller_.reset( | 1052 candidate_window_controller_.reset( |
1042 CandidateWindowController::CreateCandidateWindowController()); | 1053 CandidateWindowController::CreateCandidateWindowController()); |
1043 candidate_window_controller_->AddObserver(this); | 1054 candidate_window_controller_->AddObserver(this); |
1044 } | 1055 } |
1045 | 1056 |
1046 } // namespace input_method | 1057 } // namespace input_method |
1047 } // namespace chromeos | 1058 } // namespace chromeos |
OLD | NEW |