blob: 72c4162952f6e253b241455f9a44e2aebd570fb6 (
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
|
// 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 "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* observing_widget);
virtual ~AutofillPopupBaseView();
// 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.
virtual void OnMouseCaptureLost() OVERRIDE;
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
// views::WidgetFocusChangeListener implementation.
virtual void OnNativeFocusChange(gfx::NativeView focused_before,
gfx::NativeView focused_now) OVERRIDE;
// views::WidgetObserver implementation.
virtual void OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) OVERRIDE;
// Stop observing the |observing_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 that |this| observes. Weak reference.
views::Widget* observing_widget_;
base::WeakPtrFactory<AutofillPopupBaseView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupBaseView);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_
|