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