Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_popup_controller.h
bloba9d91749edc2445b8f5b70fb503397eebe04ea93
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_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
8 #include <vector>
10 #include "base/compiler_specific.h"
11 #include "base/strings/string16.h"
12 #include "ui/gfx/native_widget_types.h"
14 namespace gfx {
15 class FontList;
16 class Point;
17 class Rect;
18 class RectF;
21 namespace ui {
22 class MouseEvent;
25 namespace autofill {
27 // This interface provides data to an AutofillPopupView.
28 class AutofillPopupController {
29 public:
30 // Called when the popup should get hidden.
31 virtual void Hide() = 0;
33 // Called whent the popup view was destroyed.
34 virtual void ViewDestroyed() = 0;
36 // Recalculates the height and width of the popup and triggers a redraw.
37 virtual void UpdateBoundsAndRedrawPopup() = 0;
39 // The user selected the line at (x, y), e.g. by hovering the mouse cursor.
40 // |x| and |y| must be in the popup coordinates.
41 virtual void LineSelectedAtPoint(int x, int y) = 0;
43 // The user accepted the line at (x, y); e.g., by clicking on it using the
44 // mouse. |x| and |y| must be in the popup coordinates.
45 virtual void LineAcceptedAtPoint(int x, int y) = 0;
47 // The user cleared the selected line, e.g. by moving the mouse cursor out of
48 // the popup bounds.
49 virtual void SelectionCleared() = 0;
51 // Whether |event| should be reposted to the native window management.
52 virtual bool ShouldRepostEvent(const ui::MouseEvent& event) = 0;
54 // Accepts the suggestion at |index|.
55 virtual void AcceptSuggestion(size_t index) = 0;
57 // Gets the resource value for the given resource, returning -1 if the
58 // resource isn't recognized.
59 virtual int GetIconResourceID(const base::string16& resource_name) const = 0;
61 // Returns true if the given index refers to an element that can be deleted.
62 virtual bool CanDelete(size_t index) const = 0;
64 // Returns true if the given index refers to an element that is a warning
65 // rather than an Autofill suggestion.
66 virtual bool IsWarning(size_t index) const = 0;
68 // Updates the bounds of the popup and initiates a redraw.
69 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0;
71 // Returns the bounds of the item at |index| in the popup, relative to
72 // the top left of the popup.
73 virtual gfx::Rect GetRowBounds(size_t index) = 0;
75 // The actual bounds of the popup.
76 virtual const gfx::Rect& popup_bounds() const = 0;
78 // The view that the form field element sits in.
79 virtual gfx::NativeView container_view() const = 0;
81 // The bounds of the form field element (screen coordinates).
82 virtual const gfx::RectF& element_bounds() const = 0;
84 // If the current popup should be displayed in RTL mode.
85 virtual bool IsRTL() const = 0;
87 // TODO(csharp): The names, subtexts and icon getters can probably be adjusted
88 // to take in the row index and return a single element, instead of the
89 // whole vector.
90 // The main labels for each autofill item.
91 virtual const std::vector<base::string16>& names() const = 0;
93 // Smaller labels for each autofill item.
94 virtual const std::vector<base::string16>& subtexts() const = 0;
96 // A string which identifies the icon to be shown for each autofill item.
97 virtual const std::vector<base::string16>& icons() const = 0;
99 // Identifier for the row.
100 virtual const std::vector<int>& identifiers() const = 0;
102 #if !defined(OS_ANDROID)
103 // The same font can vary based on the type of data it is showing,
104 // so we need to know the row.
105 virtual const gfx::FontList& GetNameFontListForRow(size_t index) const = 0;
106 virtual const gfx::FontList& subtext_font_list() const = 0;
107 #endif
109 // Returns the index of the selected line. A line is "selected" when it is
110 // hovered or has keyboard focus.
111 virtual int selected_line() const = 0;
113 // Whether the view should be hidden on outside mouse presses.
114 virtual bool hide_on_outside_click() const = 0;
116 protected:
117 virtual ~AutofillPopupController() {}
120 } // namespace autofill
122 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_