OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" | 12 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class FontList; | 15 class FontList; |
16 class Point; | 16 class Point; |
17 class Rect; | 17 class Rect; |
18 } | 18 } |
19 | 19 |
20 namespace autofill { | 20 namespace autofill { |
21 | 21 |
| 22 struct Suggestion; |
| 23 |
22 // This interface provides data to an AutofillPopupView. | 24 // This interface provides data to an AutofillPopupView. |
23 class AutofillPopupController : public AutofillPopupViewDelegate { | 25 class AutofillPopupController : public AutofillPopupViewDelegate { |
24 public: | 26 public: |
25 // Recalculates the height and width of the popup and triggers a redraw. | 27 // Recalculates the height and width of the popup and triggers a redraw. |
26 virtual void UpdateBoundsAndRedrawPopup() = 0; | 28 virtual void UpdateBoundsAndRedrawPopup() = 0; |
27 | 29 |
28 // Accepts the suggestion at |index|. | 30 // Accepts the suggestion at |index|. |
29 virtual void AcceptSuggestion(size_t index) = 0; | 31 virtual void AcceptSuggestion(size_t index) = 0; |
30 | 32 |
31 // Gets the resource value for the given resource, returning -1 if the | 33 // Gets the resource value for the given resource, returning -1 if the |
32 // resource isn't recognized. | 34 // resource isn't recognized. |
33 virtual int GetIconResourceID(const base::string16& resource_name) const = 0; | 35 virtual int GetIconResourceID(const base::string16& resource_name) const = 0; |
34 | 36 |
35 // Returns true if the given index refers to an element that can be deleted. | 37 // Returns true if the given index refers to an element that can be deleted. |
36 virtual bool CanDelete(size_t index) const = 0; | 38 virtual bool CanDelete(size_t index) const = 0; |
37 | 39 |
38 // Returns true if the given index refers to an element that is a warning | 40 // Returns true if the given index refers to an element that is a warning |
39 // rather than an Autofill suggestion. | 41 // rather than an Autofill suggestion. |
40 virtual bool IsWarning(size_t index) const = 0; | 42 virtual bool IsWarning(size_t index) const = 0; |
41 | 43 |
42 // Updates the bounds of the popup and initiates a redraw. | 44 // Updates the bounds of the popup and initiates a redraw. |
43 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0; | 45 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0; |
44 | 46 |
45 // Returns the bounds of the item at |index| in the popup, relative to | 47 // Returns the bounds of the item at |index| in the popup, relative to |
46 // the top left of the popup. | 48 // the top left of the popup. |
47 virtual gfx::Rect GetRowBounds(size_t index) = 0; | 49 virtual gfx::Rect GetRowBounds(size_t index) = 0; |
48 | 50 |
49 // TODO(csharp): The names, subtexts and icon getters can probably be adjusted | 51 // Returns the number of lines of data that there are. |
50 // to take in the row index and return a single element, instead of the | 52 virtual size_t GetLineCount() const = 0; |
51 // whole vector. | |
52 // The main labels for each autofill item. | |
53 virtual const std::vector<base::string16>& names() const = 0; | |
54 | 53 |
55 // Smaller labels for each autofill item. | 54 // Returns the suggestion or pre-elided string at the given row index. |
56 virtual const std::vector<base::string16>& subtexts() const = 0; | 55 virtual const autofill::Suggestion& GetSuggestionAt(size_t row) const = 0; |
57 | 56 virtual const base::string16& GetElidedValueAt(size_t row) const = 0; |
58 // A string which identifies the icon to be shown for each autofill item. | 57 virtual const base::string16& GetElidedLabelAt(size_t row) const = 0; |
59 virtual const std::vector<base::string16>& icons() const = 0; | |
60 | |
61 // Identifier for the row. | |
62 virtual const std::vector<int>& identifiers() const = 0; | |
63 | 58 |
64 #if !defined(OS_ANDROID) | 59 #if !defined(OS_ANDROID) |
65 // The same font can vary based on the type of data it is showing, | 60 // The same font can vary based on the type of data it is showing, |
66 // so we need to know the row. | 61 // so we need to know the row. |
67 virtual const gfx::FontList& GetNameFontListForRow(size_t index) const = 0; | 62 virtual const gfx::FontList& GetValueFontListForRow(size_t index) const = 0; |
68 virtual const gfx::FontList& subtext_font_list() const = 0; | 63 virtual const gfx::FontList& GetLabelFontList() const = 0; |
69 #endif | 64 #endif |
70 | 65 |
71 // Returns the index of the selected line. A line is "selected" when it is | 66 // Returns the index of the selected line. A line is "selected" when it is |
72 // hovered or has keyboard focus. | 67 // hovered or has keyboard focus. |
73 virtual int selected_line() const = 0; | 68 virtual int selected_line() const = 0; |
74 | 69 |
75 protected: | 70 protected: |
76 ~AutofillPopupController() override {} | 71 ~AutofillPopupController() override {} |
77 }; | 72 }; |
78 | 73 |
79 } // namespace autofill | 74 } // namespace autofill |
80 | 75 |
81 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ | 76 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ |
OLD | NEW |