diff options
author | estade <estade@chromium.org> | 2015-01-21 06:12:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-21 14:14:29 +0000 |
commit | d0a0c992fc0eb9c81d514a256a5c0eb7928efea6 (patch) | |
tree | c3f2161963f79d5801ec361231e059dc4f430863 | |
parent | b43e6cc69ecb0049bbcd84b41cd13847cd01bc4b (diff) | |
download | chromium_src-d0a0c992fc0eb9c81d514a256a5c0eb7928efea6.zip chromium_src-d0a0c992fc0eb9c81d514a256a5c0eb7928efea6.tar.gz chromium_src-d0a0c992fc0eb9c81d514a256a5c0eb7928efea6.tar.bz2 |
Remove RenderViewObserver::Resized (try 2)
The only client was AutofillAgent; reimplement the functionality in a slightly different way. While we're at it, fix a bug where the browser-owned popup is hidden without the renderer's knowledge.
BUG=433486,449325
Review URL: https://codereview.chromium.org/854943002
Cr-Commit-Position: refs/heads/master@{#312346}
18 files changed, 56 insertions, 21 deletions
diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc index da0ebca..47b8219 100644 --- a/chrome/browser/ui/autofill/chrome_autofill_client.cc +++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc @@ -219,6 +219,10 @@ void ChromeAutofillClient::DidNavigateAnyFrame( HideRequestAutocompleteDialog(); } +void ChromeAutofillClient::MainFrameWasResized() { + HideAutofillPopup(); +} + void ChromeAutofillClient::WebContentsDestroyed() { HideAutofillPopup(); } diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.h b/chrome/browser/ui/autofill/chrome_autofill_client.h index 4017e02..28f1032 100644 --- a/chrome/browser/ui/autofill/chrome_autofill_client.h +++ b/chrome/browser/ui/autofill/chrome_autofill_client.h @@ -82,6 +82,7 @@ class ChromeAutofillClient content::RenderFrameHost* render_frame_host, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) override; + void MainFrameWasResized() override; void WebContentsDestroyed() override; // ZoomObserver implementation. diff --git a/components/autofill/content/browser/content_autofill_driver.cc b/components/autofill/content/browser/content_autofill_driver.cc index bae84ee..d21db43 100644 --- a/components/autofill/content/browser/content_autofill_driver.cc +++ b/components/autofill/content/browser/content_autofill_driver.cc @@ -145,6 +145,13 @@ void ContentAutofillDriver::RendererShouldPreviewFieldWithValue( render_frame_host_->GetRoutingID(), value)); } +void ContentAutofillDriver::PopupHidden() { + if (!RendererIsAvailable()) + return; + render_frame_host_->Send( + new AutofillMsg_PopupHidden(render_frame_host_->GetRoutingID())); +} + bool ContentAutofillDriver::HandleMessage(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ContentAutofillDriver, message) diff --git a/components/autofill/content/browser/content_autofill_driver.h b/components/autofill/content/browser/content_autofill_driver.h index cb35d81..98bac40 100644 --- a/components/autofill/content/browser/content_autofill_driver.h +++ b/components/autofill/content/browser/content_autofill_driver.h @@ -61,6 +61,7 @@ class ContentAutofillDriver : public AutofillDriver { void RendererShouldFillFieldWithValue(const base::string16& value) override; void RendererShouldPreviewFieldWithValue( const base::string16& value) override; + void PopupHidden() override; // Handles a message that came from the associated render frame. bool HandleMessage(const IPC::Message& message); diff --git a/components/autofill/content/common/autofill_messages.h b/components/autofill/content/common/autofill_messages.h index bc2e5af..94a2748 100644 --- a/components/autofill/content/common/autofill_messages.h +++ b/components/autofill/content/common/autofill_messages.h @@ -155,6 +155,9 @@ IPC_MESSAGE_ROUTED1(AutofillMsg_FillFieldWithValue, IPC_MESSAGE_ROUTED1(AutofillMsg_PreviewFieldWithValue, base::string16 /* value */) +// The popup has been hidden. +IPC_MESSAGE_ROUTED0(AutofillMsg_PopupHidden); + // Sets the currently selected node's value to be the given data list value. IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptDataListSuggestion, base::string16 /* accepted data list value */) diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc index 6afbd4c..2c48d11 100644 --- a/components/autofill/content/renderer/autofill_agent.cc +++ b/components/autofill/content/renderer/autofill_agent.cc @@ -172,6 +172,7 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { OnFillPasswordSuggestion) IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, OnPreviewPasswordSuggestion) + IPC_MESSAGE_HANDLER(AutofillMsg_PopupHidden, OnPopupHidden) IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, OnRequestAutocompleteResult) IPC_MESSAGE_UNHANDLED(handled = false) @@ -234,10 +235,6 @@ void AutofillAgent::FocusedNodeChanged(const WebNode& node) { element_ = *element; } -void AutofillAgent::Resized() { - HidePopup(); -} - void AutofillAgent::didRequestAutocomplete( const WebFormElement& form) { DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); @@ -550,6 +547,11 @@ void AutofillAgent::OnPreviewPasswordSuggestion( DCHECK(handled); } +void AutofillAgent::OnPopupHidden() { + if (!element_.isNull()) + OnClearPreviewedForm(); +} + void AutofillAgent::OnRequestAutocompleteResult( WebFormElement::AutocompleteResult result, const base::string16& message, @@ -740,10 +742,6 @@ void AutofillAgent::ProcessForms() { void AutofillAgent::HidePopup() { if (!is_popup_possibly_visible_) return; - - if (!element_.isNull()) - OnClearPreviewedForm(); - is_popup_possibly_visible_ = false; Send(new AutofillHostMsg_HidePopup(routing_id())); } @@ -785,8 +783,4 @@ void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( agent_->FocusedNodeChanged(node); } -void AutofillAgent::LegacyAutofillAgent::Resized() { - agent_->Resized(); -} - } // namespace autofill diff --git a/components/autofill/content/renderer/autofill_agent.h b/components/autofill/content/renderer/autofill_agent.h index ea90fd9..13c35ad 100644 --- a/components/autofill/content/renderer/autofill_agent.h +++ b/components/autofill/content/renderer/autofill_agent.h @@ -67,7 +67,6 @@ class AutofillAgent : public content::RenderFrameObserver, // content::RenderViewObserver: void OnDestruct() override; void FocusedNodeChanged(const blink::WebNode& node) override; - void Resized() override; AutofillAgent* agent_; @@ -115,10 +114,9 @@ class AutofillAgent : public content::RenderFrameObserver, void WillSubmitForm(const blink::WebFormElement& form) override; void DidChangeScrollOffset() override; - // Pass-throughs from LegacyAutofillAgent. These correlate with - // RenderViewObserver methods. + // Pass-through from LegacyAutofillAgent. This correlates with the + // RenderViewObserver method. void FocusedNodeChanged(const blink::WebNode& node); - void Resized(); // PageClickListener: void FormControlElementClicked(const blink::WebFormControlElement& element, @@ -158,6 +156,7 @@ class AutofillAgent : public content::RenderFrameObserver, const base::string16& password); void OnPreviewPasswordSuggestion(const base::string16& username, const base::string16& password); + void OnPopupHidden(); // Called when interactive autocomplete finishes. |message| is printed to // the console if non-empty. diff --git a/components/autofill/core/browser/autofill_driver.h b/components/autofill/core/browser/autofill_driver.h index b690191..368f1f4 100644 --- a/components/autofill/core/browser/autofill_driver.h +++ b/components/autofill/core/browser/autofill_driver.h @@ -89,6 +89,9 @@ class AutofillDriver { // Tells the renderer to preview the node with suggested text. virtual void RendererShouldPreviewFieldWithValue( const base::string16& value) = 0; + + // Informs the renderer that the popup has been hidden. + virtual void PopupHidden() = 0; }; } // namespace autofill diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc index 8eac4f0..85e6cdf 100644 --- a/components/autofill/core/browser/autofill_external_delegate.cc +++ b/components/autofill/core/browser/autofill_external_delegate.cc @@ -190,6 +190,7 @@ void AutofillExternalDelegate::OnPopupShown() { } void AutofillExternalDelegate::OnPopupHidden() { + driver_->PopupHidden(); } void AutofillExternalDelegate::DidSelectSuggestion( diff --git a/components/autofill/core/browser/test_autofill_driver.cc b/components/autofill/core/browser/test_autofill_driver.cc index 76bb9d5..6c978a5 100644 --- a/components/autofill/core/browser/test_autofill_driver.cc +++ b/components/autofill/core/browser/test_autofill_driver.cc @@ -73,4 +73,7 @@ void TestAutofillDriver::RendererShouldPreviewFieldWithValue( const base::string16& value) { } +void TestAutofillDriver::PopupHidden() { +} + } // namespace autofill diff --git a/components/autofill/core/browser/test_autofill_driver.h b/components/autofill/core/browser/test_autofill_driver.h index 11f06ff..35fb8ec 100644 --- a/components/autofill/core/browser/test_autofill_driver.h +++ b/components/autofill/core/browser/test_autofill_driver.h @@ -44,6 +44,7 @@ class TestAutofillDriver : public AutofillDriver { void RendererShouldFillFieldWithValue(const base::string16& value) override; void RendererShouldPreviewFieldWithValue( const base::string16& value) override; + void PopupHidden() override; // Methods that tests can use to specialize functionality. diff --git a/content/browser/renderer_host/render_widget_host_delegate.h b/content/browser/renderer_host/render_widget_host_delegate.h index 669dc25..b68d72d 100644 --- a/content/browser/renderer_host/render_widget_host_delegate.h +++ b/content/browser/renderer_host/render_widget_host_delegate.h @@ -34,6 +34,10 @@ class CONTENT_EXPORT RenderWidgetHostDelegate { // The RenderWidgetHost got the focus. virtual void RenderWidgetGotFocus(RenderWidgetHostImpl* render_widget_host) {} + // The RenderWidget was resized. + virtual void RenderWidgetWasResized( + RenderWidgetHostImpl* render_widget_host) {} + // Callback to give the browser a chance to handle the specified keyboard // event before sending it to the renderer. // Returns true if the |event| was handled. Otherwise, if the |event| would diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 2d695c3..25b1fcd 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -637,6 +637,9 @@ void RenderWidgetHostImpl::WasResized() { } else { old_resize_params_.swap(params); } + + if (delegate_) + delegate_->RenderWidgetWasResized(this); } void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 5b891f5..64c7bcd 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -1338,6 +1338,17 @@ void WebContentsImpl::RenderWidgetGotFocus( delegate_->WebContentsFocused(this); } +void WebContentsImpl::RenderWidgetWasResized( + RenderWidgetHostImpl* render_widget_host) { + if (render_widget_host != + static_cast<RenderFrameHostImpl*>(GetMainFrame()) + ->GetRenderWidgetHost()) { + return; + } + + FOR_EACH_OBSERVER(WebContentsObserver, observers_, MainFrameWasResized()); +} + bool WebContentsImpl::PreHandleKeyboardEvent( const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 0f56ad4..5db6b0d 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -535,6 +535,8 @@ class CONTENT_EXPORT WebContentsImpl void RenderWidgetDeleted(RenderWidgetHostImpl* render_widget_host) override; void RenderWidgetGotFocus(RenderWidgetHostImpl* render_widget_host) override; + void RenderWidgetWasResized( + RenderWidgetHostImpl* render_widget_host) override; bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) override; void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override; diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h index 9dc5fb4..6f49e91 100644 --- a/content/public/browser/web_contents_observer.h +++ b/content/public/browser/web_contents_observer.h @@ -254,6 +254,9 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, virtual void WasShown() {} virtual void WasHidden() {} + // Invoked when the main frame changes size. + virtual void MainFrameWasResized() {} + // This methods is invoked when the title of the WebContents is set. If the // title was explicitly set, |explicit_set| is true, otherwise the title was // synthesized and |explicit_set| is false. diff --git a/content/public/renderer/render_view_observer.h b/content/public/renderer/render_view_observer.h index 610bd5f..9b8c71e 100644 --- a/content/public/renderer/render_view_observer.h +++ b/content/public/renderer/render_view_observer.h @@ -89,7 +89,6 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Listener, // These match incoming IPCs. virtual void Navigate(const GURL& url) {} virtual void ClosePage() {} - virtual void Resized() {} virtual void OnStop() {} diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 1a17cdd..851e81c 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -3176,10 +3176,6 @@ void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { if (old_visible_viewport_size != visible_viewport_size_) has_scrolled_focused_editable_node_into_rect_ = false; - - FOR_EACH_OBSERVER(RenderViewObserver, - observers_, - Resized()); } void RenderViewImpl::DidInitiatePaint() { |