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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_
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"
12 class AutofillPopupController
;
20 // Views toolkit implementation for AutofillPopupView.
21 class AutofillPopupViewViews
: public AutofillPopupView
,
22 public views::WidgetDelegateView
,
23 public views::WidgetObserver
{
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
);
32 virtual ~AutofillPopupViewViews();
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
;
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
;
49 // views::WidgetObserver implementation.
50 virtual void OnWidgetBoundsChanged(views::Widget
* widget
,
51 const gfx::Rect
& new_bounds
) OVERRIDE
;
53 // Hide the popup (Since either Hide or ~AutofillPopupViewViews can need to
54 // hide the popup, the actually hiding code must be placed here).
57 // Draw the given autofill entry in |entry_rect|.
58 void DrawAutofillEntry(gfx::Canvas
* canvas
,
60 const gfx::Rect
& entry_rect
);
62 AutofillPopupController
* controller_
; // Weak reference.
64 // The widget that |this| observes. Weak reference.
65 views::Widget
* observing_widget_
;
67 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewViews
);
70 } // namespace autofill
72 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_VIEW_VIEWS_H_