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

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

Issue 2727233003: Uses child views in Autofill Popup so we can trigger (Closed)
Patch Set: Combines 2 calls to InvalidateRow to 1 OnSelectedRowChanged call. Created 3 years, 9 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 <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/autofill_popup_layout_model.h" 16 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
17 #include "chrome/browser/ui/autofill/popup_controller_common.h" 17 #include "chrome/browser/ui/autofill/popup_controller_common.h"
18 #include "ui/accessibility/ax_enums.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 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
21 22
22 namespace autofill { 23 namespace autofill {
23 24
24 class AutofillPopupDelegate; 25 class AutofillPopupDelegate;
25 class AutofillPopupView; 26 class AutofillPopupView;
26 27
27 // This class is a controller for an AutofillPopupView. It implements 28 // This class is a controller for an AutofillPopupView. It implements
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ProperlyResetController); 66 ProperlyResetController);
66 67
67 AutofillPopupControllerImpl(base::WeakPtr<AutofillPopupDelegate> delegate, 68 AutofillPopupControllerImpl(base::WeakPtr<AutofillPopupDelegate> delegate,
68 content::WebContents* web_contents, 69 content::WebContents* web_contents,
69 gfx::NativeView container_view, 70 gfx::NativeView container_view,
70 const gfx::RectF& element_bounds, 71 const gfx::RectF& element_bounds,
71 base::i18n::TextDirection text_direction); 72 base::i18n::TextDirection text_direction);
72 ~AutofillPopupControllerImpl() override; 73 ~AutofillPopupControllerImpl() override;
73 74
74 // AutofillPopupViewDelegate implementation. 75 // AutofillPopupViewDelegate implementation.
75 void UpdateBoundsAndRedrawPopup() override;
76 void SetSelectionAtPoint(const gfx::Point& point) override; 76 void SetSelectionAtPoint(const gfx::Point& point) override;
77 bool AcceptSelectedLine() override; 77 bool AcceptSelectedLine() override;
78 void SelectionCleared() override; 78 void SelectionCleared() override;
79 void AcceptSuggestion(size_t index) override;
80 gfx::Rect popup_bounds() const override; 79 gfx::Rect popup_bounds() const override;
81 gfx::NativeView container_view() override; 80 gfx::NativeView container_view() override;
82 const gfx::RectF& element_bounds() const override; 81 const gfx::RectF& element_bounds() const override;
83 bool IsRTL() const override; 82 bool IsRTL() const override;
84 const std::vector<autofill::Suggestion> GetSuggestions() override; 83 const std::vector<autofill::Suggestion> GetSuggestions() override;
85 #if !defined(OS_ANDROID) 84 #if !defined(OS_ANDROID)
86 int GetElidedValueWidthForRow(size_t row) override; 85 int GetElidedValueWidthForRow(size_t row) override;
87 int GetElidedLabelWidthForRow(size_t row) override; 86 int GetElidedLabelWidthForRow(size_t row) override;
88 #endif 87 #endif
89 88
90 // AutofillPopupController implementation. 89 // AutofillPopupController implementation.
90 void OnSuggestionsChanged() override;
91 void AcceptSuggestion(size_t index) override;
91 size_t GetLineCount() const override; 92 size_t GetLineCount() const override;
92 const autofill::Suggestion& GetSuggestionAt(size_t row) const override; 93 const autofill::Suggestion& GetSuggestionAt(size_t row) const override;
93 const base::string16& GetElidedValueAt(size_t row) const override; 94 const base::string16& GetElidedValueAt(size_t row) const override;
94 const base::string16& GetElidedLabelAt(size_t row) const override; 95 const base::string16& GetElidedLabelAt(size_t row) const override;
95 bool GetRemovalConfirmationText(int list_index, 96 bool GetRemovalConfirmationText(int list_index,
96 base::string16* title, 97 base::string16* title,
97 base::string16* body) override; 98 base::string16* body) override;
98 bool RemoveSuggestion(int list_index) override; 99 bool RemoveSuggestion(int list_index) override;
99 ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const override; 100 ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const override;
100 int selected_line() const override; 101 int selected_line() const override;
(...skipping 18 matching lines...) Expand all
119 120
120 // 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.
121 bool HasSuggestions(); 122 bool HasSuggestions();
122 123
123 // Set the Autofill entry values. Exposed to allow tests to set these values 124 // Set the Autofill entry values. Exposed to allow tests to set these values
124 // without showing the popup. 125 // without showing the popup.
125 void SetValues(const std::vector<autofill::Suggestion>& suggestions); 126 void SetValues(const std::vector<autofill::Suggestion>& suggestions);
126 127
127 AutofillPopupView* view() { return view_; } 128 AutofillPopupView* view() { return view_; }
128 129
129 // |view_| pass throughs (virtual for testing).
130 virtual void ShowView();
131 virtual void InvalidateRow(size_t row);
132
133 base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr(); 130 base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr();
134 131
135 // Contains common popup functionality such as popup layout. Protected for 132 // Contains common popup functionality such as popup layout. Protected for
136 // testing. 133 // testing.
137 std::unique_ptr<PopupControllerCommon> controller_common_; 134 std::unique_ptr<PopupControllerCommon> controller_common_;
138 135
139 private: 136 private:
140 #if !defined(OS_ANDROID) 137 #if !defined(OS_ANDROID)
141 FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, ElideText); 138 FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, ElideText);
142
143 // Helper method which elides the value and label for the suggestion at |row| 139 // Helper method which elides the value and label for the suggestion at |row|
144 // given the |available_width|. Puts the results in |elided_values_| and 140 // given the |available_width|. Puts the results in |elided_values_| and
145 // |elided_labels_|. 141 // |elided_labels_|.
146 void ElideValueAndLabelForRow(size_t row, int available_width); 142 void ElideValueAndLabelForRow(size_t row, int available_width);
147 #endif 143 #endif
148 144
149 // Clear the internal state of the controller. This is needed to ensure that 145 // Clear the internal state of the controller. This is needed to ensure that
150 // when the popup is reused it doesn't leak values between uses. 146 // when the popup is reused it doesn't leak values between uses.
151 void ClearState(); 147 void ClearState();
152 148
149 friend class AutofillPopupControllerUnitTest;
150 void SetViewForTesting(AutofillPopupView* view) { view_ = view; }
151
153 AutofillPopupView* view_; // Weak reference. 152 AutofillPopupView* view_; // Weak reference.
154 AutofillPopupLayoutModel layout_model_; 153 AutofillPopupLayoutModel layout_model_;
155 base::WeakPtr<AutofillPopupDelegate> delegate_; 154 base::WeakPtr<AutofillPopupDelegate> delegate_;
156 155
157 // The text direction of the popup. 156 // The text direction of the popup.
158 base::i18n::TextDirection text_direction_; 157 base::i18n::TextDirection text_direction_;
159 158
160 // The current Autofill query values. 159 // The current Autofill query values.
161 std::vector<autofill::Suggestion> suggestions_; 160 std::vector<autofill::Suggestion> suggestions_;
162 161
163 // Elided values and labels corresponding to the suggestions_ vector to 162 // Elided values and labels corresponding to the suggestions_ vector to
164 // ensure that it fits on the screen. 163 // ensure that it fits on the screen.
165 std::vector<base::string16> elided_values_; 164 std::vector<base::string16> elided_values_;
166 std::vector<base::string16> elided_labels_; 165 std::vector<base::string16> elided_labels_;
167 166
168 // The line that is currently selected by the user. 167 // The line that is currently selected by the user.
169 // |kNoSelection| indicates that no line is currently selected. 168 // |AutofillPopupView::kNoSelection| indicates that no line is currently
169 // selected.
170 int selected_line_; 170 int selected_line_;
171 171
172 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; 172 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_;
173 }; 173 };
174 174
175 } // namespace autofill 175 } // namespace autofill
176 176
177 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ 177 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698