Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_popup_controller.h
blobd355d60392645bbcd482a4de8637ae5e44e31f84
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 // This interface provides data to an AutofillPopupView.
23 class AutofillPopupController : public AutofillPopupViewDelegate {
24 public:
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
51 // whole vector.
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;
69 #endif
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;
75 protected:
76 virtual ~AutofillPopupController() {}
79 } // namespace autofill
81 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_