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"
24 // This interface provides data to an AutofillPopupView.
25 class AutofillPopupController
: public AutofillPopupViewDelegate
{
27 // Recalculates the height and width of the popup and triggers a redraw.
28 virtual void UpdateBoundsAndRedrawPopup() = 0;
30 // Accepts the suggestion at |index|.
31 virtual void AcceptSuggestion(size_t index
) = 0;
33 // Gets the resource value for the given resource, returning -1 if the
34 // resource isn't recognized.
35 virtual int GetIconResourceID(const base::string16
& resource_name
) const = 0;
37 // Returns true if the given index refers to an element that can be deleted.
38 virtual bool CanDelete(size_t index
) const = 0;
40 // Returns true if the given index refers to an element that is a warning
41 // rather than an Autofill suggestion.
42 virtual bool IsWarning(size_t index
) const = 0;
44 // Updates the bounds of the popup and initiates a redraw.
45 virtual void SetPopupBounds(const gfx::Rect
& bounds
) = 0;
47 // Returns the bounds of the item at |index| in the popup, relative to
48 // the top left of the popup.
49 virtual gfx::Rect
GetRowBounds(size_t index
) = 0;
51 // Returns the number of lines of data that there are.
52 virtual size_t GetLineCount() const = 0;
54 // Returns the suggestion or pre-elided string at the given row index.
55 virtual const autofill::Suggestion
& GetSuggestionAt(size_t row
) const = 0;
56 virtual const base::string16
& GetElidedValueAt(size_t row
) const = 0;
57 virtual const base::string16
& GetElidedLabelAt(size_t row
) const = 0;
59 #if !defined(OS_ANDROID)
60 // The same font can vary based on the type of data it is showing,
61 // so we need to know the row.
62 virtual const gfx::FontList
& GetValueFontListForRow(size_t index
) const = 0;
63 virtual const gfx::FontList
& GetLabelFontList() const = 0;
66 // Returns the index of the selected line. A line is "selected" when it is
67 // hovered or has keyboard focus.
68 virtual int selected_line() const = 0;
71 ~AutofillPopupController() override
{}
74 } // namespace autofill
76 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_