| Index: ui/base/ime/input_method_ibus.cc | 
| diff --git a/ui/base/ime/input_method_ibus.cc b/ui/base/ime/input_method_ibus.cc | 
| index 48f31e5910c00be1a6fb4e3e2e40847e12c4d903..d0aea84d46932719c663583c20d791bf38dea22a 100644 | 
| --- a/ui/base/ime/input_method_ibus.cc | 
| +++ b/ui/base/ime/input_method_ibus.cc | 
| @@ -223,8 +223,58 @@ void InputMethodIBus::OnTextInputTypeChanged(const TextInputClient* client) { | 
| } | 
|  | 
| void InputMethodIBus::OnCaretBoundsChanged(const TextInputClient* client) { | 
| -  OnCaretBoundsChangedInternal(client); | 
| -  InputMethodBase::OnCaretBoundsChanged(client); | 
| +  if (!context_focused_ || !IsTextInputClientFocused(client)) | 
| +    return; | 
| + | 
| +  // The current text input type should not be NONE if |context_| is focused. | 
| +  DCHECK(!IsTextInputTypeNone()); | 
| +  const gfx::Rect rect = GetTextInputClient()->GetCaretBounds(); | 
| + | 
| +  gfx::Rect composition_head; | 
| +  if (!GetTextInputClient()->GetCompositionCharacterBounds(0, | 
| +                                                           &composition_head)) { | 
| +    composition_head = rect; | 
| +  } | 
| + | 
| +  chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = | 
| +      chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); | 
| +  if (!candidate_window) | 
| +    return; | 
| +  candidate_window->SetCursorBounds(rect, composition_head); | 
| + | 
| +  gfx::Range text_range; | 
| +  gfx::Range selection_range; | 
| +  string16 surrounding_text; | 
| +  if (!GetTextInputClient()->GetTextRange(&text_range) || | 
| +      !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text) || | 
| +      !GetTextInputClient()->GetSelectionRange(&selection_range)) { | 
| +    previous_surrounding_text_.clear(); | 
| +    previous_selection_range_ = gfx::Range::InvalidRange(); | 
| +    return; | 
| +  } | 
| + | 
| +  if (previous_selection_range_ == selection_range && | 
| +      previous_surrounding_text_ == surrounding_text) | 
| +    return; | 
| + | 
| +  previous_selection_range_ = selection_range; | 
| +  previous_surrounding_text_ = surrounding_text; | 
| + | 
| +  if (!selection_range.IsValid()) { | 
| +    // TODO(nona): Ideally selection_range should not be invalid. | 
| +    // TODO(nona): If javascript changes the focus on page loading, even (0,0) | 
| +    //             can not be obtained. Need investigation. | 
| +    return; | 
| +  } | 
| + | 
| +  // Here SetSurroundingText accepts relative position of |surrounding_text|, so | 
| +  // we have to convert |selection_range| from node coordinates to | 
| +  // |surrounding_text| coordinates. | 
| +  if (!GetEngine()) | 
| +    return; | 
| +  GetEngine()->SetSurroundingText(UTF16ToUTF8(surrounding_text), | 
| +                                  selection_range.start() - text_range.start(), | 
| +                                  selection_range.end() - text_range.start()); | 
| } | 
|  | 
| void InputMethodIBus::CancelComposition(const TextInputClient* client) { | 
| @@ -775,61 +825,4 @@ void InputMethodIBus::ExtractCompositionText( | 
| } | 
| } | 
|  | 
| -void InputMethodIBus::OnCaretBoundsChangedInternal( | 
| -    const TextInputClient* client) { | 
| -  if (!context_focused_ || !IsTextInputClientFocused(client)) | 
| -    return; | 
| - | 
| -  // The current text input type should not be NONE if |context_| is focused. | 
| -  DCHECK(!IsTextInputTypeNone()); | 
| -  const gfx::Rect rect = GetTextInputClient()->GetCaretBounds(); | 
| - | 
| -  gfx::Rect composition_head; | 
| -  if (!GetTextInputClient()->GetCompositionCharacterBounds(0, | 
| -                                                           &composition_head)) { | 
| -    composition_head = rect; | 
| -  } | 
| - | 
| -  chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = | 
| -      chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); | 
| -  if (!candidate_window) | 
| -    return; | 
| -  candidate_window->SetCursorBounds(rect, composition_head); | 
| - | 
| -  gfx::Range text_range; | 
| -  gfx::Range selection_range; | 
| -  string16 surrounding_text; | 
| -  if (!GetTextInputClient()->GetTextRange(&text_range) || | 
| -      !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text) || | 
| -      !GetTextInputClient()->GetSelectionRange(&selection_range)) { | 
| -    previous_surrounding_text_.clear(); | 
| -    previous_selection_range_ = gfx::Range::InvalidRange(); | 
| -    return; | 
| -  } | 
| - | 
| -  if (previous_selection_range_ == selection_range && | 
| -      previous_surrounding_text_ == surrounding_text) | 
| -    return; | 
| - | 
| -  previous_selection_range_ = selection_range; | 
| -  previous_surrounding_text_ = surrounding_text; | 
| - | 
| -  if (!selection_range.IsValid()) { | 
| -    // TODO(nona): Ideally selection_range should not be invalid. | 
| -    // TODO(nona): If javascript changes the focus on page loading, even (0,0) | 
| -    //             can not be obtained. Need investigation. | 
| -    return; | 
| -  } | 
| - | 
| -  // Here SetSurroundingText accepts relative position of |surrounding_text|, so | 
| -  // we have to convert |selection_range| from node coordinates to | 
| -  // |surrounding_text| coordinates. | 
| -  if (!GetEngine()) | 
| -    return; | 
| -  GetEngine()->SetSurroundingText( | 
| -      UTF16ToUTF8(surrounding_text), | 
| -      selection_range.start() - text_range.start(), | 
| -      selection_range.end() - text_range.start()); | 
| -} | 
| - | 
| }  // namespace ui | 
|  |