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

Unified 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: Uses base::Optional<size_t> instead of representing no selection as -1. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_popup_controller_impl.h
diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.h b/chrome/browser/ui/autofill/autofill_popup_controller_impl.h
index e3332b51f00d49f50a74b5c06df29046052c63ae..8cfe91f355fe77b467753fdebe245c395c9eb8c3 100644
--- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.h
+++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.h
@@ -10,11 +10,13 @@
#include "base/gtest_prod_util.h"
#include "base/i18n/rtl.h"
#include "base/memory/weak_ptr.h"
+#include "base/optional.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
#include "chrome/browser/ui/autofill/popup_controller_common.h"
+#include "ui/accessibility/ax_enums.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/native_theme/native_theme.h"
@@ -72,11 +74,9 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
~AutofillPopupControllerImpl() override;
// AutofillPopupViewDelegate implementation.
- void UpdateBoundsAndRedrawPopup() override;
void SetSelectionAtPoint(const gfx::Point& point) override;
bool AcceptSelectedLine() override;
void SelectionCleared() override;
- void AcceptSuggestion(size_t index) override;
gfx::Rect popup_bounds() const override;
gfx::NativeView container_view() override;
const gfx::RectF& element_bounds() const override;
@@ -88,6 +88,8 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
#endif
// AutofillPopupController implementation.
+ void OnSuggestionsChanged() override;
+ void AcceptSuggestion(size_t index) override;
size_t GetLineCount() const override;
const autofill::Suggestion& GetSuggestionAt(size_t row) const override;
const base::string16& GetElidedValueAt(size_t row) const override;
@@ -97,13 +99,13 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
base::string16* body) override;
bool RemoveSuggestion(int list_index) override;
ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const override;
- int selected_line() const override;
+ base::Optional<size_t> selected_line() const override;
Evan Stade 2017/03/16 17:39:00 is this called from somewhere?
csashi 2017/03/16 22:42:05 Currently only from the tests.
const AutofillPopupLayoutModel& layout_model() const override;
content::WebContents* web_contents();
// Change which line is currently selected by the user.
- void SetSelectedLine(int selected_line);
+ void SetSelectedLine(base::Optional<size_t> selected_line);
// Increase the selected line by 1, properly handling wrapping.
void SelectNextLine();
@@ -126,10 +128,6 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
AutofillPopupView* view() { return view_; }
- // |view_| pass throughs (virtual for testing).
- virtual void ShowView();
- virtual void InvalidateRow(size_t row);
-
base::WeakPtr<AutofillPopupControllerImpl> GetWeakPtr();
// Contains common popup functionality such as popup layout. Protected for
@@ -139,7 +137,6 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
private:
#if !defined(OS_ANDROID)
FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, ElideText);
-
// Helper method which elides the value and label for the suggestion at |row|
// given the |available_width|. Puts the results in |elided_values_| and
// |elided_labels_|.
@@ -150,6 +147,9 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
// when the popup is reused it doesn't leak values between uses.
void ClearState();
+ friend class AutofillPopupControllerUnitTest;
+ void SetViewForTesting(AutofillPopupView* view) { view_ = view; }
+
AutofillPopupView* view_; // Weak reference.
AutofillPopupLayoutModel layout_model_;
base::WeakPtr<AutofillPopupDelegate> delegate_;
@@ -165,9 +165,9 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
std::vector<base::string16> elided_values_;
std::vector<base::string16> elided_labels_;
- // The line that is currently selected by the user.
- // |kNoSelection| indicates that no line is currently selected.
- int selected_line_;
+ // The line that is currently selected by the user, null indicates that no
+ // line is currently selected.
+ base::Optional<size_t> selected_line_;
base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_;
};

Powered by Google App Engine
This is Rietveld 408576698