Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.cc

Issue 2274013003: Keeps the opt-in IME menu in lock screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sate menu_activated in StateImpl. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 *first_char = ch; 105 *first_char = ch;
106 return category; 106 return category;
107 } 107 }
108 108
109 } // namespace 109 } // namespace
110 110
111 // ------------------------ InputMethodManagerImpl::StateImpl 111 // ------------------------ InputMethodManagerImpl::StateImpl
112 112
113 InputMethodManagerImpl::StateImpl::StateImpl(InputMethodManagerImpl* manager, 113 InputMethodManagerImpl::StateImpl::StateImpl(InputMethodManagerImpl* manager,
114 Profile* profile) 114 Profile* profile)
115 : profile(profile), manager_(manager) { 115 : profile(profile), manager_(manager), menu_activated(false) {}
116 }
117 116
118 InputMethodManagerImpl::StateImpl::~StateImpl() { 117 InputMethodManagerImpl::StateImpl::~StateImpl() {
119 } 118 }
120 119
121 void InputMethodManagerImpl::StateImpl::InitFrom(const StateImpl& other) { 120 void InputMethodManagerImpl::StateImpl::InitFrom(const StateImpl& other) {
122 previous_input_method = other.previous_input_method; 121 previous_input_method = other.previous_input_method;
123 current_input_method = other.current_input_method; 122 current_input_method = other.current_input_method;
124 123
125 active_input_method_ids = other.active_input_method_ids; 124 active_input_method_ids = other.active_input_method_ids;
126 125
127 pending_input_method_id = other.pending_input_method_id; 126 pending_input_method_id = other.pending_input_method_id;
128 127
129 enabled_extension_imes = other.enabled_extension_imes; 128 enabled_extension_imes = other.enabled_extension_imes;
130 extra_input_methods = other.extra_input_methods; 129 extra_input_methods = other.extra_input_methods;
130 menu_activated = other.menu_activated;
131 } 131 }
132 132
133 bool InputMethodManagerImpl::StateImpl::IsActive() const { 133 bool InputMethodManagerImpl::StateImpl::IsActive() const {
134 return manager_->state_.get() == this; 134 return manager_->state_.get() == this;
135 } 135 }
136 136
137 std::string InputMethodManagerImpl::StateImpl::Dump() const { 137 std::string InputMethodManagerImpl::StateImpl::Dump() const {
138 std::ostringstream os; 138 std::ostringstream os;
139 139
140 os << "################# " 140 os << "################# "
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 849
850 InputMethodManagerImpl::InputMethodManagerImpl( 850 InputMethodManagerImpl::InputMethodManagerImpl(
851 std::unique_ptr<InputMethodDelegate> delegate, 851 std::unique_ptr<InputMethodDelegate> delegate,
852 bool enable_extension_loading) 852 bool enable_extension_loading)
853 : delegate_(std::move(delegate)), 853 : delegate_(std::move(delegate)),
854 ui_session_(STATE_LOGIN_SCREEN), 854 ui_session_(STATE_LOGIN_SCREEN),
855 state_(NULL), 855 state_(NULL),
856 util_(delegate_.get()), 856 util_(delegate_.get()),
857 component_extension_ime_manager_(new ComponentExtensionIMEManager()), 857 component_extension_ime_manager_(new ComponentExtensionIMEManager()),
858 enable_extension_loading_(enable_extension_loading), 858 enable_extension_loading_(enable_extension_loading),
859 is_ime_menu_activated_(false) { 859 menu_activated_(false) {
860 // TODO(mohsen): Revisit using FakeImeKeyboard with mash when InputController 860 // TODO(mohsen): Revisit using FakeImeKeyboard with mash when InputController
861 // work is ready. http://crbug.com/601981 861 // work is ready. http://crbug.com/601981
862 if (base::SysInfo::IsRunningOnChromeOS() && !chrome::IsRunningInMash()) 862 if (base::SysInfo::IsRunningOnChromeOS() && !chrome::IsRunningInMash())
863 keyboard_.reset(ImeKeyboard::Create()); 863 keyboard_.reset(ImeKeyboard::Create());
864 else 864 else
865 keyboard_.reset(new FakeImeKeyboard()); 865 keyboard_.reset(new FakeImeKeyboard());
866 866
867 // Initializes the system IME list. 867 // Initializes the system IME list.
868 std::unique_ptr<ComponentExtensionIMEManagerDelegate> comp_delegate( 868 std::unique_ptr<ComponentExtensionIMEManagerDelegate> comp_delegate(
869 new ComponentExtensionIMEManagerImpl()); 869 new ComponentExtensionIMEManagerImpl());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 920 }
921 921
922 InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() { 922 InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() {
923 return ui_session_; 923 return ui_session_;
924 } 924 }
925 925
926 void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) { 926 void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) {
927 ui_session_ = new_ui_session; 927 ui_session_ = new_ui_session;
928 if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get()) 928 if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get())
929 candidate_window_controller_.reset(); 929 candidate_window_controller_.reset();
930
931 // The expanded IME menu is only supportive with 'normal' screen type. It
932 // should be deactivated when the screen type is not 'normal', and be
933 // re-activated when changing back.
934 if (is_ime_menu_activated_ && ui_session_ != STATE_TERMINATING) {
935 FOR_EACH_OBSERVER(
936 InputMethodManager::ImeMenuObserver, ime_menu_observers_,
937 ImeMenuActivationChanged(ui_session_ == STATE_BROWSER_SCREEN));
938 }
939 } 930 }
940 931
941 void InputMethodManagerImpl::OnUserAddingStarted() { 932 void InputMethodManagerImpl::OnUserAddingStarted() {
942 if (ui_session_ == STATE_BROWSER_SCREEN) 933 if (ui_session_ == STATE_BROWSER_SCREEN)
943 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); 934 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN);
944 } 935 }
945 936
946 void InputMethodManagerImpl::OnUserAddingFinished() { 937 void InputMethodManagerImpl::OnUserAddingFinished() {
947 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) 938 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN)
948 SetUISessionState(STATE_BROWSER_SCREEN); 939 SetUISessionState(STATE_BROWSER_SCREEN);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 } 1169 }
1179 1170
1180 void InputMethodManagerImpl::CandidateWindowClosed() { 1171 void InputMethodManagerImpl::CandidateWindowClosed() {
1181 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, 1172 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver,
1182 candidate_window_observers_, 1173 candidate_window_observers_,
1183 CandidateWindowClosed(this)); 1174 CandidateWindowClosed(this));
1184 } 1175 }
1185 1176
1186 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { 1177 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) {
1187 // Saves the state that whether the expanded IME menu has been activated by 1178 // Saves the state that whether the expanded IME menu has been activated by
1188 // users. This method is only called when the preference is changing. 1179 // users. This method is only called when the preference is changing or the
1189 is_ime_menu_activated_ = is_active; 1180 // active user changed.
Shu Chen 2016/08/29 08:20:08 revert this comment change.
Azure Wei 2016/08/29 08:27:47 Done.
1181 menu_activated_ = is_active;
1182 state_->menu_activated = menu_activated_;
1190 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, 1183 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_,
1191 ImeMenuActivationChanged(is_active)); 1184 ImeMenuActivationChanged(menu_activated_));
1192 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", 1185 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged",
1193 is_ime_menu_activated_); 1186 menu_activated_);
Shu Chen 2016/08/29 08:20:08 void InputMethodManagerImpl::ImeMenuActivationChan
Azure Wei 2016/08/29 08:27:47 Done.
1194 } 1187 }
1195 1188
1196 void InputMethodManagerImpl::NotifyImeMenuListChanged() { 1189 void InputMethodManagerImpl::NotifyImeMenuListChanged() {
1197 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, 1190 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_,
1198 ImeMenuListChanged()); 1191 ImeMenuListChanged());
1199 } 1192 }
1200 1193
1201 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { 1194 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() {
1202 if (candidate_window_controller_.get()) 1195 if (candidate_window_controller_.get())
1203 return; 1196 return;
1204 1197
1205 candidate_window_controller_.reset( 1198 candidate_window_controller_.reset(
1206 CandidateWindowController::CreateCandidateWindowController()); 1199 CandidateWindowController::CreateCandidateWindowController());
1207 candidate_window_controller_->AddObserver(this); 1200 candidate_window_controller_->AddObserver(this);
1208 } 1201 }
1209 1202
1210 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( 1203 void InputMethodManagerImpl::NotifyImeMenuItemsChanged(
1211 const std::string& engine_id, 1204 const std::string& engine_id,
1212 const std::vector<InputMethodManager::MenuItem>& items) { 1205 const std::vector<InputMethodManager::MenuItem>& items) {
1213 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, 1206 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_,
1214 ImeMenuItemsChanged(engine_id, items)); 1207 ImeMenuItemsChanged(engine_id, items));
1215 } 1208 }
1216 1209
1210 void InputMethodManagerImpl::MaybeNotifyImeMenuActivationChanged() {
1211 bool is_active = state_->menu_activated;
1212 if (menu_activated_ != is_active) {
1213 ImeMenuActivationChanged(is_active);
1214 }
1215 }
1216
1217 } // namespace input_method 1217 } // namespace input_method
1218 } // namespace chromeos 1218 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698