Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_popup_controller.h
blob2b4927cfc8cdd0b8aa576d83fd86f3983f1cd36f
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 "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
14 namespace gfx {
15 class FontList;
16 class Point;
17 class Rect;
20 namespace autofill {
22 struct Suggestion;
24 // This interface provides data to an AutofillPopupView.
25 class AutofillPopupController : public AutofillPopupViewDelegate {
26 public:
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 is a warning
38 // rather than an Autofill suggestion.
39 virtual bool IsWarning(size_t index) const = 0;
41 // Updates the bounds of the popup and initiates a redraw.
42 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0;
44 // Returns the bounds of the item at |index| in the popup, relative to
45 // the top left of the popup.
46 virtual gfx::Rect GetRowBounds(size_t index) = 0;
48 // Returns the number of lines of data that there are.
49 virtual size_t GetLineCount() const = 0;
51 // Returns the suggestion or pre-elided string at the given row index.
52 virtual const autofill::Suggestion& GetSuggestionAt(size_t row) const = 0;
53 virtual const base::string16& GetElidedValueAt(size_t row) const = 0;
54 virtual const base::string16& GetElidedLabelAt(size_t row) const = 0;
56 // Returns whether the item at |list_index| can be removed. If so, fills
57 // out |title| and |body| (when non-null) with relevant user-facing text.
58 virtual bool GetRemovalConfirmationText(int index,
59 base::string16* title,
60 base::string16* body) = 0;
62 // Removes the suggestion at the given index.
63 virtual bool RemoveSuggestion(int index) = 0;
65 #if !defined(OS_ANDROID)
66 // The same font can vary based on the type of data it is showing,
67 // so we need to know the row.
68 virtual const gfx::FontList& GetValueFontListForRow(size_t index) const = 0;
69 virtual const gfx::FontList& GetLabelFontList() const = 0;
70 #endif
72 // Returns the index of the selected line. A line is "selected" when it is
73 // hovered or has keyboard focus.
74 virtual int selected_line() const = 0;
76 protected:
77 ~AutofillPopupController() override {}
80 } // namespace autofill
82 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_