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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_ 6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_ 7 8 #include "chrome/browser/ui/autofill/autofill_popup_view.h" 9 #include "ui/views/widget/widget_delegate.h" 10 #include "ui/views/widget/widget_observer.h" 11 12 class AutofillPopupController; 13 14 namespace content { 15 class WebContents; 16 } 17 18 namespace autofill { 19 20 // Views toolkit implementation for AutofillPopupView. 21 class AutofillPopupViewViews : public AutofillPopupView, 22 public views::WidgetDelegateView, 23 public views::WidgetObserver { 24 public: 25 // The observing widget should be the top level widget for the native 26 // view, which we need to listen to for several signals that indicate the 27 // popup should be closed. 28 AutofillPopupViewViews(AutofillPopupController* controller, 29 views::Widget* observing_widget); 30 31 private: 32 virtual ~AutofillPopupViewViews(); 33 34 // AutofillPopupView implementation. 35 virtual void Show() OVERRIDE; 36 virtual void Hide() OVERRIDE; 37 virtual void InvalidateRow(size_t row) OVERRIDE; 38 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; 39 40 // views:Views implementation. 41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 42 virtual void OnMouseCaptureLost() OVERRIDE; 43 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; 44 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 45 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; 46 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 47 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; 48 49 // views::WidgetObserver implementation. 50 virtual void OnWidgetBoundsChanged(views::Widget* widget, 51 const gfx::Rect& new_bounds) OVERRIDE; 52 53 // Hide the popup (Since either Hide or ~AutofillPopupViewViews can need to 54 // hide the popup, the actually hiding code must be placed here). 55 void HideInternal(); 56 57 // Draw the given autofill entry in |entry_rect|. 58 void DrawAutofillEntry(gfx::Canvas* canvas, 59 int index, 60 const gfx::Rect& entry_rect); 61 62 AutofillPopupController* controller_; // Weak reference. 63 64 // The widget that |this| observes. Weak reference. 65 views::Widget* observing_widget_; 66 67 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewViews); 68 }; 69 70 } // namespace autofill 71 72 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_ 73