| 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 "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // |web_contents| while the popup is showing, unless |web_contents| is NULL. | 31 // |web_contents| while the popup is showing, unless |web_contents| is NULL. |
| 32 static base::WeakPtr<AutofillPopupControllerImpl> GetOrCreate( | 32 static base::WeakPtr<AutofillPopupControllerImpl> GetOrCreate( |
| 33 base::WeakPtr<AutofillPopupControllerImpl> previous, | 33 base::WeakPtr<AutofillPopupControllerImpl> previous, |
| 34 base::WeakPtr<AutofillPopupDelegate> delegate, | 34 base::WeakPtr<AutofillPopupDelegate> delegate, |
| 35 content::WebContents* web_contents, | 35 content::WebContents* web_contents, |
| 36 gfx::NativeView container_view, | 36 gfx::NativeView container_view, |
| 37 const gfx::RectF& element_bounds, | 37 const gfx::RectF& element_bounds, |
| 38 base::i18n::TextDirection text_direction); | 38 base::i18n::TextDirection text_direction); |
| 39 | 39 |
| 40 // Shows the popup, or updates the existing popup with the given values. | 40 // Shows the popup, or updates the existing popup with the given values. |
| 41 void Show(const std::vector<base::string16>& names, | 41 void Show(const std::vector<autofill::Suggestion>& suggestions); |
| 42 const std::vector<base::string16>& subtexts, | |
| 43 const std::vector<base::string16>& icons, | |
| 44 const std::vector<int>& identifiers); | |
| 45 | 42 |
| 46 // Updates the data list values currently shown with the popup. | 43 // Updates the data list values currently shown with the popup. |
| 47 void UpdateDataListValues(const std::vector<base::string16>& values, | 44 void UpdateDataListValues(const std::vector<base::string16>& values, |
| 48 const std::vector<base::string16>& labels); | 45 const std::vector<base::string16>& labels); |
| 49 | 46 |
| 50 // Hides the popup and destroys the controller. This also invalidates | 47 // Hides the popup and destroys the controller. This also invalidates |
| 51 // |delegate_|. | 48 // |delegate_|. |
| 52 void Hide() override; | 49 void Hide() override; |
| 53 | 50 |
| 54 // Invoked when the view was destroyed by by someone other than this class. | 51 // Invoked when the view was destroyed by by someone other than this class. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 81 int GetIconResourceID(const base::string16& resource_name) const override; | 78 int GetIconResourceID(const base::string16& resource_name) const override; |
| 82 bool CanDelete(size_t index) const override; | 79 bool CanDelete(size_t index) const override; |
| 83 bool IsWarning(size_t index) const override; | 80 bool IsWarning(size_t index) const override; |
| 84 gfx::Rect GetRowBounds(size_t index) override; | 81 gfx::Rect GetRowBounds(size_t index) override; |
| 85 void SetPopupBounds(const gfx::Rect& bounds) override; | 82 void SetPopupBounds(const gfx::Rect& bounds) override; |
| 86 const gfx::Rect& popup_bounds() const override; | 83 const gfx::Rect& popup_bounds() const override; |
| 87 gfx::NativeView container_view() override; | 84 gfx::NativeView container_view() override; |
| 88 const gfx::RectF& element_bounds() const override; | 85 const gfx::RectF& element_bounds() const override; |
| 89 bool IsRTL() const override; | 86 bool IsRTL() const override; |
| 90 | 87 |
| 91 const std::vector<base::string16>& names() const override; | 88 virtual size_t GetLineCount() const override; |
| 92 const std::vector<base::string16>& subtexts() const override; | 89 virtual const autofill::Suggestion& GetSuggestionAt( |
| 93 const std::vector<base::string16>& icons() const override; | 90 size_t row) const override; |
| 94 const std::vector<int>& identifiers() const override; | 91 virtual const base::string16& GetElidedValueAt(size_t row) const override; |
| 92 virtual const base::string16& GetElidedLabelAt(size_t row) const override; |
| 95 #if !defined(OS_ANDROID) | 93 #if !defined(OS_ANDROID) |
| 96 const gfx::FontList& GetNameFontListForRow(size_t index) const override; | 94 const gfx::FontList& GetValueFontListForRow(size_t index) const override; |
| 97 const gfx::FontList& subtext_font_list() const override; | 95 const gfx::FontList& GetLabelFontList() const override; |
| 98 #endif | 96 #endif |
| 99 int selected_line() const override; | 97 int selected_line() const override; |
| 100 | 98 |
| 101 content::WebContents* web_contents(); | 99 content::WebContents* web_contents(); |
| 102 | 100 |
| 103 // Change which line is currently selected by the user. | 101 // Change which line is currently selected by the user. |
| 104 void SetSelectedLine(int selected_line); | 102 void SetSelectedLine(int selected_line); |
| 105 | 103 |
| 106 // Increase the selected line by 1, properly handling wrapping. | 104 // Increase the selected line by 1, properly handling wrapping. |
| 107 void SelectNextLine(); | 105 void SelectNextLine(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 119 int GetRowHeightFromId(int identifier) const; | 117 int GetRowHeightFromId(int identifier) const; |
| 120 | 118 |
| 121 // Returns true if the given id refers to an element that can be accepted. | 119 // Returns true if the given id refers to an element that can be accepted. |
| 122 bool CanAccept(int id); | 120 bool CanAccept(int id); |
| 123 | 121 |
| 124 // Returns true if the popup still has non-options entries to show the user. | 122 // Returns true if the popup still has non-options entries to show the user. |
| 125 bool HasSuggestions(); | 123 bool HasSuggestions(); |
| 126 | 124 |
| 127 // Set the Autofill entry values. Exposed to allow tests to set these values | 125 // Set the Autofill entry values. Exposed to allow tests to set these values |
| 128 // without showing the popup. | 126 // without showing the popup. |
| 129 void SetValues(const std::vector<base::string16>& names, | 127 void SetValues(const std::vector<autofill::Suggestion>& suggestions); |
| 130 const std::vector<base::string16>& subtexts, | |
| 131 const std::vector<base::string16>& icons, | |
| 132 const std::vector<int>& identifier); | |
| 133 | 128 |
| 134 AutofillPopupView* view() { return view_; } | 129 AutofillPopupView* view() { return view_; } |
| 135 | 130 |
| 136 // |view_| pass throughs (virtual for testing). | 131 // |view_| pass throughs (virtual for testing). |
| 137 virtual void ShowView(); | 132 virtual void ShowView(); |
| 138 virtual void InvalidateRow(size_t row); | 133 virtual void InvalidateRow(size_t row); |
| 139 | 134 |
| 140 // Protected so tests can access. | 135 // Protected so tests can access. |
| 141 #if !defined(OS_ANDROID) | 136 #if !defined(OS_ANDROID) |
| 142 // Calculates the desired width of the popup based on its contents. | 137 // Calculates the desired width of the popup based on its contents. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 171 AutofillPopupView* view_; // Weak reference. | 166 AutofillPopupView* view_; // Weak reference. |
| 172 base::WeakPtr<AutofillPopupDelegate> delegate_; | 167 base::WeakPtr<AutofillPopupDelegate> delegate_; |
| 173 | 168 |
| 174 // The bounds of the Autofill popup. | 169 // The bounds of the Autofill popup. |
| 175 gfx::Rect popup_bounds_; | 170 gfx::Rect popup_bounds_; |
| 176 | 171 |
| 177 // The text direction of the popup. | 172 // The text direction of the popup. |
| 178 base::i18n::TextDirection text_direction_; | 173 base::i18n::TextDirection text_direction_; |
| 179 | 174 |
| 180 // The current Autofill query values. | 175 // The current Autofill query values. |
| 181 std::vector<base::string16> names_; | 176 std::vector<autofill::Suggestion> suggestions_; |
| 182 std::vector<base::string16> subtexts_; | |
| 183 std::vector<base::string16> icons_; | |
| 184 std::vector<int> identifiers_; | |
| 185 | 177 |
| 186 // Since names_ can be elided to ensure that it fits on the screen, we need to | 178 // Elided values and labels corresponding to the suggestions_ vector to |
| 187 // keep an unelided copy of the names to be able to pass to the delegate. | 179 // ensure that it fits on the screen. |
| 188 std::vector<base::string16> full_names_; | 180 std::vector<base::string16> elided_values_; |
| 181 std::vector<base::string16> elided_labels_; |
| 189 | 182 |
| 190 #if !defined(OS_ANDROID) | 183 #if !defined(OS_ANDROID) |
| 191 // The fonts for the popup text. | 184 // The fonts for the popup text. |
| 192 gfx::FontList name_font_list_; | 185 gfx::FontList value_font_list_; |
| 193 gfx::FontList subtext_font_list_; | 186 gfx::FontList label_font_list_; |
| 194 gfx::FontList warning_font_list_; | 187 gfx::FontList warning_font_list_; |
| 195 gfx::FontList title_font_list_; | 188 gfx::FontList title_font_list_; |
| 196 #endif | 189 #endif |
| 197 | 190 |
| 198 // The line that is currently selected by the user. | 191 // The line that is currently selected by the user. |
| 199 // |kNoSelection| indicates that no line is currently selected. | 192 // |kNoSelection| indicates that no line is currently selected. |
| 200 int selected_line_; | 193 int selected_line_; |
| 201 | 194 |
| 202 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; | 195 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; |
| 203 }; | 196 }; |
| 204 | 197 |
| 205 } // namespace autofill | 198 } // namespace autofill |
| 206 | 199 |
| 207 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 200 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| OLD | NEW |