Commit dbed11f1 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

CHECK that messages are not forwarded from RenderView to RenderWidget.

Widget messages should be directly sent to RenderWidgets rather than
relying on fallback from RenderView. This adds a CHECK() to enforce that
and validate that nothing too insane is happening in the wild. Assuming
nothing goes wrong, the CHECK() will be removed in a week or so.

Bug: 419087
Change-Id: I0aa21020931fa907db64a71a3e8d189e7ffa1f8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733028
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683864}
parent 8647c770
......@@ -690,7 +690,9 @@ void RenderViewTest::Resize(gfx::Size new_size,
visual_properties.display_mode = blink::kWebDisplayModeBrowser;
std::unique_ptr<IPC::Message> resize_message(
new WidgetMsg_SynchronizeVisualProperties(0, visual_properties));
OnMessageReceived(*resize_message);
RenderWidget* render_widget =
static_cast<RenderViewImpl*>(view_)->GetWidget();
render_widget->OnMessageReceived(*resize_message);
}
void RenderViewTest::SimulateUserTypingASCIICharacter(char ascii_character,
......@@ -743,11 +745,6 @@ void RenderViewTest::SimulateUserInputChangeForElement(
base::RunLoop().RunUntilIdle();
}
bool RenderViewTest::OnMessageReceived(const IPC::Message& msg) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
return impl->OnMessageReceived(msg);
}
void RenderViewTest::OnSameDocumentNavigation(blink::WebLocalFrame* frame,
bool is_new_navigation) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
......
......@@ -180,7 +180,6 @@ class RenderViewTest : public testing::Test {
const std::string& new_value);
// These are all methods from RenderViewImpl that we expose to testing code.
bool OnMessageReceived(const IPC::Message& msg);
void OnSameDocumentNavigation(blink::WebLocalFrame* frame,
bool is_new_navigation);
blink::WebWidget* GetWebWidget();
......
......@@ -1309,7 +1309,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
// Have the widget handle all other messages.
// TODO(ajwong): Remove this cross-object dispatch.
IPC_MESSAGE_UNHANDLED(handled = GetWidget()->OnMessageReceived(message))
IPC_MESSAGE_UNHANDLED(handled = ForwardToWidgetAndCheckIfHandled(message))
IPC_END_MESSAGE_MAP()
return handled;
......@@ -2274,4 +2274,13 @@ RenderViewImpl::GetCleanupTaskRunner() {
->CleanupTaskRunner();
}
bool RenderViewImpl::ForwardToWidgetAndCheckIfHandled(
const IPC::Message& message) {
// TODO(https://crbug.com/990607): This CHECK is temporary and will be
// removed, assuming nothing crashes in the wild.
bool handled = GetWidget()->OnMessageReceived(message);
CHECK(!handled);
return handled;
}
} // namespace content
......@@ -513,6 +513,8 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
void UpdateThemePrefs() {}
#endif
bool ForwardToWidgetAndCheckIfHandled(const IPC::Message& message);
// ---------------------------------------------------------------------------
// ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
// it in the same order in the .cc file as it was in the header.
......
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