Commit 6024ffbd authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Autofill] Introduce AutofillPopupViewDelegate::GetWebContents()

Follow up CL will make use of this API.

Bug: 1108181
Change-Id: I931e2aac81ff5164b129c8556b0bb27d1e15fc6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333835Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794660}
parent 87363cc1
...@@ -188,6 +188,10 @@ gfx::NativeView AutofillKeyboardAccessoryAdapter::container_view() const { ...@@ -188,6 +188,10 @@ gfx::NativeView AutofillKeyboardAccessoryAdapter::container_view() const {
return controller_->container_view(); return controller_->container_view();
} }
content::WebContents* AutofillKeyboardAccessoryAdapter::GetWebContents() const {
return controller_->GetWebContents();
}
const gfx::RectF& AutofillKeyboardAccessoryAdapter::element_bounds() const { const gfx::RectF& AutofillKeyboardAccessoryAdapter::element_bounds() const {
DCHECK(controller_) << "Call OnSuggestionsChanged only from its owner!"; DCHECK(controller_) << "Call OnSuggestionsChanged only from its owner!";
return controller_->element_bounds(); return controller_->element_bounds();
......
...@@ -82,6 +82,7 @@ class AutofillKeyboardAccessoryAdapter : public AutofillPopupView, ...@@ -82,6 +82,7 @@ class AutofillKeyboardAccessoryAdapter : public AutofillPopupView,
void ViewDestroyed() override; void ViewDestroyed() override;
void SelectionCleared() override; void SelectionCleared() override;
gfx::NativeView container_view() const override; gfx::NativeView container_view() const override;
content::WebContents* GetWebContents() const override;
const gfx::RectF& element_bounds() const override; const gfx::RectF& element_bounds() const override;
bool IsRTL() const override; bool IsRTL() const override;
std::vector<Suggestion> GetSuggestions() const override; std::vector<Suggestion> GetSuggestions() const override;
......
...@@ -34,6 +34,7 @@ class MockAutofillPopupController ...@@ -34,6 +34,7 @@ class MockAutofillPopupController
MOCK_CONST_METHOD0(HasSelection, bool()); MOCK_CONST_METHOD0(HasSelection, bool());
MOCK_CONST_METHOD0(popup_bounds, gfx::Rect()); MOCK_CONST_METHOD0(popup_bounds, gfx::Rect());
MOCK_CONST_METHOD0(container_view, gfx::NativeView()); MOCK_CONST_METHOD0(container_view, gfx::NativeView());
MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
const gfx::RectF& element_bounds() const override { const gfx::RectF& element_bounds() const override {
static base::NoDestructor<gfx::RectF> bounds({100, 100, 250, 50}); static base::NoDestructor<gfx::RectF> bounds({100, 100, 250, 50});
return *bounds; return *bounds;
......
...@@ -290,6 +290,10 @@ gfx::NativeView AutofillPopupControllerImpl::container_view() const { ...@@ -290,6 +290,10 @@ gfx::NativeView AutofillPopupControllerImpl::container_view() const {
return controller_common_.container_view; return controller_common_.container_view;
} }
content::WebContents* AutofillPopupControllerImpl::GetWebContents() const {
return web_contents_;
}
const gfx::RectF& AutofillPopupControllerImpl::element_bounds() const { const gfx::RectF& AutofillPopupControllerImpl::element_bounds() const {
return controller_common_.element_bounds; return controller_common_.element_bounds;
} }
......
...@@ -92,6 +92,7 @@ class AutofillPopupControllerImpl : public AutofillPopupController { ...@@ -92,6 +92,7 @@ class AutofillPopupControllerImpl : public AutofillPopupController {
void SelectionCleared() override; void SelectionCleared() override;
gfx::NativeView container_view() const override; gfx::NativeView container_view() const override;
content::WebContents* GetWebContents() const override;
const gfx::RectF& element_bounds() const override; const gfx::RectF& element_bounds() const override;
void SetElementBounds(const gfx::RectF& bounds); void SetElementBounds(const gfx::RectF& bounds);
bool IsRTL() const override; bool IsRTL() const override;
......
...@@ -16,8 +16,11 @@ namespace gfx { ...@@ -16,8 +16,11 @@ namespace gfx {
class Point; class Point;
class Rect; class Rect;
class RectF; class RectF;
} } // namespace gfx
namespace content {
class WebContents;
} // namespace content
namespace autofill { namespace autofill {
// Base class for Controllers of Autofill-style popups. This interface is // Base class for Controllers of Autofill-style popups. This interface is
...@@ -39,6 +42,9 @@ class AutofillPopupViewDelegate { ...@@ -39,6 +42,9 @@ class AutofillPopupViewDelegate {
// The view that the form field element sits in. // The view that the form field element sits in.
virtual gfx::NativeView container_view() const = 0; virtual gfx::NativeView container_view() const = 0;
// The web contents the form field element sits in.
virtual content::WebContents* GetWebContents() const = 0;
// The bounds of the form field element (screen coordinates). // The bounds of the form field element (screen coordinates).
virtual const gfx::RectF& element_bounds() const = 0; virtual const gfx::RectF& element_bounds() const = 0;
......
...@@ -49,6 +49,7 @@ class MockAutofillPopupController : public autofill::AutofillPopupController { ...@@ -49,6 +49,7 @@ class MockAutofillPopupController : public autofill::AutofillPopupController {
MOCK_CONST_METHOD0(HasSelection, bool()); MOCK_CONST_METHOD0(HasSelection, bool());
MOCK_CONST_METHOD0(popup_bounds, gfx::Rect()); MOCK_CONST_METHOD0(popup_bounds, gfx::Rect());
MOCK_CONST_METHOD0(container_view, gfx::NativeView()); MOCK_CONST_METHOD0(container_view, gfx::NativeView());
MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
MOCK_CONST_METHOD0(element_bounds, const gfx::RectF&()); MOCK_CONST_METHOD0(element_bounds, const gfx::RectF&());
MOCK_CONST_METHOD0(IsRTL, bool()); MOCK_CONST_METHOD0(IsRTL, bool());
std::vector<autofill::Suggestion> GetSuggestions() const override { std::vector<autofill::Suggestion> GetSuggestions() const override {
......
...@@ -306,6 +306,11 @@ gfx::NativeView PasswordGenerationPopupControllerImpl::container_view() const { ...@@ -306,6 +306,11 @@ gfx::NativeView PasswordGenerationPopupControllerImpl::container_view() const {
return controller_common_.container_view; return controller_common_.container_view;
} }
content::WebContents* PasswordGenerationPopupControllerImpl::GetWebContents()
const {
return WebContentsObserver::web_contents();
}
const gfx::RectF& PasswordGenerationPopupControllerImpl::element_bounds() const gfx::RectF& PasswordGenerationPopupControllerImpl::element_bounds()
const { const {
return controller_common_.element_bounds; return controller_common_.element_bounds;
......
...@@ -133,6 +133,7 @@ class PasswordGenerationPopupControllerImpl ...@@ -133,6 +133,7 @@ class PasswordGenerationPopupControllerImpl
void SetSelected() override; void SetSelected() override;
void PasswordAccepted() override; void PasswordAccepted() override;
gfx::NativeView container_view() const override; gfx::NativeView container_view() const override;
content::WebContents* GetWebContents() const override;
const gfx::RectF& element_bounds() const override; const gfx::RectF& element_bounds() const override;
bool IsRTL() const override; bool IsRTL() const override;
......
...@@ -40,6 +40,7 @@ class MockAutofillPopupViewDelegate : public AutofillPopupViewDelegate { ...@@ -40,6 +40,7 @@ class MockAutofillPopupViewDelegate : public AutofillPopupViewDelegate {
// TODO(jdduke): Mock this method upon resolution of crbug.com/352463. // TODO(jdduke): Mock this method upon resolution of crbug.com/352463.
MOCK_CONST_METHOD0(popup_bounds, gfx::Rect()); MOCK_CONST_METHOD0(popup_bounds, gfx::Rect());
MOCK_CONST_METHOD0(container_view, gfx::NativeView()); MOCK_CONST_METHOD0(container_view, gfx::NativeView());
MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
MOCK_CONST_METHOD0(element_bounds, gfx::RectF&()); MOCK_CONST_METHOD0(element_bounds, gfx::RectF&());
MOCK_CONST_METHOD0(IsRTL, bool()); MOCK_CONST_METHOD0(IsRTL, bool());
}; };
...@@ -63,15 +64,10 @@ class AutofillPopupBaseViewTest : public InProcessBrowserTest { ...@@ -63,15 +64,10 @@ class AutofillPopupBaseViewTest : public InProcessBrowserTest {
browser()->window()->GetNativeWindow())); browser()->window()->GetNativeWindow()));
} }
void ShowView() { void ShowView() { view_->DoShow(); }
view_->DoShow();
}
ui::GestureEvent CreateGestureEvent(ui::EventType type, gfx::Point point) { ui::GestureEvent CreateGestureEvent(ui::EventType type, gfx::Point point) {
return ui::GestureEvent(point.x(), return ui::GestureEvent(point.x(), point.y(), 0, ui::EventTimeForNow(),
point.y(),
0,
ui::EventTimeForNow(),
ui::GestureEventDetails(type)); ui::GestureEventDetails(type));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment