| 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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 engine->PropertyActivate(key); | 413 engine->PropertyActivate(key); |
| 414 return; | 414 return; |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 DVLOG(1) << "ActivateInputMethodProperty: unknown key: " << key; | 418 DVLOG(1) << "ActivateInputMethodProperty: unknown key: " << key; |
| 419 } | 419 } |
| 420 | 420 |
| 421 void InputMethodManagerImpl::AddInputMethodExtension( | 421 void InputMethodManagerImpl::AddInputMethodExtension( |
| 422 const std::string& id, | 422 const std::string& id, |
| 423 const std::string& name, | |
| 424 const std::vector<std::string>& layouts, | |
| 425 const std::vector<std::string>& languages, | |
| 426 const GURL& options_url, | |
| 427 const GURL& inputview_url, | |
| 428 InputMethodEngineInterface* engine) { | 423 InputMethodEngineInterface* engine) { |
| 429 if (state_ == STATE_TERMINATING) | 424 if (state_ == STATE_TERMINATING) |
| 430 return; | 425 return; |
| 431 | 426 |
| 432 if (!extension_ime_util::IsExtensionIME(id) && | 427 if (!extension_ime_util::IsExtensionIME(id) && |
| 433 !extension_ime_util::IsComponentExtensionIME(id)) { | 428 !extension_ime_util::IsComponentExtensionIME(id)) { |
| 434 DVLOG(1) << id << " is not a valid extension input method ID."; | 429 DVLOG(1) << id << " is not a valid extension input method ID."; |
| 435 return; | 430 return; |
| 436 } | 431 } |
| 437 | 432 |
| 438 extra_input_methods_[id] = InputMethodDescriptor( | 433 DCHECK(engine); |
| 439 id, name, layouts, languages, false, options_url, inputview_url); | 434 |
| 435 const InputMethodDescriptor& descriptor = engine->GetDescriptor(); |
| 436 extra_input_methods_[id] = descriptor; |
| 440 if (Contains(enabled_extension_imes_, id) && | 437 if (Contains(enabled_extension_imes_, id) && |
| 441 !extension_ime_util::IsComponentExtensionIME(id)) { | 438 !extension_ime_util::IsComponentExtensionIME(id)) { |
| 442 if (!Contains(active_input_method_ids_, id)) { | 439 if (!Contains(active_input_method_ids_, id)) { |
| 443 active_input_method_ids_.push_back(id); | 440 active_input_method_ids_.push_back(id); |
| 444 } else { | 441 } else { |
| 445 DVLOG(1) << "AddInputMethodExtension: alread added: " | 442 DVLOG(1) << "AddInputMethodExtension: alread added: " |
| 446 << id << ", " << name; | 443 << id << ", " << descriptor.name(); |
| 447 // Call Start() anyway, just in case. | 444 // Call Start() anyway, just in case. |
| 448 } | 445 } |
| 449 | 446 |
| 450 // Ensure that the input method daemon is running. | 447 // Ensure that the input method daemon is running. |
| 451 MaybeInitializeCandidateWindowController(); | 448 MaybeInitializeCandidateWindowController(); |
| 452 } | 449 } |
| 453 | 450 |
| 454 // TODO(komatsu): Engine should not be NULL even in unittests. | 451 IBusBridge::Get()->SetEngineHandler(id, engine); |
| 455 if (engine) | |
| 456 IBusBridge::Get()->SetEngineHandler(id, engine); | |
| 457 } | 452 } |
| 458 | 453 |
| 459 void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { | 454 void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { |
| 460 if (!extension_ime_util::IsExtensionIME(id)) | 455 if (!extension_ime_util::IsExtensionIME(id)) |
| 461 DVLOG(1) << id << " is not a valid extension input method ID."; | 456 DVLOG(1) << id << " is not a valid extension input method ID."; |
| 462 | 457 |
| 463 std::vector<std::string>::iterator i = std::find( | 458 std::vector<std::string>::iterator i = std::find( |
| 464 active_input_method_ids_.begin(), active_input_method_ids_.end(), id); | 459 active_input_method_ids_.begin(), active_input_method_ids_.end(), id); |
| 465 if (i != active_input_method_ids_.end()) | 460 if (i != active_input_method_ids_.end()) |
| 466 active_input_method_ids_.erase(i); | 461 active_input_method_ids_.erase(i); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 if (candidate_window_controller_.get()) | 815 if (candidate_window_controller_.get()) |
| 821 return; | 816 return; |
| 822 | 817 |
| 823 candidate_window_controller_.reset( | 818 candidate_window_controller_.reset( |
| 824 CandidateWindowController::CreateCandidateWindowController()); | 819 CandidateWindowController::CreateCandidateWindowController()); |
| 825 candidate_window_controller_->AddObserver(this); | 820 candidate_window_controller_->AddObserver(this); |
| 826 } | 821 } |
| 827 | 822 |
| 828 } // namespace input_method | 823 } // namespace input_method |
| 829 } // namespace chromeos | 824 } // namespace chromeos |
| OLD | NEW |