Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
index 12afb42ee61cf6379b7c3b9cb0e160920835e206..d2e947408b5ed145269789d39dee94f7f5a71278 100644 |
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
@@ -13,6 +13,7 @@ |
#include "base/auto_reset.h" |
#include "base/basictypes.h" |
+#include "base/bind.h" |
#include "base/i18n/rtl.h" |
#include "base/lazy_instance.h" |
#include "base/memory/ref_counted.h" |
@@ -53,6 +54,8 @@ |
#include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
#include "ui/base/events/event.h" |
#include "ui/base/events/event_constants.h" |
+#include "ui/base/ime/win/tsf_bridge.h" |
+#include "ui/base/ime/win/tsf_event_router.h" |
#include "ui/base/keycodes/keyboard_codes.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/l10n/l10n_util_win.h" |
@@ -538,6 +541,9 @@ OmniboxViewWin::OmniboxViewWin(OmniboxEditController* controller, |
// the edit control will invoke RevokeDragDrop when it's being destroyed, so |
// we don't have to do so. |
scoped_refptr<EditDropTarget> drop_target(new EditDropTarget(this)); |
+ |
+ if (base::win::IsTsfAwareRequired()) |
+ tsf_event_router_ = ui::TsfEventRouter::Create(); |
} |
} |
@@ -553,6 +559,9 @@ OmniboxViewWin::~OmniboxViewWin() { |
// been destroyed. This prevents us from relying on the AtExit or static |
// destructor sequence to do our unpatching, which is generally fragile. |
g_paint_patcher.Pointer()->DerefPatch(); |
+ |
+ if (tsf_event_router_) |
Peter Kasting
2012/10/19 18:40:57
Tiny nit: This should probably go above the paint
Seigo Nonaka
2012/10/22 03:11:04
Done.
|
+ tsf_event_router_->SetManager(NULL, NULL); |
} |
views::View* OmniboxViewWin::parent_view() const { |
@@ -913,6 +922,29 @@ bool OmniboxViewWin::OnAfterPossibleChangeInternal(bool force_text_changed) { |
return something_changed; |
} |
+void OmniboxViewWin::OnTextUpdated() { |
+ if (ignore_ime_messages_) |
+ return; |
+ OnAfterPossibleChangeInternal(true); |
+ // Call OnBeforePossibleChange function here to get correct diff in next IME |
+ // update. The Text Services Framework does not provide any notification |
+ // before entering edit session, therefore we don't have good place to call |
+ // OnBeforePossibleChange. |
+ OnBeforePossibleChange(); |
+} |
+ |
+void OmniboxViewWin::OnCandidateWindowCountChanged(size_t window_count) { |
+ ime_candidate_window_open_ = (window_count != 0); |
+ if (ime_candidate_window_open_) { |
+ CloseOmniboxPopup(); |
+ } else if (model()->user_input_in_progress()) { |
+ // UpdatePopup assumes user input is in progress, so only call it if |
+ // that's the case. Otherwise, autocomplete may run on an empty user |
+ // text. |
+ UpdatePopup(); |
+ } |
+} |
+ |
gfx::NativeView OmniboxViewWin::GetNativeView() const { |
return m_hWnd; |
} |
@@ -948,6 +980,8 @@ string16 OmniboxViewWin::GetInstantSuggestion() const { |
} |
bool OmniboxViewWin::IsImeComposing() const { |
+ if (tsf_event_router_) |
+ return tsf_event_router_->IsImeComposing(); |
bool ime_composing = false; |
HIMC context = ImmGetContext(m_hWnd); |
if (context) { |
@@ -1376,6 +1410,15 @@ LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { |
DCHECK(touch_mode); |
} |
SetMsgHandled(FALSE); |
+ |
+ // To ensure OnBeforePossibleChange is called before any |
+ // OnAfterPossibleChange call, we call OnBeforePossibleChange here. In the |
+ // case of a pure TSF environment like on Metro UI, we can't get any chance |
+ // to call OnBeforePossibleChange at the beginning of an edit session, if we |
Peter Kasting
2012/10/19 18:40:57
Nit: Slightly clearer:
// When TSF is enabled,
Seigo Nonaka
2012/10/22 03:11:04
Done.
|
+ // do not call OnBeforePossibleChange here, we would call |
+ // OnAfterPossibleChange on the end of edit session without any |
+ // OnBeforePossibleChange call. |
+ OnBeforePossibleChange(); |
Peter Kasting
2012/10/19 18:40:57
You should only do this when |tsf_event_router_| i
Seigo Nonaka
2012/10/22 03:11:04
Done.
|
return 0; |
} |
@@ -1582,6 +1625,9 @@ void OmniboxViewWin::OnKillFocus(HWND focus_wnd) { |
// view, we work around this CRichEditCtrl bug. |
SelectAll(true); |
PlaceCaretAt(0); |
+ |
+ if (tsf_event_router_) |
+ tsf_event_router_->SetManager(NULL, NULL); |
} |
void OmniboxViewWin::OnLButtonDblClk(UINT keys, const CPoint& point) { |
@@ -1909,7 +1955,17 @@ void OmniboxViewWin::OnSetFocus(HWND focus_wnd) { |
saved_selection_for_focus_change_.cpMin = -1; |
} |
- SetMsgHandled(false); |
+ if (!tsf_event_router_) { |
+ SetMsgHandled(false); |
+ } else { |
+ DefWindowProc(); |
+ // Document manager created by RichEdit can be obtained only after |
+ // WM_SETFOCUS event is handled. |
+ tsf_event_router_->SetManager( |
+ ui::TsfBridge::GetInstance()->GetThreadManager(), |
+ this); |
+ SetMsgHandled(true); |
+ } |
} |
LRESULT OmniboxViewWin::OnSetText(const wchar_t* text) { |