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

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

Issue 67313006: Delete IBusClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 <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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" 17 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
18 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i mpl.h" 18 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i mpl.h"
19 #include "chrome/browser/chromeos/input_method/input_method_engine_ibus.h" 19 #include "chrome/browser/chromeos/input_method/input_method_engine_ibus.h"
20 #include "chrome/browser/chromeos/language_preferences.h" 20 #include "chrome/browser/chromeos/language_preferences.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/ibus/ibus_client.h"
23 #include "chromeos/ime/component_extension_ime_manager.h" 22 #include "chromeos/ime/component_extension_ime_manager.h"
24 #include "chromeos/ime/extension_ime_util.h" 23 #include "chromeos/ime/extension_ime_util.h"
25 #include "chromeos/ime/input_method_delegate.h" 24 #include "chromeos/ime/input_method_delegate.h"
26 #include "chromeos/ime/xkeyboard.h" 25 #include "chromeos/ime/xkeyboard.h"
27 #include "third_party/icu/source/common/unicode/uloc.h" 26 #include "third_party/icu/source/common/unicode/uloc.h"
28 #include "ui/base/accelerators/accelerator.h" 27 #include "ui/base/accelerators/accelerator.h"
29 28
30 namespace chromeos { 29 namespace chromeos {
31 namespace input_method { 30 namespace input_method {
32 31
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); 288 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods());
290 DCHECK(!input_methods->empty()); 289 DCHECK(!input_methods->empty());
291 input_method_id_to_switch = input_methods->at(0).id(); 290 input_method_id_to_switch = input_methods->at(0).id();
292 if (!input_method_id.empty()) { 291 if (!input_method_id.empty()) {
293 DVLOG(1) << "Can't change the current input method to " 292 DVLOG(1) << "Can't change the current input method to "
294 << input_method_id << " since the engine is not enabled. " 293 << input_method_id << " since the engine is not enabled. "
295 << "Switch to " << input_method_id_to_switch << " instead."; 294 << "Switch to " << input_method_id_to_switch << " instead.";
296 } 295 }
297 } 296 }
298 297
299 if (!component_extension_ime_manager_->IsInitialized() || 298 if (!component_extension_ime_manager_->IsInitialized()) {
300 (!InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && 299 // We can't change input method before the initialization of
301 !IsIBusConnectionAlive())) { 300 // component extension ime manager. ChangeInputMethod will be
302 // We can't change input method before the initialization of component 301 // called with |pending_input_method_| when the initialization is
303 // extension ime manager or before connection to ibus-daemon is not 302 // done.
304 // established. ChangeInputMethod will be called with
305 // |pending_input_method_| when the both initialization is done.
306 pending_input_method_ = input_method_id_to_switch; 303 pending_input_method_ = input_method_id_to_switch;
307 return false; 304 return false;
308 } 305 }
309 306
310 pending_input_method_.clear(); 307 pending_input_method_.clear();
311 IBusEngineHandlerInterface* engine = IBusBridge::Get()->GetEngineHandler(); 308 IBusEngineHandlerInterface* engine = IBusBridge::Get()->GetEngineHandler();
312 const std::string current_input_method_id = current_input_method_.id(); 309 const std::string current_input_method_id = current_input_method_.id();
313 IBusClient* client = DBusThreadManager::Get()->GetIBusClient();
314 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { 310 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) {
315 FOR_EACH_OBSERVER(InputMethodManager::Observer, 311 FOR_EACH_OBSERVER(InputMethodManager::Observer,
316 observers_, 312 observers_,
317 InputMethodPropertyChanged(this)); 313 InputMethodPropertyChanged(this));
318 if (engine) { 314 if (engine) {
319 engine->Disable(); 315 engine->Disable();
320 IBusBridge::Get()->SetEngineHandler(NULL); 316 IBusBridge::Get()->SetEngineHandler(NULL);
321 } 317 }
322 } else { 318 } else {
323 DCHECK(client); 319 // Disable the current engine and enable the next engine.
324 client->SetGlobalEngine(input_method_id_to_switch, 320 IBusEngineHandlerInterface* previous_engine =
Seigo Nonaka 2013/11/12 03:21:45 Can we reuse |engine| for this? Or please move L30
Hiro Komatsu 2013/11/12 04:34:24 Done.
325 base::Bind(&base::DoNothing)); 321 IBusBridge::Get()->GetEngineHandler();
322 if (previous_engine)
323 previous_engine->Disable();
324 IBusBridge::Get()->CreateEngine(input_method_id_to_switch);
Seigo Nonaka 2013/11/12 03:21:45 FYI: CreateEngine is no longer necessary because E
Hiro Komatsu 2013/11/12 04:34:24 ACK. I will try to remove CreateEngine in the fol
325 IBusEngineHandlerInterface* next_engine =
326 IBusBridge::Get()->GetEngineHandler();
327 IBusBridge::Get()->SetEngineHandler(next_engine);
328 if (next_engine)
329 next_engine->Enable();
326 } 330 }
327 331
328 if (current_input_method_id != input_method_id_to_switch) { 332 if (current_input_method_id != input_method_id_to_switch) {
329 // Clear input method properties unconditionally if 333 // Clear input method properties unconditionally if
330 // |input_method_id_to_switch| is not equal to |current_input_method_id|. 334 // |input_method_id_to_switch| is not equal to |current_input_method_id|.
331 // 335 //
332 // When switching to another input method and no text area is focused, 336 // When switching to another input method and no text area is focused,
333 // RegisterProperties signal for the new input method will NOT be sent 337 // RegisterProperties signal for the new input method will NOT be sent
334 // until a text area is focused. Therefore, we have to clear the old input 338 // until a text area is focused. Therefore, we have to clear the old input
335 // method properties here to keep the input method switcher status 339 // method properties here to keep the input method switcher status
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 return; 862 return;
859 863
860 candidate_window_controller_.reset( 864 candidate_window_controller_.reset(
861 CandidateWindowController::CreateCandidateWindowController()); 865 CandidateWindowController::CreateCandidateWindowController());
862 if (candidate_window_controller_->Init()) 866 if (candidate_window_controller_->Init())
863 candidate_window_controller_->AddObserver(this); 867 candidate_window_controller_->AddObserver(this);
864 else 868 else
865 DVLOG(1) << "Failed to initialize the candidate window controller"; 869 DVLOG(1) << "Failed to initialize the candidate window controller";
866 } 870 }
867 871
868 bool InputMethodManagerImpl::IsIBusConnectionAlive() {
869 return DBusThreadManager::Get() && DBusThreadManager::Get()->GetIBusClient();
870 }
871
872 } // namespace input_method 872 } // namespace input_method
873 } // namespace chromeos 873 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698