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

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

Issue 15959004: Fix Incognito input method handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> // std::find 7 #include <algorithm> // std::find
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 const std::string& input_method_id) { 277 const std::string& input_method_id) {
278 ChangeInputMethodInternal(input_method_id, false); 278 ChangeInputMethodInternal(input_method_id, false);
279 } 279 }
280 280
281 bool InputMethodManagerImpl::ChangeInputMethodInternal( 281 bool InputMethodManagerImpl::ChangeInputMethodInternal(
282 const std::string& input_method_id, 282 const std::string& input_method_id,
283 bool show_message) { 283 bool show_message) {
284 if (state_ == STATE_TERMINATING) 284 if (state_ == STATE_TERMINATING)
285 return false; 285 return false;
286 286
287 if (!component_extension_ime_manager_->IsInitialized() ||
288 (!InputMethodUtil::IsKeyboardLayout(input_method_id) &&
289 !IsIBusConnectionAlive())) {
290 // We can't change input method before the initialization of component
291 // extension ime manager or before connection to ibus-daemon is not
292 // established. ChangeInputMethod will be called with
293 // |pending_input_method_| when the both initialization is done.
294 pending_input_method_ = input_method_id;
295 return false;
296 }
297
298 std::string input_method_id_to_switch = input_method_id; 287 std::string input_method_id_to_switch = input_method_id;
299 288
300 // Sanity check. 289 // Sanity check.
301 if (!InputMethodIsActivated(input_method_id)) { 290 if (!InputMethodIsActivated(input_method_id)) {
302 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); 291 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods());
303 DCHECK(!input_methods->empty()); 292 DCHECK(!input_methods->empty());
304 input_method_id_to_switch = input_methods->at(0).id(); 293 input_method_id_to_switch = input_methods->at(0).id();
305 if (!input_method_id.empty()) { 294 if (!input_method_id.empty()) {
306 DVLOG(1) << "Can't change the current input method to " 295 DVLOG(1) << "Can't change the current input method to "
307 << input_method_id << " since the engine is not enabled. " 296 << input_method_id << " since the engine is not enabled. "
308 << "Switch to " << input_method_id_to_switch << " instead."; 297 << "Switch to " << input_method_id_to_switch << " instead.";
309 } 298 }
310 } 299 }
311 300
301 if (!component_extension_ime_manager_->IsInitialized() ||
302 (!InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) &&
303 !IsIBusConnectionAlive())) {
304 // We can't change input method before the initialization of component
305 // extension ime manager or before connection to ibus-daemon is not
306 // established. ChangeInputMethod will be called with
307 // |pending_input_method_| when the both initialization is done.
308 pending_input_method_ = input_method_id_to_switch;
309 return false;
310 }
311
312 IBusInputContextClient* input_context = 312 IBusInputContextClient* input_context =
313 chromeos::DBusThreadManager::Get()->GetIBusInputContextClient(); 313 chromeos::DBusThreadManager::Get()->GetIBusInputContextClient();
314 const std::string current_input_method_id = current_input_method_.id(); 314 const std::string current_input_method_id = current_input_method_.id();
315 IBusClient* client = DBusThreadManager::Get()->GetIBusClient(); 315 IBusClient* client = DBusThreadManager::Get()->GetIBusClient();
316 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { 316 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) {
317 FOR_EACH_OBSERVER(InputMethodManager::Observer, 317 FOR_EACH_OBSERVER(InputMethodManager::Observer,
318 observers_, 318 observers_,
319 InputMethodPropertyChanged(this)); 319 InputMethodPropertyChanged(this));
320 // Hack for fixing http://crosbug.com/p/12798 320 // Hack for fixing http://crosbug.com/p/12798
321 // We should notify IME switching to ibus-daemon, otherwise 321 // We should notify IME switching to ibus-daemon, otherwise
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 else 865 else
866 DVLOG(1) << "Failed to initialize the candidate window controller"; 866 DVLOG(1) << "Failed to initialize the candidate window controller";
867 } 867 }
868 868
869 bool InputMethodManagerImpl::IsIBusConnectionAlive() { 869 bool InputMethodManagerImpl::IsIBusConnectionAlive() {
870 return DBusThreadManager::Get() && DBusThreadManager::Get()->GetIBusClient(); 870 return DBusThreadManager::Get() && DBusThreadManager::Get()->GetIBusClient();
871 } 871 }
872 872
873 } // namespace input_method 873 } // namespace input_method
874 } // namespace chromeos 874 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698