Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.h

Issue 12188020: Adding the page and DPI scale adjustment for Autofill Popups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mock call fix #2 Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "content/public/browser/keyboard_listener.h" 11 #include "content/public/browser/keyboard_listener.h"
12 #include "ui/gfx/font.h" 12 #include "ui/gfx/font.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/rect_f.h"
14 15
15 class AutofillPopupDelegate; 16 class AutofillPopupDelegate;
16 class AutofillPopupView; 17 class AutofillPopupView;
17 18
18 namespace gfx { 19 namespace gfx {
19 class Display; 20 class Display;
20 } 21 }
21 22
22 namespace ui { 23 namespace ui {
23 class KeyEvent; 24 class KeyEvent;
24 } 25 }
25 26
26 // This class is a controller for an AutofillPopupView. It implements 27 // This class is a controller for an AutofillPopupView. It implements
27 // AutofillPopupController to allow calls from AutofillPopupView. The 28 // AutofillPopupController to allow calls from AutofillPopupView. The
28 // other, public functions are available to its instantiator. 29 // other, public functions are available to its instantiator.
29 class AutofillPopupControllerImpl : public AutofillPopupController, 30 class AutofillPopupControllerImpl : public AutofillPopupController,
30 public content::KeyboardListener { 31 public content::KeyboardListener {
31 public: 32 public:
32 // Creates a new |AutofillPopupControllerImpl|, or reuses |previous| if 33 // Creates a new |AutofillPopupControllerImpl|, or reuses |previous| if
33 // the construction arguments are the same. |previous| may be invalidated by 34 // the construction arguments are the same. |previous| may be invalidated by
34 // this call. 35 // this call.
35 static AutofillPopupControllerImpl* GetOrCreate( 36 static AutofillPopupControllerImpl* GetOrCreate(
36 AutofillPopupControllerImpl* previous, 37 AutofillPopupControllerImpl* previous,
37 AutofillPopupDelegate* delegate, 38 AutofillPopupDelegate* delegate,
38 gfx::NativeView container_view, 39 gfx::NativeView container_view,
39 const gfx::Rect& element_bounds); 40 const gfx::RectF& element_bounds);
40 41
41 // Shows the popup, or updates the existing popup with the given values. 42 // Shows the popup, or updates the existing popup with the given values.
42 void Show(const std::vector<string16>& names, 43 void Show(const std::vector<string16>& names,
43 const std::vector<string16>& subtexts, 44 const std::vector<string16>& subtexts,
44 const std::vector<string16>& icons, 45 const std::vector<string16>& icons,
45 const std::vector<int>& identifiers); 46 const std::vector<int>& identifiers);
46 47
47 // Hides the popup and destroys the controller. This also invalidates 48 // Hides the popup and destroys the controller. This also invalidates
48 // |delegate_|. Virtual for testing. 49 // |delegate_|. Virtual for testing.
49 virtual void Hide(); 50 virtual void Hide();
50 51
51 // KeyboardListener implementation. 52 // KeyboardListener implementation.
52 virtual bool HandleKeyPressEvent( 53 virtual bool HandleKeyPressEvent(
53 const content::NativeWebKeyboardEvent& event) OVERRIDE; 54 const content::NativeWebKeyboardEvent& event) OVERRIDE;
54 55
55 protected: 56 protected:
56 FRIEND_TEST_ALL_PREFIXES(AutofillExternalDelegateBrowserTest, 57 FRIEND_TEST_ALL_PREFIXES(AutofillExternalDelegateBrowserTest,
57 CloseWidgetAndNoLeaking); 58 CloseWidgetAndNoLeaking);
58 59
59 AutofillPopupControllerImpl(AutofillPopupDelegate* delegate, 60 AutofillPopupControllerImpl(AutofillPopupDelegate* delegate,
60 gfx::NativeView container_view, 61 gfx::NativeView container_view,
61 const gfx::Rect& element_bounds); 62 const gfx::RectF& element_bounds);
62 virtual ~AutofillPopupControllerImpl(); 63 virtual ~AutofillPopupControllerImpl();
63 64
64 // AutofillPopupController implementation. 65 // AutofillPopupController implementation.
65 virtual void ViewDestroyed() OVERRIDE; 66 virtual void ViewDestroyed() OVERRIDE;
66 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; 67 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE;
67 virtual void MouseHovered(int x, int y) OVERRIDE; 68 virtual void MouseHovered(int x, int y) OVERRIDE;
68 virtual void MouseClicked(int x, int y) OVERRIDE; 69 virtual void MouseClicked(int x, int y) OVERRIDE;
69 virtual void MouseExitedPopup() OVERRIDE; 70 virtual void MouseExitedPopup() OVERRIDE;
70 virtual void AcceptSuggestion(size_t index) OVERRIDE; 71 virtual void AcceptSuggestion(size_t index) OVERRIDE;
71 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; 72 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE;
72 virtual bool CanDelete(size_t index) const OVERRIDE; 73 virtual bool CanDelete(size_t index) const OVERRIDE;
73 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE; 74 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE;
74 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; 75 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE;
75 virtual const gfx::Rect& popup_bounds() const OVERRIDE; 76 virtual const gfx::Rect& popup_bounds() const OVERRIDE;
76 virtual gfx::NativeView container_view() const OVERRIDE; 77 virtual gfx::NativeView container_view() const OVERRIDE;
77 virtual const gfx::Rect& element_bounds() const OVERRIDE; 78 virtual const gfx::RectF& element_bounds() const OVERRIDE;
79
78 virtual const std::vector<string16>& names() const OVERRIDE; 80 virtual const std::vector<string16>& names() const OVERRIDE;
79 virtual const std::vector<string16>& subtexts() const OVERRIDE; 81 virtual const std::vector<string16>& subtexts() const OVERRIDE;
80 virtual const std::vector<string16>& icons() const OVERRIDE; 82 virtual const std::vector<string16>& icons() const OVERRIDE;
81 virtual const std::vector<int>& identifiers() const OVERRIDE; 83 virtual const std::vector<int>& identifiers() const OVERRIDE;
82 #if !defined(OS_ANDROID) 84 #if !defined(OS_ANDROID)
83 virtual const gfx::Font& name_font() const OVERRIDE; 85 virtual const gfx::Font& name_font() const OVERRIDE;
84 virtual const gfx::Font& subtext_font() const OVERRIDE; 86 virtual const gfx::Font& subtext_font() const OVERRIDE;
85 #endif 87 #endif
86 virtual int selected_line() const OVERRIDE; 88 virtual int selected_line() const OVERRIDE;
87 virtual bool delete_icon_hovered() const OVERRIDE; 89 virtual bool delete_icon_hovered() const OVERRIDE;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Protected so tests can access. 132 // Protected so tests can access.
131 #if !defined(OS_ANDROID) 133 #if !defined(OS_ANDROID)
132 // Calculates the desired width of the popup based on its contents. 134 // Calculates the desired width of the popup based on its contents.
133 int GetDesiredPopupWidth() const; 135 int GetDesiredPopupWidth() const;
134 136
135 // Calculates the desired height of the popup based on its contents. 137 // Calculates the desired height of the popup based on its contents.
136 int GetDesiredPopupHeight() const; 138 int GetDesiredPopupHeight() const;
137 #endif 139 #endif
138 140
139 private: 141 private:
142 const gfx::Rect RoundedElementBounds() const;
140 #if !defined(OS_ANDROID) 143 #if !defined(OS_ANDROID)
141 // Calculate the width of the row, excluding all the text. This provides 144 // Calculate the width of the row, excluding all the text. This provides
142 // the size of the row that won't be reducible (since all the text can be 145 // the size of the row that won't be reducible (since all the text can be
143 // elided if there isn't enough space). 146 // elided if there isn't enough space).
144 int RowWidthWithoutText(int row) const; 147 int RowWidthWithoutText(int row) const;
145 148
146 // Calculates and sets the bounds of the popup, including placing it properly 149 // Calculates and sets the bounds of the popup, including placing it properly
147 // to prevent it from going off the screen. 150 // to prevent it from going off the screen.
148 void UpdatePopupBounds(); 151 void UpdatePopupBounds();
149 #endif 152 #endif
(...skipping 15 matching lines...) Expand all
165 const gfx::Display& top_display, 168 const gfx::Display& top_display,
166 const gfx::Display& bottom_display, 169 const gfx::Display& bottom_display,
167 int popup_required_height) const; 170 int popup_required_height) const;
168 171
169 AutofillPopupView* view_; // Weak reference. 172 AutofillPopupView* view_; // Weak reference.
170 AutofillPopupDelegate* delegate_; // Weak reference. 173 AutofillPopupDelegate* delegate_; // Weak reference.
171 gfx::NativeView container_view_; // Weak reference. 174 gfx::NativeView container_view_; // Weak reference.
172 175
173 // The bounds of the text element that is the focus of the Autofill. 176 // The bounds of the text element that is the focus of the Autofill.
174 // These coordinates are in screen space. 177 // These coordinates are in screen space.
175 const gfx::Rect element_bounds_; 178 const gfx::RectF element_bounds_;
176 179
177 // The bounds of the Autofill popup. 180 // The bounds of the Autofill popup.
178 gfx::Rect popup_bounds_; 181 gfx::Rect popup_bounds_;
179 182
180 // The current Autofill query values. 183 // The current Autofill query values.
181 std::vector<string16> names_; 184 std::vector<string16> names_;
182 std::vector<string16> subtexts_; 185 std::vector<string16> subtexts_;
183 std::vector<string16> icons_; 186 std::vector<string16> icons_;
184 std::vector<int> identifiers_; 187 std::vector<int> identifiers_;
185 188
(...skipping 15 matching lines...) Expand all
201 bool delete_icon_hovered_; 204 bool delete_icon_hovered_;
202 205
203 // True if |HideInternal| has already been called. 206 // True if |HideInternal| has already been called.
204 bool is_hiding_; 207 bool is_hiding_;
205 208
206 // True if the delegate should be informed when |this| is destroyed. 209 // True if the delegate should be informed when |this| is destroyed.
207 bool inform_delegate_of_destruction_; 210 bool inform_delegate_of_destruction_;
208 }; 211 };
209 212
210 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ 213 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698