Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / autofill / autofill_popup_base_view.h
blobb37b465d713fff209340710563179bf1fba59b91
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"
14 namespace content {
15 class WebContents;
18 namespace gfx {
19 class Point;
22 namespace views {
23 class FocusManager;
26 namespace autofill {
28 // Class that deals with the event handling for Autofill-style popups. This
29 // class should only be instantiated by sub-classes.
30 class AutofillPopupBaseView : public views::WidgetDelegateView,
31 public views::WidgetFocusChangeListener {
32 public:
33 static const SkColor kBorderColor;
34 static const SkColor kHoveredBackgroundColor;
35 static const SkColor kItemTextColor;
36 static const SkColor kPopupBackground;
37 static const SkColor kValueTextColor;
38 static const SkColor kWarningTextColor;
40 protected:
41 explicit AutofillPopupBaseView(AutofillPopupViewDelegate* delegate,
42 views::FocusManager* focus_manager);
43 ~AutofillPopupBaseView() override;
45 // Show this popup. Idempotent.
46 void DoShow();
48 // Hide the widget and delete |this|.
49 void DoHide();
51 // Update size of popup and paint.
52 void DoUpdateBoundsAndRedrawPopup();
54 private:
55 friend class AutofillPopupBaseViewTest;
57 // views::Views implementation.
58 void OnMouseCaptureLost() override;
59 bool OnMouseDragged(const ui::MouseEvent& event) override;
60 void OnMouseExited(const ui::MouseEvent& event) override;
61 void OnMouseMoved(const ui::MouseEvent& event) override;
62 bool OnMousePressed(const ui::MouseEvent& event) override;
63 void OnMouseReleased(const ui::MouseEvent& event) override;
64 void OnGestureEvent(ui::GestureEvent* event) override;
65 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
67 // views::WidgetFocusChangeListener implementation.
68 void OnNativeFocusChanged(gfx::NativeView focused_now) override;
70 // Stop observing accelerators and focus changes.
71 void RemoveObserver();
73 void SetSelection(const gfx::Point& point);
74 void AcceptSelection(const gfx::Point& point);
75 void ClearSelection();
77 // Hide the controller of this view. This assumes that doing so will
78 // eventually hide this view in the process.
79 void HideController();
81 // Must return the container view for this popup.
82 gfx::NativeView container_view();
84 // Controller for this popup. Weak reference.
85 AutofillPopupViewDelegate* delegate_;
87 // The focus manager that |this| observes. Weak reference.
88 views::FocusManager* focus_manager_;
90 // The time when the popup was shown.
91 base::Time show_time_;
93 base::WeakPtrFactory<AutofillPopupBaseView> weak_ptr_factory_;
95 DISALLOW_COPY_AND_ASSIGN(AutofillPopupBaseView);
98 } // namespace autofill
100 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_POPUP_BASE_VIEW_H_