blob: 30e4beaa73a8c0bcd33517934258ac8845444b6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
#include "ui/views/focus/widget_focus_manager.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_observer.h"
namespace content {
class WebContents;
}
namespace gfx {
class Point;
}
namespace autofill {
// Class that deals with the event handling for Autofill-style popups. This
// class should only be instantiated by sub-classes.
class AutofillPopupBaseView : public views::WidgetDelegateView,
public views::WidgetFocusChangeListener,
public views::WidgetObserver {
public:
static const SkColor kBorderColor;
static const SkColor kHoveredBackgroundColor;
static const SkColor kItemTextColor;
static const SkColor kPopupBackground;
static const SkColor kValueTextColor;
static const SkColor kWarningTextColor;
protected:
explicit AutofillPopupBaseView(AutofillPopupViewDelegate* delegate,
views::Widget* parent_widget);
~AutofillPopupBaseView() override;
// Show this popup. Idempotent.
void DoShow();
// Hide the widget and delete |this|.
void DoHide();
// Update size of popup and paint.
void DoUpdateBoundsAndRedrawPopup();
private:
friend class AutofillPopupBaseViewTest;
// views::Views implementation.
void OnMouseCaptureLost() override;
bool OnMouseDragged(const ui::MouseEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override;
void OnMouseMoved(const ui::MouseEvent& event) override;
bool OnMousePressed(const ui::MouseEvent& event) override;
void OnMouseReleased(const ui::MouseEvent& event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
// views::WidgetFocusChangeListener implementation.
void OnNativeFocusChanged(gfx::NativeView focused_now) override;
// views::WidgetObserver implementation.
void OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) override;
// Stop observing the widget.
void RemoveObserver();
void SetSelection(const gfx::Point& point);
void AcceptSelection(const gfx::Point& point);
void ClearSelection();
// Hide the controller of this view. This assumes that doing so will
// eventually hide this view in the process.
void HideController();
// Must return the container view for this popup.
gfx::NativeView container_view();
// Controller for this popup. Weak reference.
AutofillPopupViewDelegate* delegate_;
// The widget of the window that triggered this popup. Weak reference.
views::Widget* parent_widget_;
// The time when the popup was shown.
base::Time show_time_;
base::WeakPtrFactory<AutofillPopupBaseView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupBaseView);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_
|