• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
7 
8 #include <vector>
9 
10 #include "base/compiler_specific.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
13 
14 namespace gfx {
15 class FontList;
16 class Point;
17 class Rect;
18 class RectF;
19 }
20 
21 namespace autofill {
22 
23 // This interface provides data to an AutofillPopupView.
24 class AutofillPopupController : public AutofillPopupViewDelegate {
25  public:
26   // Recalculates the height and width of the popup and triggers a redraw.
27   virtual void UpdateBoundsAndRedrawPopup() = 0;
28 
29   // Accepts the suggestion at |index|.
30   virtual void AcceptSuggestion(size_t index) = 0;
31 
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;
35 
36   // Returns true if the given index refers to an element that can be deleted.
37   virtual bool CanDelete(size_t index) const = 0;
38 
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;
42 
43   // Updates the bounds of the popup and initiates a redraw.
44   virtual void SetPopupBounds(const gfx::Rect& bounds) = 0;
45 
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;
49 
50   // The bounds of the form field element (screen coordinates).
51   virtual const gfx::RectF& element_bounds() const = 0;
52 
53   // If the current popup should be displayed in RTL mode.
54   virtual bool IsRTL() const = 0;
55 
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
58   // whole vector.
59   // The main labels for each autofill item.
60   virtual const std::vector<base::string16>& names() const = 0;
61 
62   // Smaller labels for each autofill item.
63   virtual const std::vector<base::string16>& subtexts() const = 0;
64 
65   // A string which identifies the icon to be shown for each autofill item.
66   virtual const std::vector<base::string16>& icons() const = 0;
67 
68   // Identifier for the row.
69   virtual const std::vector<int>& identifiers() const = 0;
70 
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;
76 #endif
77 
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;
81 
82  protected:
~AutofillPopupController()83   virtual ~AutofillPopupController() {}
84 };
85 
86 }  // namespace autofill
87 
88 #endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_
89