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/optional.h" | 13 #include "base/optional.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 16 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
17 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" | 17 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" |
18 #include "chrome/browser/ui/autofill/popup_controller_common.h" | 18 #include "chrome/browser/ui/autofill/popup_controller_common.h" |
19 #include "ui/accessibility/ax_enums.h" | 19 #include "ui/accessibility/ax_enums.h" |
20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
21 #include "ui/gfx/geometry/rect_f.h" | 21 #include "ui/gfx/geometry/rect_f.h" |
22 #include "ui/native_theme/native_theme.h" | 22 #include "ui/native_theme/native_theme.h" |
23 | 23 |
24 namespace content { | |
25 struct NativeWebKeyboardEvent; | |
vabr (Chromium)
2017/04/05 14:53:34
This is used on line 65. Due to reduction in popup
| |
26 class WebContents; | |
27 } | |
28 | |
24 namespace autofill { | 29 namespace autofill { |
25 | 30 |
26 class AutofillPopupDelegate; | 31 class AutofillPopupDelegate; |
27 class AutofillPopupView; | 32 class AutofillPopupView; |
28 | 33 |
29 // This class is a controller for an AutofillPopupView. It implements | 34 // This class is a controller for an AutofillPopupView. It implements |
30 // AutofillPopupController to allow calls from AutofillPopupView. The | 35 // AutofillPopupController to allow calls from AutofillPopupView. The |
31 // other, public functions are available to its instantiator. | 36 // other, public functions are available to its instantiator. |
32 class AutofillPopupControllerImpl : public AutofillPopupController { | 37 class AutofillPopupControllerImpl : public AutofillPopupController { |
33 public: | 38 public: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 const base::string16& GetElidedValueAt(int row) const override; | 100 const base::string16& GetElidedValueAt(int row) const override; |
96 const base::string16& GetElidedLabelAt(int row) const override; | 101 const base::string16& GetElidedLabelAt(int row) const override; |
97 bool GetRemovalConfirmationText(int list_index, | 102 bool GetRemovalConfirmationText(int list_index, |
98 base::string16* title, | 103 base::string16* title, |
99 base::string16* body) override; | 104 base::string16* body) override; |
100 bool RemoveSuggestion(int list_index) override; | 105 bool RemoveSuggestion(int list_index) override; |
101 ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const override; | 106 ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const override; |
102 base::Optional<int> selected_line() const override; | 107 base::Optional<int> selected_line() const override; |
103 const AutofillPopupLayoutModel& layout_model() const override; | 108 const AutofillPopupLayoutModel& layout_model() const override; |
104 | 109 |
105 content::WebContents* web_contents(); | |
106 | |
107 // Change which line is currently selected by the user. | 110 // Change which line is currently selected by the user. |
108 void SetSelectedLine(base::Optional<int> selected_line); | 111 void SetSelectedLine(base::Optional<int> selected_line); |
109 | 112 |
110 // Increase the selected line by 1, properly handling wrapping. | 113 // Increase the selected line by 1, properly handling wrapping. |
111 void SelectNextLine(); | 114 void SelectNextLine(); |
112 | 115 |
113 // Decrease the selected line by 1, properly handling wrapping. | 116 // Decrease the selected line by 1, properly handling wrapping. |
114 void SelectPreviousLine(); | 117 void SelectPreviousLine(); |
115 | 118 |
116 // The user has removed a suggestion. | 119 // The user has removed a suggestion. |
117 bool RemoveSelectedLine(); | 120 bool RemoveSelectedLine(); |
118 | 121 |
119 // Returns true if the given id refers to an element that can be accepted. | 122 // Returns true if the given id refers to an element that can be accepted. |
120 bool CanAccept(int id); | 123 bool CanAccept(int id); |
121 | 124 |
122 // Returns true if the popup still has non-options entries to show the user. | 125 // Returns true if the popup still has non-options entries to show the user. |
123 bool HasSuggestions(); | 126 bool HasSuggestions(); |
124 | 127 |
125 // Set the Autofill entry values. Exposed to allow tests to set these values | 128 // Set the Autofill entry values. Exposed to allow tests to set these values |
126 // without showing the popup. | 129 // without showing the popup. |
127 void SetValues(const std::vector<autofill::Suggestion>& suggestions); | 130 void SetValues(const std::vector<autofill::Suggestion>& suggestions); |
128 | 131 |
129 AutofillPopupView* view() { return view_; } | 132 AutofillPopupView* view() { return view_; } |
130 | 133 |
131 base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr(); | 134 base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr(); |
132 | 135 |
133 // Contains common popup functionality such as popup layout. Protected for | 136 // Contains common popup functionality such as popup layout. Protected for |
134 // testing. | 137 // testing. |
135 std::unique_ptr<PopupControllerCommon> controller_common_; | 138 const PopupControllerCommon controller_common_; |
136 | 139 |
137 private: | 140 private: |
138 #if !defined(OS_ANDROID) | 141 #if !defined(OS_ANDROID) |
139 FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, ElideText); | 142 FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, ElideText); |
140 // Helper method which elides the value and label for the suggestion at |row| | 143 // Helper method which elides the value and label for the suggestion at |row| |
141 // given the |available_width|. Puts the results in |elided_values_| and | 144 // given the |available_width|. Puts the results in |elided_values_| and |
142 // |elided_labels_|. | 145 // |elided_labels_|. |
143 void ElideValueAndLabelForRow(int row, int available_width); | 146 void ElideValueAndLabelForRow(int row, int available_width); |
144 #endif | 147 #endif |
145 | 148 |
(...skipping 22 matching lines...) Expand all Loading... | |
168 // The line that is currently selected by the user, null indicates that no | 171 // The line that is currently selected by the user, null indicates that no |
169 // line is currently selected. | 172 // line is currently selected. |
170 base::Optional<int> selected_line_; | 173 base::Optional<int> selected_line_; |
171 | 174 |
172 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; | 175 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; |
173 }; | 176 }; |
174 | 177 |
175 } // namespace autofill | 178 } // namespace autofill |
176 | 179 |
177 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 180 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
OLD | NEW |