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

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

Issue 11817051: Elide text in the new Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixing compile errors Created 7 years, 11 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
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 14
15 class AutofillPopupDelegate; 15 class AutofillPopupDelegate;
16 class AutofillPopupView; 16 class AutofillPopupView;
17 17
18 namespace gfx {
19 class Display;
20 }
21
18 namespace ui { 22 namespace ui {
19 class KeyEvent; 23 class KeyEvent;
20 } 24 }
21 25
22 // This class is a controller for an AutofillPopupView. It implements 26 // This class is a controller for an AutofillPopupView. It implements
23 // AutofillPopupController to allow calls from AutofillPopupView. The 27 // AutofillPopupController to allow calls from AutofillPopupView. The
24 // other, public functions are available to its instantiator. 28 // other, public functions are available to its instantiator.
25 class AutofillPopupControllerImpl : public AutofillPopupController, 29 class AutofillPopupControllerImpl : public AutofillPopupController,
26 public content::KeyboardListener { 30 public content::KeyboardListener {
27 public: 31 public:
(...skipping 27 matching lines...) Expand all
55 59
56 // AutofillPopupController implementation. 60 // AutofillPopupController implementation.
57 virtual void ViewDestroyed() OVERRIDE; 61 virtual void ViewDestroyed() OVERRIDE;
58 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; 62 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE;
59 virtual void MouseHovered(int x, int y) OVERRIDE; 63 virtual void MouseHovered(int x, int y) OVERRIDE;
60 virtual void MouseClicked(int x, int y) OVERRIDE; 64 virtual void MouseClicked(int x, int y) OVERRIDE;
61 virtual void MouseExitedPopup() OVERRIDE; 65 virtual void MouseExitedPopup() OVERRIDE;
62 virtual void AcceptSuggestion(size_t index) OVERRIDE; 66 virtual void AcceptSuggestion(size_t index) OVERRIDE;
63 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; 67 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE;
64 virtual bool CanDelete(size_t index) OVERRIDE; 68 virtual bool CanDelete(size_t index) OVERRIDE;
65 #if !defined(OS_ANDROID)
66 virtual int GetPopupRequiredWidth() OVERRIDE;
67 virtual int GetPopupRequiredHeight() OVERRIDE;
68 #endif
69 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE; 69 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE;
70 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; 70 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE;
71 virtual const gfx::Rect& popup_bounds() const OVERRIDE; 71 virtual const gfx::Rect& popup_bounds() const OVERRIDE;
72 virtual gfx::NativeView container_view() const OVERRIDE; 72 virtual gfx::NativeView container_view() const OVERRIDE;
73 virtual const gfx::Rect& element_bounds() const OVERRIDE; 73 virtual const gfx::Rect& element_bounds() const OVERRIDE;
74 virtual const std::vector<string16>& names() const OVERRIDE; 74 virtual const std::vector<string16>& names() const OVERRIDE;
75 virtual const std::vector<string16>& subtexts() const OVERRIDE; 75 virtual const std::vector<string16>& subtexts() const OVERRIDE;
76 virtual const std::vector<string16>& icons() const OVERRIDE; 76 virtual const std::vector<string16>& icons() const OVERRIDE;
77 virtual const std::vector<int>& identifiers() const OVERRIDE; 77 virtual const std::vector<int>& identifiers() const OVERRIDE;
78 #if !defined(OS_ANDROID) 78 #if !defined(OS_ANDROID)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 HasSuggestions(); 122 bool HasSuggestions();
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 #if !defined(OS_ANDROID)
132 // Calculates the width of the popup based on its contents.
133 int GetPopupRequiredWidth();
134
135 // Calculates the height of the popup based on its contents.
136 int GetPopupRequiredHeight();
137
138 // Calculate the width of the row, excluding all the text. This provides
139 // the size of the row that won't be reducible (since all the text can be
140 // elided if there isn't enough space).
141 int RowWidthWithoutText(int row);
142
143 // Calculates and sets the bounds of the popup, including placing it properly
144 // to prevent it from going off the screen (virtual for testing).
145 virtual void UpdatePopupBounds();
146 #endif
147
148 // Calculates the width of the popup and the x position of it. These values
149 // will stay on the screen.
150 std::pair<int, int> CalculatePopupXAndWidth(
151 const gfx::Display& left_display,
152 const gfx::Display& right_display,
153 int popup_required_width);
154
155 // Calculates the height of the popup and the y position of it. These values
156 // will stay on the screen.
157 std::pair<int, int> CalculatePopupYAndHeight(
158 const gfx::Display& top_display,
159 const gfx::Display& bottom_display,
160 int popup_required_height);
161
131 AutofillPopupView* view_; // Weak reference. 162 AutofillPopupView* view_; // Weak reference.
132 AutofillPopupDelegate* delegate_; // Weak reference. 163 AutofillPopupDelegate* delegate_; // Weak reference.
133 gfx::NativeView container_view_; // Weak reference. 164 gfx::NativeView container_view_; // Weak reference.
134 165
135 // The bounds of the text element that is the focus of the Autofill. 166 // The bounds of the text element that is the focus of the Autofill.
136 // These coordinates are in screen space. 167 // These coordinates are in screen space.
137 const gfx::Rect element_bounds_; 168 const gfx::Rect element_bounds_;
138 169
139 // The bounds of the Autofill popup. 170 // The bounds of the Autofill popup.
140 gfx::Rect popup_bounds_; 171 gfx::Rect popup_bounds_;
(...skipping 18 matching lines...) Expand all
159 bool delete_icon_hovered_; 190 bool delete_icon_hovered_;
160 191
161 // True if |HideInternal| has already been called. 192 // True if |HideInternal| has already been called.
162 bool is_hiding_; 193 bool is_hiding_;
163 194
164 // True if the delegate should be informed when |this| is destroyed. 195 // True if the delegate should be informed when |this| is destroyed.
165 bool inform_delegate_of_destruction_; 196 bool inform_delegate_of_destruction_;
166 }; 197 };
167 198
168 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ 199 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698