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"
22 // This interface provides data to an AutofillPopupView.
23 class AutofillPopupController
: public AutofillPopupViewDelegate
{
25 // Recalculates the height and width of the popup and triggers a redraw.
26 virtual void UpdateBoundsAndRedrawPopup() = 0;
28 // Accepts the suggestion at |index|.
29 virtual void AcceptSuggestion(size_t index
) = 0;
31 // Gets the resource value for the given resource, returning -1 if the
32 // resource isn't recognized.
33 virtual int GetIconResourceID(const base::string16
& resource_name
) const = 0;
35 // Returns true if the given index refers to an element that can be deleted.
36 virtual bool CanDelete(size_t index
) const = 0;
38 // Returns true if the given index refers to an element that is a warning
39 // rather than an Autofill suggestion.
40 virtual bool IsWarning(size_t index
) const = 0;
42 // Updates the bounds of the popup and initiates a redraw.
43 virtual void SetPopupBounds(const gfx::Rect
& bounds
) = 0;
45 // Returns the bounds of the item at |index| in the popup, relative to
46 // the top left of the popup.
47 virtual gfx::Rect
GetRowBounds(size_t index
) = 0;
49 // TODO(csharp): The names, subtexts and icon getters can probably be adjusted
50 // to take in the row index and return a single element, instead of the
52 // The main labels for each autofill item.
53 virtual const std::vector
<base::string16
>& names() const = 0;
55 // Smaller labels for each autofill item.
56 virtual const std::vector
<base::string16
>& subtexts() const = 0;
58 // A string which identifies the icon to be shown for each autofill item.
59 virtual const std::vector
<base::string16
>& icons() const = 0;
61 // Identifier for the row.
62 virtual const std::vector
<int>& identifiers() const = 0;
64 #if !defined(OS_ANDROID)
65 // The same font can vary based on the type of data it is showing,
66 // so we need to know the row.
67 virtual const gfx::FontList
& GetNameFontListForRow(size_t index
) const = 0;
68 virtual const gfx::FontList
& subtext_font_list() const = 0;
71 // Returns the index of the selected line. A line is "selected" when it is
72 // hovered or has keyboard focus.
73 virtual int selected_line() const = 0;
76 virtual ~AutofillPopupController() {}
79 } // namespace autofill
81 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_