| 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 "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class Font; | 14 class Font; |
| 15 class Point; | 15 class Point; |
| 16 class Rect; | 16 class Rect; |
| 17 } | 17 } |
| 18 | 18 |
| 19 // This interface provides data to an AutofillPopupView. | 19 // This interface provides data to an AutofillPopupView. |
| 20 class AutofillPopupController { | 20 class AutofillPopupController { |
| 21 public: | 21 public: |
| 22 // Called when the view is going down. | 22 // Called when the view is going down. |
| 23 virtual void ViewDestroyed() = 0; | 23 virtual void ViewDestroyed() = 0; |
| 24 | 24 |
| 25 // Recalculate the height and width of the popup and trigger a redraw. | 25 // Recalculates the height and width of the popup and triggers a redraw. |
| 26 virtual void UpdateBoundsAndRedrawPopup() = 0; | 26 virtual void UpdateBoundsAndRedrawPopup() = 0; |
| 27 | 27 |
| 28 // Change which line is selected by the user, based on coordinates. | 28 // The user has moved the mouse within the popup. |
| 29 virtual void SetSelectedPosition(int x, int y) = 0; | 29 virtual void MouseHovered(int x, int y) = 0; |
| 30 | 30 |
| 31 // Accepts the described Autofill suggestion. | 31 // The user clicked the mouse within the popup. |
| 32 virtual bool AcceptAutofillSuggestion(const string16& value, | 32 virtual void MouseClicked(int x, int y) = 0; |
| 33 int unique_id, | |
| 34 unsigned index) = 0; | |
| 35 | 33 |
| 36 // Select the value at the given position. | 34 // The user has moved the mouse outside of the popup. |
| 37 virtual void AcceptSelectedPosition(int x, int y) = 0; | 35 virtual void MouseExitedPopup() = 0; |
| 38 | 36 |
| 39 // Clear the currently selected line so that nothing is selected. | 37 // Accepts the suggestion at |index|. |
| 40 virtual void ClearSelectedLine() = 0; | 38 virtual void AcceptSuggestion(size_t index) = 0; |
| 41 | 39 |
| 42 // Get the resource value for the given resource, returning -1 if the | 40 // Gets the resource value for the given resource, returning -1 if the |
| 43 // resource isn't recognized. | 41 // resource isn't recognized. |
| 44 virtual int GetIconResourceID(const string16& resource_name) = 0; | 42 virtual int GetIconResourceID(const string16& resource_name) = 0; |
| 45 | 43 |
| 46 // Returns true if the given id refers to an element that can be deleted. | 44 // Returns true if the given index refers to an element that can be deleted. |
| 47 virtual bool CanDelete(int id) = 0; | 45 virtual bool CanDelete(size_t index) = 0; |
| 48 | 46 |
| 49 #if !defined(OS_ANDROID) | 47 #if !defined(OS_ANDROID) |
| 50 // Get width of popup needed by values. | 48 // Calculates the width of the popup based on its contents. |
| 51 virtual int GetPopupRequiredWidth() = 0; | 49 virtual int GetPopupRequiredWidth() = 0; |
| 52 | 50 |
| 53 // Get height of popup needed by values. | 51 // Calculates the height of the popup based on its contents. |
| 54 virtual int GetPopupRequiredHeight() = 0; | 52 virtual int GetPopupRequiredHeight() = 0; |
| 55 #endif | 53 #endif |
| 56 | 54 |
| 57 // Updates the bounds of the popup and initiates a redraw. | 55 // Updates the bounds of the popup and initiates a redraw. |
| 58 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0; | 56 virtual void SetPopupBounds(const gfx::Rect& bounds) = 0; |
| 59 | 57 |
| 60 // Get the height of the given row. | 58 // Returns the bounds of the item at |index| in the popup, relative to |
| 61 virtual int GetRowHeightFromId(int unique_id) = 0; | 59 // the top left of the popup. |
| 62 | 60 virtual gfx::Rect GetRowBounds(size_t index) = 0; |
| 63 // Returns the rectangle containing the item at position |row| in the popup. | |
| 64 // |row| is the index of the row, and |width| is its width. | |
| 65 virtual gfx::Rect GetRectForRow(size_t row, int width) = 0; | |
| 66 | 61 |
| 67 // The actual bounds of the popup. | 62 // The actual bounds of the popup. |
| 68 virtual const gfx::Rect& popup_bounds() const = 0; | 63 virtual const gfx::Rect& popup_bounds() const = 0; |
| 69 | 64 |
| 70 // The view that the form field element sits in. | 65 // The view that the form field element sits in. |
| 71 virtual gfx::NativeView container_view() const = 0; | 66 virtual gfx::NativeView container_view() const = 0; |
| 72 | 67 |
| 73 // The bounds of the form field element (relative to |container_origin|). | 68 // The bounds of the form field element (screen coordinates). |
| 74 virtual const gfx::Rect& element_bounds() const = 0; | 69 virtual const gfx::Rect& element_bounds() const = 0; |
| 75 | 70 |
| 76 virtual const std::vector<string16>& autofill_values() const = 0; | 71 // The main labels for each autofill item. |
| 77 virtual const std::vector<string16>& autofill_labels() const = 0; | 72 virtual const std::vector<string16>& names() const = 0; |
| 78 virtual const std::vector<string16>& autofill_icons() const = 0; | 73 |
| 79 virtual const std::vector<int>& autofill_unique_ids() const = 0; | 74 // Smaller labels for each autofill item. |
| 75 virtual const std::vector<string16>& subtexts() const = 0; |
| 76 |
| 77 // A string which identifies the icon to be shown for each autofill item. |
| 78 virtual const std::vector<string16>& icons() const = 0; |
| 79 |
| 80 // Identifier for the row. |
| 81 virtual const std::vector<int>& identifiers() const = 0; |
| 80 | 82 |
| 81 #if !defined(OS_ANDROID) | 83 #if !defined(OS_ANDROID) |
| 82 virtual const gfx::Font& label_font() const = 0; | 84 virtual const gfx::Font& name_font() const = 0; |
| 83 virtual const gfx::Font& value_font() const = 0; | 85 virtual const gfx::Font& subtext_font() const = 0; |
| 84 #endif | 86 #endif |
| 85 | 87 |
| 88 // Returns the index of the selected line. A line is "selected" when it is |
| 89 // hovered or has keyboard focus. |
| 86 virtual int selected_line() const = 0; | 90 virtual int selected_line() const = 0; |
| 91 |
| 92 // Returns true if the delete icon of the selected line is currently hovered. |
| 87 virtual bool delete_icon_hovered() const = 0; | 93 virtual bool delete_icon_hovered() const = 0; |
| 88 | 94 |
| 89 protected: | 95 protected: |
| 90 virtual ~AutofillPopupController() {} | 96 virtual ~AutofillPopupController() {} |
| 91 }; | 97 }; |
| 92 | 98 |
| 93 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ | 99 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_H_ |
| OLD | NEW |