Chromium Code Reviews| 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 <algorithm> // std::find | 7 #include <algorithm> // std::find |
| 8 | 8 |
| 9 #include "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
| 10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 IMEBridge::Get()->GetCurrentEngineHandler(); | 426 IMEBridge::Get()->GetCurrentEngineHandler(); |
| 427 if (engine) | 427 if (engine) |
| 428 engine->PropertyActivate(key); | 428 engine->PropertyActivate(key); |
| 429 return; | 429 return; |
| 430 } | 430 } |
| 431 | 431 |
| 432 DVLOG(1) << "ActivateInputMethodMenuItem: unknown key: " << key; | 432 DVLOG(1) << "ActivateInputMethodMenuItem: unknown key: " << key; |
| 433 } | 433 } |
| 434 | 434 |
| 435 void InputMethodManagerImpl::AddInputMethodExtension( | 435 void InputMethodManagerImpl::AddInputMethodExtension( |
| 436 Profile* profile, | |
| 436 const std::string& id, | 437 const std::string& id, |
| 437 InputMethodEngineInterface* engine) { | 438 InputMethodEngineInterface* engine) { |
| 438 if (state_ == STATE_TERMINATING) | 439 if (state_ == STATE_TERMINATING) |
| 439 return; | 440 return; |
| 440 | 441 |
| 441 DCHECK(engine); | 442 DCHECK(engine); |
| 442 | 443 |
| 443 profile_engine_map_[GetProfile()][id] = engine; | 444 profile_engine_map_[profile][id] = engine; |
| 444 | 445 |
| 445 if (id == current_input_method_.id()) { | 446 if (id == current_input_method_.id()) { |
| 446 IMEBridge::Get()->SetCurrentEngineHandler(engine); | 447 IMEBridge::Get()->SetCurrentEngineHandler(engine); |
| 447 engine->Enable(); | 448 engine->Enable(); |
| 448 } | 449 } |
| 449 | 450 |
| 450 if (extension_ime_util::IsComponentExtensionIME(id)) | 451 if (extension_ime_util::IsComponentExtensionIME(id)) |
| 451 return; | 452 return; |
| 452 | 453 |
| 453 CHECK(extension_ime_util::IsExtensionIME(id)) | 454 CHECK(extension_ime_util::IsExtensionIME(id)) |
| 454 << id << "is not a valid extension input method ID"; | 455 << id << "is not a valid extension input method ID"; |
| 455 | 456 |
| 456 const InputMethodDescriptor& descriptor = engine->GetDescriptor(); | 457 const InputMethodDescriptor& descriptor = engine->GetDescriptor(); |
| 457 extra_input_methods_[id] = descriptor; | 458 extra_input_methods_[id] = descriptor; |
| 458 | 459 |
| 459 if (Contains(enabled_extension_imes_, id)) { | 460 if (Contains(enabled_extension_imes_, id)) { |
| 460 if (!Contains(active_input_method_ids_, id)) { | 461 if (!Contains(active_input_method_ids_, id)) { |
| 461 active_input_method_ids_.push_back(id); | 462 active_input_method_ids_.push_back(id); |
| 462 } else { | 463 } else { |
| 463 DVLOG(1) << "AddInputMethodExtension: alread added: " | 464 DVLOG(1) << "AddInputMethodExtension: alread added: " |
| 464 << id << ", " << descriptor.name(); | 465 << id << ", " << descriptor.name(); |
| 465 } | 466 } |
| 466 | 467 |
| 467 // Ensure that the input method daemon is running. | 468 // Ensure that the input method daemon is running. |
| 468 MaybeInitializeCandidateWindowController(); | 469 MaybeInitializeCandidateWindowController(); |
| 469 } | 470 } |
| 470 } | 471 } |
| 471 | 472 |
| 472 void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { | 473 void InputMethodManagerImpl::RemoveInputMethodExtension(Profile* profile, |
| 474 const std::string& id) { | |
| 473 if (!extension_ime_util::IsExtensionIME(id)) | 475 if (!extension_ime_util::IsExtensionIME(id)) |
| 474 DVLOG(1) << id << " is not a valid extension input method ID."; | 476 DVLOG(1) << id << " is not a valid extension input method ID."; |
| 475 | 477 |
| 476 std::vector<std::string>::iterator i = std::find( | 478 std::vector<std::string>::iterator i = std::find( |
| 477 active_input_method_ids_.begin(), active_input_method_ids_.end(), id); | 479 active_input_method_ids_.begin(), active_input_method_ids_.end(), id); |
| 478 if (i != active_input_method_ids_.end()) | 480 if (i != active_input_method_ids_.end()) |
| 479 active_input_method_ids_.erase(i); | 481 active_input_method_ids_.erase(i); |
| 480 extra_input_methods_.erase(id); | 482 extra_input_methods_.erase(id); |
| 481 | 483 |
| 482 EngineMap& engine_map = profile_engine_map_[GetProfile()]; | 484 EngineMap& engine_map = profile_engine_map_[profile]; |
| 483 if (IMEBridge::Get()->GetCurrentEngineHandler() == engine_map[id]) | 485 if (IMEBridge::Get()->GetCurrentEngineHandler() == engine_map[id]) |
| 484 IMEBridge::Get()->SetCurrentEngineHandler(NULL); | 486 IMEBridge::Get()->SetCurrentEngineHandler(NULL); |
| 485 engine_map.erase(id); | 487 engine_map.erase(id); |
| 486 | 488 |
| 487 // No need to switch input method when terminating. | 489 // No need to switch input method when terminating. |
| 488 if (state_ != STATE_TERMINATING) { | 490 if (state_ != STATE_TERMINATING) { |
| 489 // If |current_input_method| is no longer in |active_input_method_ids_|, | 491 // If |current_input_method| is no longer in |active_input_method_ids_|, |
| 490 // switch to the first one in |active_input_method_ids_|. | 492 // switch to the first one in |active_input_method_ids_|. |
| 491 ChangeInputMethod(current_input_method_.id()); | 493 ChangeInputMethod(current_input_method_.id()); |
| 492 } | 494 } |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 | 860 |
| 859 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { | 861 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { |
| 860 if (candidate_window_controller_.get()) | 862 if (candidate_window_controller_.get()) |
| 861 return; | 863 return; |
| 862 | 864 |
| 863 candidate_window_controller_.reset( | 865 candidate_window_controller_.reset( |
| 864 CandidateWindowController::CreateCandidateWindowController()); | 866 CandidateWindowController::CreateCandidateWindowController()); |
| 865 candidate_window_controller_->AddObserver(this); | 867 candidate_window_controller_->AddObserver(this); |
| 866 } | 868 } |
| 867 | 869 |
| 868 Profile* InputMethodManagerImpl::GetProfile() const { | 870 Profile* InputMethodManagerImpl::GetProfile() const { |
|
Nikita (slow)
2014/08/04 12:51:39
This method is a potential source of similar bugs.
Alexander Alekseev
2014/08/04 16:24:12
Done.
| |
| 869 return ProfileManager::GetActiveUserProfile(); | 871 return ProfileManager::GetActiveUserProfile(); |
| 870 } | 872 } |
| 871 | 873 |
| 872 } // namespace input_method | 874 } // namespace input_method |
| 873 } // namespace chromeos | 875 } // namespace chromeos |
| OLD | NEW |