Chromium Code Reviews| 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_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // Creates a new |AutofillPopupControllerImpl|, or reuses |previous| if | 28 // Creates a new |AutofillPopupControllerImpl|, or reuses |previous| if |
| 29 // the construction arguments are the same. |previous| may be invalidated by | 29 // the construction arguments are the same. |previous| may be invalidated by |
| 30 // this call. | 30 // this call. |
| 31 static AutofillPopupControllerImpl* GetOrCreate( | 31 static AutofillPopupControllerImpl* GetOrCreate( |
| 32 AutofillPopupControllerImpl* previous, | 32 AutofillPopupControllerImpl* previous, |
| 33 AutofillPopupDelegate* delegate, | 33 AutofillPopupDelegate* delegate, |
| 34 gfx::NativeView container_view, | 34 gfx::NativeView container_view, |
| 35 const gfx::Rect& element_bounds); | 35 const gfx::Rect& element_bounds); |
| 36 | 36 |
| 37 // Shows the popup, or updates the existing popup with the given values. | 37 // Shows the popup, or updates the existing popup with the given values. |
| 38 void Show(const std::vector<string16>& autofill_values, | 38 void Show(const std::vector<string16>& labels, |
| 39 const std::vector<string16>& autofill_labels, | 39 const std::vector<string16>& sub_labels, |
|
Ilya Sherman
2012/12/20 04:34:52
I'd rather prefer you keep the names "values" and
Evan Stade
2012/12/20 20:01:25
I don't think it's a worthwhile use of time to upd
Ilya Sherman
2012/12/20 21:57:42
"value" is the value that gets filled into the act
Evan Stade
2012/12/20 23:03:59
renamed to name and subtext.
| |
| 40 const std::vector<string16>& autofill_icons, | 40 const std::vector<string16>& icons, |
| 41 const std::vector<int>& autofill_unique_ids); | 41 const std::vector<int>& identifiers); |
| 42 | 42 |
| 43 // Hides the popup and destroys the controller. This also invalidates | 43 // Hides the popup and destroys the controller. This also invalidates |
| 44 // |delegate_|. Virtual for testing. | 44 // |delegate_|. Virtual for testing. |
| 45 virtual void Hide(); | 45 virtual void Hide(); |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 FRIEND_TEST_ALL_PREFIXES(AutofillExternalDelegateBrowserTest, | 48 FRIEND_TEST_ALL_PREFIXES(AutofillExternalDelegateBrowserTest, |
| 49 CloseWidgetAndNoLeaking); | 49 CloseWidgetAndNoLeaking); |
| 50 | 50 |
| 51 AutofillPopupControllerImpl(AutofillPopupDelegate* delegate, | 51 AutofillPopupControllerImpl(AutofillPopupDelegate* delegate, |
| 52 gfx::NativeView container_view, | 52 gfx::NativeView container_view, |
| 53 const gfx::Rect& element_bounds); | 53 const gfx::Rect& element_bounds); |
| 54 virtual ~AutofillPopupControllerImpl(); | 54 virtual ~AutofillPopupControllerImpl(); |
| 55 | 55 |
| 56 // AutofillPopupController implementation. | 56 // AutofillPopupController implementation. |
| 57 virtual void ViewDestroyed() OVERRIDE; | 57 virtual void ViewDestroyed() OVERRIDE; |
| 58 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; | 58 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; |
| 59 virtual void SetSelectedPosition(int x, int y) OVERRIDE; | 59 virtual void MouseHovered(int x, int y) OVERRIDE; |
| 60 virtual bool AcceptAutofillSuggestion(const string16& value, | 60 virtual void MouseClicked(int x, int y) OVERRIDE; |
| 61 int unique_id, | 61 virtual void MouseLeftPopup() OVERRIDE; |
| 62 unsigned index) OVERRIDE; | 62 virtual void AcceptSuggestion(size_t index) OVERRIDE; |
| 63 virtual void AcceptSelectedPosition(int x, int y) OVERRIDE; | |
| 64 virtual void ClearSelectedLine() OVERRIDE; | |
| 65 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; | 63 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; |
| 66 virtual bool CanDelete(int id) OVERRIDE; | 64 virtual bool CanDelete(size_t index) OVERRIDE; |
| 67 #if !defined(OS_ANDROID) | 65 #if !defined(OS_ANDROID) |
| 68 virtual int GetPopupRequiredWidth() OVERRIDE; | 66 virtual int GetPopupRequiredWidth() OVERRIDE; |
| 69 virtual int GetPopupRequiredHeight() OVERRIDE; | 67 virtual int GetPopupRequiredHeight() OVERRIDE; |
| 70 #endif | 68 #endif |
| 71 virtual int GetRowHeightFromId(int unique_id) OVERRIDE; | 69 virtual gfx::Rect GetRowBounds(size_t row) OVERRIDE; |
| 72 virtual gfx::Rect GetRectForRow(size_t row, int width) OVERRIDE; | |
| 73 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; | 70 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; |
| 74 virtual const gfx::Rect& popup_bounds() const OVERRIDE; | 71 virtual const gfx::Rect& popup_bounds() const OVERRIDE; |
| 75 virtual gfx::NativeView container_view() const OVERRIDE; | 72 virtual gfx::NativeView container_view() const OVERRIDE; |
| 76 virtual const gfx::Rect& element_bounds() const OVERRIDE; | 73 virtual const gfx::Rect& element_bounds() const OVERRIDE; |
| 77 virtual const std::vector<string16>& autofill_values() const OVERRIDE; | 74 virtual const std::vector<string16>& labels() const OVERRIDE; |
| 78 virtual const std::vector<string16>& autofill_labels() const OVERRIDE; | 75 virtual const std::vector<string16>& sub_labels() const OVERRIDE; |
| 79 virtual const std::vector<string16>& autofill_icons() const OVERRIDE; | 76 virtual const std::vector<string16>& icons() const OVERRIDE; |
| 80 virtual const std::vector<int>& autofill_unique_ids() const OVERRIDE; | 77 virtual const std::vector<int>& identifiers() const OVERRIDE; |
| 81 #if !defined(OS_ANDROID) | 78 #if !defined(OS_ANDROID) |
| 82 virtual const gfx::Font& label_font() const OVERRIDE; | 79 virtual const gfx::Font& label_font() const OVERRIDE; |
| 83 virtual const gfx::Font& value_font() const OVERRIDE; | 80 virtual const gfx::Font& sub_label_font() const OVERRIDE; |
| 84 #endif | 81 #endif |
| 85 virtual int selected_line() const OVERRIDE; | 82 virtual int selected_line() const OVERRIDE; |
| 86 virtual bool delete_icon_hovered() const OVERRIDE; | 83 virtual bool delete_icon_hovered() const OVERRIDE; |
| 87 | 84 |
| 88 // KeyboardListener implementation. | 85 // KeyboardListener implementation. |
| 89 virtual bool HandleKeyPressEvent( | 86 virtual bool HandleKeyPressEvent( |
| 90 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 87 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 91 | 88 |
| 92 // Like Hide(), but doesn't invalidate |delegate_| (the delegate will still | 89 // Like Hide(), but doesn't invalidate |delegate_| (the delegate will still |
| 93 // be informed of destruction). | 90 // be informed of destruction). |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 104 | 101 |
| 105 // The user has choosen the selected line. | 102 // The user has choosen the selected line. |
| 106 bool AcceptSelectedLine(); | 103 bool AcceptSelectedLine(); |
| 107 | 104 |
| 108 // The user has removed a suggestion. | 105 // The user has removed a suggestion. |
| 109 bool RemoveSelectedLine(); | 106 bool RemoveSelectedLine(); |
| 110 | 107 |
| 111 // Convert a y-coordinate to the closest line. | 108 // Convert a y-coordinate to the closest line. |
| 112 int LineFromY(int y); | 109 int LineFromY(int y); |
| 113 | 110 |
| 111 // Returns the height of a row depending on its type. | |
| 112 int GetRowHeightFromId(int unique_id); | |
|
Ilya Sherman
2012/12/20 04:34:52
nit: |unique_id| -> |identifier|?
Evan Stade
2012/12/20 20:01:25
Done, here and everywhere.
| |
| 113 | |
| 114 // Returns true if the given |x| and |y| coordinates refer to a point that | 114 // Returns true if the given |x| and |y| coordinates refer to a point that |
| 115 // hits the delete icon in the current selected line. | 115 // hits the delete icon in the current selected line. |
| 116 bool DeleteIconIsUnder(int x, int y); | 116 bool DeleteIconIsUnder(int x, int y); |
| 117 | 117 |
| 118 // Returns true if the given id refers to an element that can be accepted. | 118 // Returns true if the given id refers to an element that can be accepted. |
| 119 bool CanAccept(int id); | 119 bool CanAccept(int id); |
| 120 | 120 |
| 121 // Returns true if the popup still has non-options entries to show the user. | 121 // Returns true if the popup still has non-options entries to show the user. |
| 122 bool HasAutofillEntries(); | 122 bool HasAutofillEntries(); |
| 123 | 123 |
| 124 AutofillPopupView* view() { return view_; } | 124 AutofillPopupView* view() { return view_; } |
| 125 | 125 |
| 126 // |view_| pass throughs (virtual for testing). | 126 // |view_| pass throughs (virtual for testing). |
| 127 virtual void ShowView(); | 127 virtual void ShowView(); |
| 128 virtual void InvalidateRow(size_t row); | 128 virtual void InvalidateRow(size_t row); |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 AutofillPopupView* view_; // Weak reference. | 131 AutofillPopupView* view_; // Weak reference. |
| 132 AutofillPopupDelegate* delegate_; // Weak reference. | 132 AutofillPopupDelegate* delegate_; // Weak reference. |
| 133 gfx::NativeView container_view_; // Weak reference. | 133 gfx::NativeView container_view_; // Weak reference. |
| 134 | 134 |
| 135 // The bounds of the text element that is the focus of the Autofill. | 135 // The bounds of the text element that is the focus of the Autofill. |
| 136 const gfx::Rect element_bounds_; | 136 const gfx::Rect element_bounds_; |
| 137 | 137 |
| 138 // The bounds of the Autofill popup. | 138 // The bounds of the Autofill popup. |
| 139 gfx::Rect popup_bounds_; | 139 gfx::Rect popup_bounds_; |
| 140 | 140 |
| 141 // The current Autofill query values. | 141 // The current Autofill query values. |
| 142 std::vector<string16> autofill_values_; | 142 std::vector<string16> labels_; |
| 143 std::vector<string16> autofill_labels_; | 143 std::vector<string16> sub_labels_; |
| 144 std::vector<string16> autofill_icons_; | 144 std::vector<string16> icons_; |
| 145 std::vector<int> autofill_unique_ids_; | 145 std::vector<int> identifiers_; |
| 146 | 146 |
| 147 #if !defined(OS_ANDROID) | 147 #if !defined(OS_ANDROID) |
| 148 // The fonts for the popup text. | 148 // The fonts for the popup text. |
| 149 gfx::Font value_font_; | |
| 150 gfx::Font label_font_; | 149 gfx::Font label_font_; |
| 150 gfx::Font sub_label_font_; | |
| 151 #endif | 151 #endif |
| 152 | 152 |
| 153 // The line that is currently selected by the user. | 153 // The line that is currently selected by the user. |
| 154 // |kNoSelection| indicates that no line is currently selected. | 154 // |kNoSelection| indicates that no line is currently selected. |
| 155 int selected_line_; | 155 int selected_line_; |
| 156 | 156 |
| 157 // Used to indicate if the delete icon within a row is currently selected. | 157 // Used to indicate if the delete icon within a row is currently selected. |
| 158 bool delete_icon_hovered_; | 158 bool delete_icon_hovered_; |
| 159 | 159 |
| 160 // True if |HideInternal| has already been called. | 160 // True if |HideInternal| has already been called. |
| 161 bool is_hiding_; | 161 bool is_hiding_; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 164 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| OLD | NEW |