Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / views / autofill / autofill_popup_base_view.h
blob30e4beaa73a8c0bcd33517934258ac8845444b6f
1 // Copyright 2014 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_BASE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/time/time.h"
10 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
11 #include "ui/views/focus/widget_focus_manager.h"
12 #include "ui/views/widget/widget_delegate.h"
13 #include "ui/views/widget/widget_observer.h"
15 namespace content {
16 class WebContents;
19 namespace gfx {
20 class Point;
23 namespace autofill {
25 // Class that deals with the event handling for Autofill-style popups. This
26 // class should only be instantiated by sub-classes.
27 class AutofillPopupBaseView : public views::WidgetDelegateView,
28 public views::WidgetFocusChangeListener,
29 public views::WidgetObserver {
30 public:
31 static const SkColor kBorderColor;
32 static const SkColor kHoveredBackgroundColor;
33 static const SkColor kItemTextColor;
34 static const SkColor kPopupBackground;
35 static const SkColor kValueTextColor;
36 static const SkColor kWarningTextColor;
38 protected:
39 explicit AutofillPopupBaseView(AutofillPopupViewDelegate* delegate,
40 views::Widget* parent_widget);
41 ~AutofillPopupBaseView() override;
43 // Show this popup. Idempotent.
44 void DoShow();
46 // Hide the widget and delete |this|.
47 void DoHide();
49 // Update size of popup and paint.
50 void DoUpdateBoundsAndRedrawPopup();
52 private:
53 friend class AutofillPopupBaseViewTest;
55 // views::Views implementation.
56 void OnMouseCaptureLost() override;
57 bool OnMouseDragged(const ui::MouseEvent& event) override;
58 void OnMouseExited(const ui::MouseEvent& event) override;
59 void OnMouseMoved(const ui::MouseEvent& event) override;
60 bool OnMousePressed(const ui::MouseEvent& event) override;
61 void OnMouseReleased(const ui::MouseEvent& event) override;
62 void OnGestureEvent(ui::GestureEvent* event) override;
63 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
65 // views::WidgetFocusChangeListener implementation.
66 void OnNativeFocusChanged(gfx::NativeView focused_now) override;
68 // views::WidgetObserver implementation.
69 void OnWidgetBoundsChanged(views::Widget* widget,
70 const gfx::Rect& new_bounds) override;
72 // Stop observing the widget.
73 void RemoveObserver();
75 void SetSelection(const gfx::Point& point);
76 void AcceptSelection(const gfx::Point& point);
77 void ClearSelection();
79 // Hide the controller of this view. This assumes that doing so will
80 // eventually hide this view in the process.
81 void HideController();
83 // Must return the container view for this popup.
84 gfx::NativeView container_view();
86 // Controller for this popup. Weak reference.
87 AutofillPopupViewDelegate* delegate_;
89 // The widget of the window that triggered this popup. Weak reference.
90 views::Widget* parent_widget_;
92 // The time when the popup was shown.
93 base::Time show_time_;
95 base::WeakPtrFactory<AutofillPopupBaseView> weak_ptr_factory_;
97 DISALLOW_COPY_AND_ASSIGN(AutofillPopupBaseView);
100 } // namespace autofill
102 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_