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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 15 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
16 #include "chrome/browser/ui/autofill/popup_controller_common.h" | 16 #include "chrome/browser/ui/autofill/popup_controller_common.h" |
17 #include "chrome/common/features.h" | |
17 #include "ui/gfx/font_list.h" | 18 #include "ui/gfx/font_list.h" |
18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
19 #include "ui/gfx/geometry/rect_f.h" | 20 #include "ui/gfx/geometry/rect_f.h" |
20 | 21 |
21 namespace autofill { | 22 namespace autofill { |
22 | 23 |
23 class AutofillPopupDelegate; | 24 class AutofillPopupDelegate; |
24 class AutofillPopupView; | 25 class AutofillPopupView; |
25 | 26 |
26 // This class is a controller for an AutofillPopupView. It implements | 27 // This class is a controller for an AutofillPopupView. It implements |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 bool IsRTL() const override; | 86 bool IsRTL() const override; |
86 | 87 |
87 size_t GetLineCount() const override; | 88 size_t GetLineCount() const override; |
88 const autofill::Suggestion& GetSuggestionAt(size_t row) const override; | 89 const autofill::Suggestion& GetSuggestionAt(size_t row) const override; |
89 const base::string16& GetElidedValueAt(size_t row) const override; | 90 const base::string16& GetElidedValueAt(size_t row) const override; |
90 const base::string16& GetElidedLabelAt(size_t row) const override; | 91 const base::string16& GetElidedLabelAt(size_t row) const override; |
91 bool GetRemovalConfirmationText(int list_index, | 92 bool GetRemovalConfirmationText(int list_index, |
92 base::string16* title, | 93 base::string16* title, |
93 base::string16* body) override; | 94 base::string16* body) override; |
94 bool RemoveSuggestion(int list_index) override; | 95 bool RemoveSuggestion(int list_index) override; |
95 #if !defined(OS_ANDROID) | 96 #if !BUILDFLAG(ANDROID_JAVA_UI) |
96 const gfx::FontList& GetValueFontListForRow(size_t index) const override; | 97 const gfx::FontList& GetValueFontListForRow(size_t index) const override; |
97 const gfx::FontList& GetLabelFontList() const override; | 98 const gfx::FontList& GetLabelFontList() const override; |
98 #endif | 99 #endif |
99 int selected_line() const override; | 100 int selected_line() const override; |
100 | 101 |
101 content::WebContents* web_contents(); | 102 content::WebContents* web_contents(); |
102 | 103 |
103 // Change which line is currently selected by the user. | 104 // Change which line is currently selected by the user. |
104 void SetSelectedLine(int selected_line); | 105 void SetSelectedLine(int selected_line); |
105 | 106 |
(...skipping 22 matching lines...) Expand all Loading... | |
128 // without showing the popup. | 129 // without showing the popup. |
129 void SetValues(const std::vector<autofill::Suggestion>& suggestions); | 130 void SetValues(const std::vector<autofill::Suggestion>& suggestions); |
130 | 131 |
131 AutofillPopupView* view() { return view_; } | 132 AutofillPopupView* view() { return view_; } |
132 | 133 |
133 // |view_| pass throughs (virtual for testing). | 134 // |view_| pass throughs (virtual for testing). |
134 virtual void ShowView(); | 135 virtual void ShowView(); |
135 virtual void InvalidateRow(size_t row); | 136 virtual void InvalidateRow(size_t row); |
136 | 137 |
137 // Protected so tests can access. | 138 // Protected so tests can access. |
138 #if !defined(OS_ANDROID) | 139 #if !BUILDFLAG(ANDROID_JAVA_UI) |
Evan Stade
2016/01/09 00:03:02
imo this is sort of hard to read. On the one hand,
bshe
2016/01/11 15:52:02
I see your point. It is indeed more clear but long
| |
139 // Calculates the desired width of the popup based on its contents. | 140 // Calculates the desired width of the popup based on its contents. |
140 int GetDesiredPopupWidth() const; | 141 int GetDesiredPopupWidth() const; |
141 | 142 |
142 // Calculates the desired height of the popup based on its contents. | 143 // Calculates the desired height of the popup based on its contents. |
143 int GetDesiredPopupHeight() const; | 144 int GetDesiredPopupHeight() const; |
144 | 145 |
145 // Calculate the width of the row, excluding all the text. This provides | 146 // Calculate the width of the row, excluding all the text. This provides |
146 // the size of the row that won't be reducible (since all the text can be | 147 // the size of the row that won't be reducible (since all the text can be |
147 // elided if there isn't enough space). | 148 // elided if there isn't enough space). |
148 int RowWidthWithoutText(int row) const; | 149 int RowWidthWithoutText(int row) const; |
149 #endif | 150 #endif |
150 | 151 |
151 base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr(); | 152 base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr(); |
152 | 153 |
153 // Contains common popup functionality such as popup layout. Protected for | 154 // Contains common popup functionality such as popup layout. Protected for |
154 // testing. | 155 // testing. |
155 scoped_ptr<PopupControllerCommon> controller_common_; | 156 scoped_ptr<PopupControllerCommon> controller_common_; |
156 | 157 |
157 private: | 158 private: |
158 // Clear the internal state of the controller. This is needed to ensure that | 159 // Clear the internal state of the controller. This is needed to ensure that |
159 // when the popup is reused it doesn't leak values between uses. | 160 // when the popup is reused it doesn't leak values between uses. |
160 void ClearState(); | 161 void ClearState(); |
161 | 162 |
162 #if !defined(OS_ANDROID) | 163 #if !BUILDFLAG(ANDROID_JAVA_UI) |
163 // Calculates and sets the bounds of the popup, including placing it properly | 164 // Calculates and sets the bounds of the popup, including placing it properly |
164 // to prevent it from going off the screen. | 165 // to prevent it from going off the screen. |
165 void UpdatePopupBounds(); | 166 void UpdatePopupBounds(); |
166 #endif | 167 #endif |
167 | 168 |
168 AutofillPopupView* view_; // Weak reference. | 169 AutofillPopupView* view_; // Weak reference. |
169 base::WeakPtr<AutofillPopupDelegate> delegate_; | 170 base::WeakPtr<AutofillPopupDelegate> delegate_; |
170 | 171 |
171 // The bounds of the Autofill popup. | 172 // The bounds of the Autofill popup. |
172 gfx::Rect popup_bounds_; | 173 gfx::Rect popup_bounds_; |
173 | 174 |
174 // The text direction of the popup. | 175 // The text direction of the popup. |
175 base::i18n::TextDirection text_direction_; | 176 base::i18n::TextDirection text_direction_; |
176 | 177 |
177 // The current Autofill query values. | 178 // The current Autofill query values. |
178 std::vector<autofill::Suggestion> suggestions_; | 179 std::vector<autofill::Suggestion> suggestions_; |
179 | 180 |
180 // Elided values and labels corresponding to the suggestions_ vector to | 181 // Elided values and labels corresponding to the suggestions_ vector to |
181 // ensure that it fits on the screen. | 182 // ensure that it fits on the screen. |
182 std::vector<base::string16> elided_values_; | 183 std::vector<base::string16> elided_values_; |
183 std::vector<base::string16> elided_labels_; | 184 std::vector<base::string16> elided_labels_; |
184 | 185 |
185 #if !defined(OS_ANDROID) | 186 #if !BUILDFLAG(ANDROID_JAVA_UI) |
186 // The fonts for the popup text. | 187 // The fonts for the popup text. |
187 gfx::FontList value_font_list_; | 188 gfx::FontList value_font_list_; |
188 gfx::FontList label_font_list_; | 189 gfx::FontList label_font_list_; |
189 gfx::FontList warning_font_list_; | 190 gfx::FontList warning_font_list_; |
190 gfx::FontList title_font_list_; | 191 gfx::FontList title_font_list_; |
191 #endif | 192 #endif |
192 | 193 |
193 // The line that is currently selected by the user. | 194 // The line that is currently selected by the user. |
194 // |kNoSelection| indicates that no line is currently selected. | 195 // |kNoSelection| indicates that no line is currently selected. |
195 int selected_line_; | 196 int selected_line_; |
196 | 197 |
197 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; | 198 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; |
198 }; | 199 }; |
199 | 200 |
200 } // namespace autofill | 201 } // namespace autofill |
201 | 202 |
202 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 203 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
OLD | NEW |