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_
10 #include "base/compiler_specific.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
23 // This interface provides data to an AutofillPopupView.
24 class AutofillPopupController
: public AutofillPopupViewDelegate
{
26 // Recalculates the height and width of the popup and triggers a redraw.
27 virtual void UpdateBoundsAndRedrawPopup() = 0;
29 // Accepts the suggestion at |index|.
30 virtual void AcceptSuggestion(size_t index
) = 0;
32 // Gets the resource value for the given resource, returning -1 if the
33 // resource isn't recognized.
34 virtual int GetIconResourceID(const base::string16
& resource_name
) const = 0;
36 // Returns true if the given index refers to an element that can be deleted.
37 virtual bool CanDelete(size_t index
) const = 0;
39 // Returns true if the given index refers to an element that is a warning
40 // rather than an Autofill suggestion.
41 virtual bool IsWarning(size_t index
) const = 0;
43 // Updates the bounds of the popup and initiates a redraw.
44 virtual void SetPopupBounds(const gfx::Rect
& bounds
) = 0;
46 // Returns the bounds of the item at |index| in the popup, relative to
47 // the top left of the popup.
48 virtual gfx::Rect
GetRowBounds(size_t index
) = 0;
50 // The bounds of the form field element (screen coordinates).
51 virtual const gfx::RectF
& element_bounds() const = 0;
53 // If the current popup should be displayed in RTL mode.
54 virtual bool IsRTL() const = 0;
56 // TODO(csharp): The names, subtexts and icon getters can probably be adjusted
57 // to take in the row index and return a single element, instead of the
59 // The main labels for each autofill item.
60 virtual const std::vector
<base::string16
>& names() const = 0;
62 // Smaller labels for each autofill item.
63 virtual const std::vector
<base::string16
>& subtexts() const = 0;
65 // A string which identifies the icon to be shown for each autofill item.
66 virtual const std::vector
<base::string16
>& icons() const = 0;
68 // Identifier for the row.
69 virtual const std::vector
<int>& identifiers() const = 0;
71 #if !defined(OS_ANDROID)
72 // The same font can vary based on the type of data it is showing,
73 // so we need to know the row.
74 virtual const gfx::FontList
& GetNameFontListForRow(size_t index
) const = 0;
75 virtual const gfx::FontList
& subtext_font_list() const = 0;
78 // Returns the index of the selected line. A line is "selected" when it is
79 // hovered or has keyboard focus.
80 virtual int selected_line() const = 0;
83 virtual ~AutofillPopupController() {}
86 } // namespace autofill
88 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_