Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| index b89db86fbb9bd2782507aaddfeb76bb2da07a0db..0ff7f1d9b68d6352e32857884fd54a07bf273816 100644 |
| --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| @@ -60,9 +60,13 @@ InputMethodManagerImpl::InputMethodManagerImpl( |
| scoped_ptr<InputMethodDelegate> delegate) |
| : delegate_(delegate.Pass()), |
| state_(STATE_LOGIN_SCREEN), |
| - util_(delegate_.get(), whitelist_.GetSupportedInputMethods()), |
| + util_(delegate_.get()), |
| component_extension_ime_manager_(new ComponentExtensionIMEManager()), |
| weak_ptr_factory_(this) { |
| + if (base::SysInfo::IsRunningOnChromeOS()) |
| + keyboard_.reset(ImeKeyboard::Create()); |
| + else |
| + keyboard_.reset(new FakeImeKeyboard()); |
| } |
| InputMethodManagerImpl::~InputMethodManagerImpl() { |
| @@ -113,8 +117,6 @@ void InputMethodManagerImpl::SetState(State new_state) { |
| scoped_ptr<InputMethodDescriptors> |
| InputMethodManagerImpl::GetSupportedInputMethods() const { |
| - if (!IsXkbComponentExtensionAvailable()) |
| - return whitelist_.GetSupportedInputMethods().Pass(); |
| return scoped_ptr<InputMethodDescriptors>(new InputMethodDescriptors).Pass(); |
| } |
| @@ -325,17 +327,6 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( |
| } |
| } |
| - if (!component_extension_ime_manager_->IsInitialized() && |
| - !InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { |
| - // We can't change input method before the initialization of |
| - // component extension ime manager. ChangeInputMethod will be |
| - // called with |pending_input_method_| when the initialization is |
| - // done. |
| - pending_input_method_ = input_method_id_to_switch; |
| - return false; |
| - } |
| - pending_input_method_.clear(); |
| - |
| // Hide candidate window and info list. |
| if (candidate_window_controller_.get()) |
| candidate_window_controller_->Hide(); |
| @@ -404,41 +395,18 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( |
| return true; |
| } |
| -bool InputMethodManagerImpl::IsXkbComponentExtensionAvailable() const { |
| - if (!component_extension_ime_manager_->IsInitialized()) |
| - return false; |
| - InputMethodDescriptors imes = |
| - component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); |
| - for (size_t i = 0; i < imes.size(); ++i) { |
| - if (StartsWithASCII(extension_ime_util::MaybeGetLegacyXkbId( |
| - imes[i].id()), "xkb:", true)) |
| - return true; |
| - } |
| - return false; |
| -} |
| - |
| void InputMethodManagerImpl::OnComponentExtensionInitialized( |
| scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| component_extension_ime_manager_->Initialize(delegate.Pass()); |
| - InputMethodDescriptors imes = |
| - component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); |
| - // In case of XKB extension is not available (e.g. linux_chromeos), don't |
| - // reset the input methods in InputMethodUtil, Instead append input methods. |
| - if (IsXkbComponentExtensionAvailable()) |
| - util_.ResetInputMethods(imes); |
| - else |
| - util_.AppendInputMethods(imes); |
| - LoadNecessaryComponentExtensions(); |
| + util_.ResetInputMethods( |
| + component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor()); |
| - if (!pending_input_method_.empty()) |
| - ChangeInputMethodInternal(pending_input_method_, false); |
| + LoadNecessaryComponentExtensions(); |
| } |
| void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { |
| - if (!component_extension_ime_manager_->IsInitialized()) |
| - return; |
| // Load component extensions but also update |active_input_method_ids_| as |
| // some component extension IMEs may have been removed from the Chrome OS |
| // image. If specified component extension IME no longer exists, falling back |
| @@ -457,8 +425,6 @@ void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { |
| active_input_method_ids_.push_back(unfiltered_input_method_ids[i]); |
| } |
| } |
| - // TODO(shuchen): move this call in ComponentExtensionIMEManager. |
| - component_extension_ime_manager_->NotifyInitialized(); |
| } |
| void InputMethodManagerImpl::ActivateInputMethodMenuItem( |
| @@ -807,29 +773,11 @@ ComponentExtensionIMEManager* |
| } |
| void InputMethodManagerImpl::InitializeComponentExtension() { |
| - ComponentExtensionIMEManagerImpl* impl = |
| - new ComponentExtensionIMEManagerImpl(); |
| - scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(impl); |
| - impl->InitializeAsync(base::Bind( |
| - &InputMethodManagerImpl::OnComponentExtensionInitialized, |
| - weak_ptr_factory_.GetWeakPtr(), |
| - base::Passed(&delegate))); |
| -} |
| - |
| -void InputMethodManagerImpl::Init(base::SequencedTaskRunner* ui_task_runner) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| - |
| - if (base::SysInfo::IsRunningOnChromeOS()) |
| - keyboard_.reset(ImeKeyboard::Create()); |
| - else |
| - keyboard_.reset(new FakeImeKeyboard()); |
| - |
| - // We can't call impl->Initialize here, because file thread is not available |
| - // at this moment. |
| - ui_task_runner->PostTask( |
| - FROM_HERE, |
| - base::Bind(&InputMethodManagerImpl::InitializeComponentExtension, |
| - weak_ptr_factory_.GetWeakPtr())); |
| + active_input_method_ids_.push_back( |
| + InputMethodUtil::GetFallbackInputMethodDescriptor().id()); |
| + scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate( |
| + new ComponentExtensionIMEManagerImpl()); |
| + OnComponentExtensionInitialized(delegate.Pass()); |
|
nona
2014/07/14 10:02:47
You no longer need to split functions. How about r
Shu Chen
2014/07/14 15:07:21
Done.
|
| } |
| void InputMethodManagerImpl::SetCandidateWindowControllerForTesting( |