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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> // std::find | 9 #include <algorithm> // std::find |
10 #include <memory> | 10 #include <memory> |
11 #include <set> | 11 #include <set> |
12 #include <sstream> | 12 #include <sstream> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/feature_list.h" | 17 #include "base/feature_list.h" |
18 #include "base/hash.h" | 18 #include "base/hash.h" |
19 #include "base/location.h" | 19 #include "base/location.h" |
20 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
21 #include "base/metrics/sparse_histogram.h" | 21 #include "base/metrics/sparse_histogram.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chromeos/ash_config.h" | 25 #include "chrome/browser/chromeos/ash_config.h" |
26 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" | 26 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" |
27 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i
mpl.h" | 27 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i
mpl.h" |
28 #include "chrome/browser/chromeos/input_method/input_method_switch_recorder.h" | |
29 #include "chrome/browser/chromeos/language_preferences.h" | 28 #include "chrome/browser/chromeos/language_preferences.h" |
30 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 29 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
31 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 30 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
32 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/common/chrome_features.h" | 32 #include "chrome/common/chrome_features.h" |
34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
35 #include "chromeos/system/devicemode.h" | 34 #include "chromeos/system/devicemode.h" |
36 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
37 #include "components/user_manager/user_manager.h" | 36 #include "components/user_manager/user_manager.h" |
38 #include "third_party/icu/source/common/unicode/uloc.h" | 37 #include "third_party/icu/source/common/unicode/uloc.h" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 } | 734 } |
736 | 735 |
737 void InputMethodManagerImpl::StateImpl::SwitchToNextInputMethod() { | 736 void InputMethodManagerImpl::StateImpl::SwitchToNextInputMethod() { |
738 DCHECK(CanCycleInputMethod()); | 737 DCHECK(CanCycleInputMethod()); |
739 if (!CanCycleInputMethod()) | 738 if (!CanCycleInputMethod()) |
740 return; | 739 return; |
741 | 740 |
742 // Find the next input method and switch to it. | 741 // Find the next input method and switch to it. |
743 SwitchToNextInputMethodInternal(active_input_method_ids, | 742 SwitchToNextInputMethodInternal(active_input_method_ids, |
744 current_input_method.id()); | 743 current_input_method.id()); |
745 InputMethodSwitchRecorder::Get()->RecordSwitch(false /* by_tray_menu*/); | |
746 } | 744 } |
747 | 745 |
748 void InputMethodManagerImpl::StateImpl::SwitchToPreviousInputMethod() { | 746 void InputMethodManagerImpl::StateImpl::SwitchToPreviousInputMethod() { |
749 DCHECK(CanCycleInputMethod()); | 747 DCHECK(CanCycleInputMethod()); |
750 if (!CanCycleInputMethod()) | 748 if (!CanCycleInputMethod()) |
751 return; | 749 return; |
752 | 750 |
753 if (previous_input_method.id().empty() || | 751 if (previous_input_method.id().empty() || |
754 previous_input_method.id() == current_input_method.id()) { | 752 previous_input_method.id() == current_input_method.id()) { |
755 SwitchToNextInputMethod(); | 753 SwitchToNextInputMethod(); |
756 return; | 754 return; |
757 } | 755 } |
758 | 756 |
759 std::vector<std::string>::const_iterator iter = | 757 std::vector<std::string>::const_iterator iter = |
760 std::find(active_input_method_ids.begin(), | 758 std::find(active_input_method_ids.begin(), |
761 active_input_method_ids.end(), | 759 active_input_method_ids.end(), |
762 previous_input_method.id()); | 760 previous_input_method.id()); |
763 if (iter == active_input_method_ids.end()) { | 761 if (iter == active_input_method_ids.end()) { |
764 // previous_input_method is not supported. | 762 // previous_input_method is not supported. |
765 SwitchToNextInputMethod(); | 763 SwitchToNextInputMethod(); |
766 return; | 764 return; |
767 } | 765 } |
768 ChangeInputMethod(*iter, true); | 766 ChangeInputMethod(*iter, true); |
769 InputMethodSwitchRecorder::Get()->RecordSwitch(false /* by_tray_menu*/); | |
770 } | 767 } |
771 | 768 |
772 bool InputMethodManagerImpl::StateImpl::CanSwitchInputMethod( | 769 bool InputMethodManagerImpl::StateImpl::CanSwitchInputMethod( |
773 const ui::Accelerator& accelerator) { | 770 const ui::Accelerator& accelerator) { |
774 // If none of the input methods associated with |accelerator| are active, we | 771 // If none of the input methods associated with |accelerator| are active, we |
775 // should ignore the accelerator. For example, we should just ignore | 772 // should ignore the accelerator. For example, we should just ignore |
776 // VKEY_HANGUL when mozc-hangul is not active. | 773 // VKEY_HANGUL when mozc-hangul is not active. |
777 std::vector<std::string> candidate_ids; | 774 std::vector<std::string> candidate_ids; |
778 GetCandidateInputMethodsForAccelerator(accelerator, &candidate_ids); | 775 GetCandidateInputMethodsForAccelerator(accelerator, &candidate_ids); |
779 return !candidate_ids.empty(); | 776 return !candidate_ids.empty(); |
780 } | 777 } |
781 | 778 |
782 void InputMethodManagerImpl::StateImpl::SwitchInputMethod( | 779 void InputMethodManagerImpl::StateImpl::SwitchInputMethod( |
783 const ui::Accelerator& accelerator) { | 780 const ui::Accelerator& accelerator) { |
784 std::vector<std::string> candidate_ids; | 781 std::vector<std::string> candidate_ids; |
785 GetCandidateInputMethodsForAccelerator(accelerator, &candidate_ids); | 782 GetCandidateInputMethodsForAccelerator(accelerator, &candidate_ids); |
786 DCHECK(!candidate_ids.empty()); | 783 DCHECK(!candidate_ids.empty()); |
787 if (!candidate_ids.empty()) { | 784 if (!candidate_ids.empty()) |
788 SwitchToNextInputMethodInternal(candidate_ids, current_input_method.id()); | 785 SwitchToNextInputMethodInternal(candidate_ids, current_input_method.id()); |
789 InputMethodSwitchRecorder::Get()->RecordSwitch(false /* by_tray_menu*/); | |
790 } | |
791 } | 786 } |
792 | 787 |
793 void InputMethodManagerImpl::StateImpl::SwitchToNextInputMethodInternal( | 788 void InputMethodManagerImpl::StateImpl::SwitchToNextInputMethodInternal( |
794 const std::vector<std::string>& input_method_ids, | 789 const std::vector<std::string>& input_method_ids, |
795 const std::string& current_input_methodid) { | 790 const std::string& current_input_methodid) { |
796 std::vector<std::string>::const_iterator iter = std::find( | 791 std::vector<std::string>::const_iterator iter = std::find( |
797 input_method_ids.begin(), input_method_ids.end(), current_input_methodid); | 792 input_method_ids.begin(), input_method_ids.end(), current_input_methodid); |
798 if (iter != input_method_ids.end()) | 793 if (iter != input_method_ids.end()) |
799 ++iter; | 794 ++iter; |
800 if (iter == input_method_ids.end()) | 795 if (iter == input_method_ids.end()) |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 if (keyboard_controller) | 1324 if (keyboard_controller) |
1330 keyboard_controller->Reload(); | 1325 keyboard_controller->Reload(); |
1331 } | 1326 } |
1332 | 1327 |
1333 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { | 1328 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { |
1334 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); | 1329 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); |
1335 } | 1330 } |
1336 | 1331 |
1337 } // namespace input_method | 1332 } // namespace input_method |
1338 } // namespace chromeos | 1333 } // namespace chromeos |
OLD | NEW |