| 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..74cd12a134a243641455199b219ef4c096438347 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();
|
| }
|
| }
|
|
|
| @@ -549,6 +555,9 @@ OmniboxViewWin::~OmniboxViewWin() {
|
| if (text_object_model_)
|
| text_object_model_->Release();
|
|
|
| + if (tsf_event_router_)
|
| + tsf_event_router_->SetManager(NULL, NULL);
|
| +
|
| // We balance our reference count and unpatch when the last instance has
|
| // been destroyed. This prevents us from relying on the AtExit or static
|
| // destructor sequence to do our unpatching, which is generally fragile.
|
| @@ -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,14 @@ LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) {
|
| DCHECK(touch_mode);
|
| }
|
| SetMsgHandled(FALSE);
|
| +
|
| + // When TSF is enabled, OnTextUpdated() may be called without any previous
|
| + // call that would have indicated the start of an editing session. In order
|
| + // to guarantee we've always called OnBeforePossibleChange() before
|
| + // OnAfterPossibleChange(), we therefore call that here. Note that multiple
|
| + // (i.e. unmatched) calls to this function in a row are safe.
|
| + if (base::win::IsTsfAwareRequired())
|
| + OnBeforePossibleChange();
|
| return 0;
|
| }
|
|
|
| @@ -1582,6 +1624,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 +1954,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) {
|
|
|