Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(918)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 11235023: Redesign: Remove TsfEventRouter interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@ominifix
Patch Set: fix nit Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | ui/base/ime/win/tsf_event_router.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/views/omnibox/omnibox_view_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 font_(parent_view->font()), 473 font_(parent_view->font()),
474 possible_drag_(false), 474 possible_drag_(false),
475 in_drag_(false), 475 in_drag_(false),
476 initiated_drag_(false), 476 initiated_drag_(false),
477 drop_highlight_position_(-1), 477 drop_highlight_position_(-1),
478 ime_candidate_window_open_(false), 478 ime_candidate_window_open_(false),
479 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( 479 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor(
480 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()), 480 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()),
481 ToolbarModel::NONE, LocationBarView::BACKGROUND))), 481 ToolbarModel::NONE, LocationBarView::BACKGROUND))),
482 security_level_(ToolbarModel::NONE), 482 security_level_(ToolbarModel::NONE),
483 text_object_model_(NULL) { 483 text_object_model_(NULL),
484 ALLOW_THIS_IN_INITIALIZER_LIST(
485 tsf_event_router_(base::win::IsTsfAwareRequired() ?
486 new ui::TsfEventRouter(this) : NULL)) {
484 if (!loaded_library_module_) 487 if (!loaded_library_module_)
485 loaded_library_module_ = LoadLibrary(kRichEditDLLName); 488 loaded_library_module_ = LoadLibrary(kRichEditDLLName);
486 489
487 saved_selection_for_focus_change_.cpMin = -1; 490 saved_selection_for_focus_change_.cpMin = -1;
488 491
489 g_paint_patcher.Pointer()->RefPatch(); 492 g_paint_patcher.Pointer()->RefPatch();
490 493
491 Create(location_bar->GetWidget()->GetNativeView(), 0, 0, 0, 494 Create(location_bar->GetWidget()->GetNativeView(), 0, 0, 0,
492 l10n_util::GetExtendedStyles()); 495 l10n_util::GetExtendedStyles());
493 SetReadOnly(popup_window_mode_); 496 SetReadOnly(popup_window_mode_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 // Non-read-only edit controls have a drop target. Revoke it so that we can 537 // Non-read-only edit controls have a drop target. Revoke it so that we can
535 // install our own. Revoking automatically deletes the existing one. 538 // install our own. Revoking automatically deletes the existing one.
536 HRESULT hr = RevokeDragDrop(m_hWnd); 539 HRESULT hr = RevokeDragDrop(m_hWnd);
537 DCHECK_EQ(S_OK, hr); 540 DCHECK_EQ(S_OK, hr);
538 541
539 // Register our drop target. The scoped_refptr here will delete the drop 542 // Register our drop target. The scoped_refptr here will delete the drop
540 // target if it fails to register itself correctly on |m_hWnd|. Otherwise, 543 // target if it fails to register itself correctly on |m_hWnd|. Otherwise,
541 // the edit control will invoke RevokeDragDrop when it's being destroyed, so 544 // the edit control will invoke RevokeDragDrop when it's being destroyed, so
542 // we don't have to do so. 545 // we don't have to do so.
543 scoped_refptr<EditDropTarget> drop_target(new EditDropTarget(this)); 546 scoped_refptr<EditDropTarget> drop_target(new EditDropTarget(this));
544
545 if (base::win::IsTsfAwareRequired())
546 tsf_event_router_ = ui::TsfEventRouter::Create();
547 } 547 }
548 } 548 }
549 549
550 OmniboxViewWin::~OmniboxViewWin() { 550 OmniboxViewWin::~OmniboxViewWin() {
551 // Explicitly release the text object model now that we're done with it, and 551 // Explicitly release the text object model now that we're done with it, and
552 // before we free the library. If the library gets unloaded before this 552 // before we free the library. If the library gets unloaded before this
553 // released, it becomes garbage. Note that since text_object_model_ is lazy 553 // released, it becomes garbage. Note that since text_object_model_ is lazy
554 // initialized, it may still be null. 554 // initialized, it may still be null.
555 if (text_object_model_) 555 if (text_object_model_)
556 text_object_model_->Release(); 556 text_object_model_->Release();
557 557
558 if (tsf_event_router_)
559 tsf_event_router_->SetManager(NULL, NULL);
560
561 // We balance our reference count and unpatch when the last instance has 558 // We balance our reference count and unpatch when the last instance has
562 // been destroyed. This prevents us from relying on the AtExit or static 559 // been destroyed. This prevents us from relying on the AtExit or static
563 // destructor sequence to do our unpatching, which is generally fragile. 560 // destructor sequence to do our unpatching, which is generally fragile.
564 g_paint_patcher.Pointer()->DerefPatch(); 561 g_paint_patcher.Pointer()->DerefPatch();
565 } 562 }
566 563
567 views::View* OmniboxViewWin::parent_view() const { 564 views::View* OmniboxViewWin::parent_view() const {
568 return parent_view_; 565 return parent_view_;
569 } 566 }
570 567
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 // 1615 //
1619 // Crazy hack: If we just do PlaceCaretAt(0), and the beginning of the text is 1616 // Crazy hack: If we just do PlaceCaretAt(0), and the beginning of the text is
1620 // currently scrolled out of view, we can wind up with a blinking cursor in 1617 // currently scrolled out of view, we can wind up with a blinking cursor in
1621 // the toolbar at the current X coordinate of the beginning of the text. By 1618 // the toolbar at the current X coordinate of the beginning of the text. By
1622 // first doing a reverse-select-all to scroll the beginning of the text into 1619 // first doing a reverse-select-all to scroll the beginning of the text into
1623 // view, we work around this CRichEditCtrl bug. 1620 // view, we work around this CRichEditCtrl bug.
1624 SelectAll(true); 1621 SelectAll(true);
1625 PlaceCaretAt(0); 1622 PlaceCaretAt(0);
1626 1623
1627 if (tsf_event_router_) 1624 if (tsf_event_router_)
1628 tsf_event_router_->SetManager(NULL, NULL); 1625 tsf_event_router_->SetManager(NULL);
1629 } 1626 }
1630 1627
1631 void OmniboxViewWin::OnLButtonDblClk(UINT keys, const CPoint& point) { 1628 void OmniboxViewWin::OnLButtonDblClk(UINT keys, const CPoint& point) {
1632 // Save the double click info for later triple-click detection. 1629 // Save the double click info for later triple-click detection.
1633 tracking_double_click_ = true; 1630 tracking_double_click_ = true;
1634 double_click_point_ = point; 1631 double_click_point_ = point;
1635 double_click_time_ = GetCurrentMessage()->time; 1632 double_click_time_ = GetCurrentMessage()->time;
1636 possible_drag_ = false; 1633 possible_drag_ = false;
1637 1634
1638 // Modifying the selection counts as accepting any inline autocompletion, so 1635 // Modifying the selection counts as accepting any inline autocompletion, so
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 saved_selection_for_focus_change_.cpMin = -1; 1950 saved_selection_for_focus_change_.cpMin = -1;
1954 } 1951 }
1955 1952
1956 if (!tsf_event_router_) { 1953 if (!tsf_event_router_) {
1957 SetMsgHandled(false); 1954 SetMsgHandled(false);
1958 } else { 1955 } else {
1959 DefWindowProc(); 1956 DefWindowProc();
1960 // Document manager created by RichEdit can be obtained only after 1957 // Document manager created by RichEdit can be obtained only after
1961 // WM_SETFOCUS event is handled. 1958 // WM_SETFOCUS event is handled.
1962 tsf_event_router_->SetManager( 1959 tsf_event_router_->SetManager(
1963 ui::TsfBridge::GetInstance()->GetThreadManager(), 1960 ui::TsfBridge::GetInstance()->GetThreadManager());
1964 this);
1965 SetMsgHandled(true); 1961 SetMsgHandled(true);
1966 } 1962 }
1967 } 1963 }
1968 1964
1969 LRESULT OmniboxViewWin::OnSetText(const wchar_t* text) { 1965 LRESULT OmniboxViewWin::OnSetText(const wchar_t* text) {
1970 // Ignore all IME messages while we process this WM_SETTEXT message. 1966 // Ignore all IME messages while we process this WM_SETTEXT message.
1971 // When SetWindowText() is called while an IME is composing text, the IME 1967 // When SetWindowText() is called while an IME is composing text, the IME
1972 // calls SendMessage() to send a WM_IME_COMPOSITION message. When we receive 1968 // calls SendMessage() to send a WM_IME_COMPOSITION message. When we receive
1973 // this WM_IME_COMPOSITION message, we update the omnibox and may call 1969 // this WM_IME_COMPOSITION message, we update the omnibox and may call
1974 // SetWindowText() again. To stop this recursive message-handler call, we 1970 // SetWindowText() again. To stop this recursive message-handler call, we
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2752 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2757 } 2753 }
2758 2754
2759 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2755 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2760 // Use font_.GetStringWidth() instead of 2756 // Use font_.GetStringWidth() instead of
2761 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2757 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2762 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2758 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2763 // PosFromChar(i) might return 0 when i is greater than 1. 2759 // PosFromChar(i) might return 0 when i is greater than 1.
2764 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2760 return font_.GetStringWidth(text) + GetHorizontalMargin();
2765 } 2761 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | ui/base/ime/win/tsf_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698