Commit 612358a6 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Add escape hatch for plugins in NavigationClient::CommitNavigation().

The current browser-side navigation code can ask the renderer to commit
a MIME type that it cannot handle. When this happens, the renderer
simply ignores the commit request, tripping the CHECKs added in
https://crrev.com/796508.

For now, allow these commits to silently fail and not commit a new
document...

Bug: 999255, 1115912, 1117282
Change-Id: I435831058db8e059b0389a8e2262f6bd72e875fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360602
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799385}
parent de10ebb1
...@@ -4267,6 +4267,11 @@ void RenderFrameImpl::DidCreateDocumentLoader( ...@@ -4267,6 +4267,11 @@ void RenderFrameImpl::DidCreateDocumentLoader(
} }
} }
void RenderFrameImpl::WillFailCommitNavigation(CommitFailureReason) {
CHECK_EQ(NavigationCommitState::kWillCommit, navigation_commit_state_);
navigation_commit_state_ = NavigationCommitState::kDidCommit;
}
void RenderFrameImpl::DidCommitNavigation( void RenderFrameImpl::DidCommitNavigation(
const blink::WebHistoryItem& item, const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type, blink::WebHistoryCommitType commit_type,
......
...@@ -678,6 +678,7 @@ class CONTENT_EXPORT RenderFrameImpl ...@@ -678,6 +678,7 @@ class CONTENT_EXPORT RenderFrameImpl
void WillSendSubmitEvent(const blink::WebFormElement& form) override; void WillSendSubmitEvent(const blink::WebFormElement& form) override;
void DidCreateDocumentLoader( void DidCreateDocumentLoader(
blink::WebDocumentLoader* document_loader) override; blink::WebDocumentLoader* document_loader) override;
void WillFailCommitNavigation(CommitFailureReason) override;
void DidCommitNavigation(const blink::WebHistoryItem& item, void DidCommitNavigation(const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type, blink::WebHistoryCommitType commit_type,
bool should_reset_browser_interface_broker) override; bool should_reset_browser_interface_broker) override;
......
...@@ -317,6 +317,15 @@ class BLINK_EXPORT WebLocalFrameClient { ...@@ -317,6 +317,15 @@ class BLINK_EXPORT WebLocalFrameClient {
// datasource will become the provisional datasource for the frame. // datasource will become the provisional datasource for the frame.
virtual void DidCreateDocumentLoader(WebDocumentLoader*) {} virtual void DidCreateDocumentLoader(WebDocumentLoader*) {}
// Used to inform the embedder that `WebNavigationControl::CommitNavigation`
// call will fail to commit a new document.
//
// TODO(https://crbug.com/1117282): Remove the need for these exceptions.
enum class CommitFailureReason {
kNoPluginForMimeType,
};
virtual void WillFailCommitNavigation(CommitFailureReason) {}
// The navigation has been committed, as a result of // The navigation has been committed, as a result of
// WebNavigationControl::CommitNavigation call. The newly created document // WebNavigationControl::CommitNavigation call. The newly created document
// is committed to the frame, the encoding of the response body is known, // is committed to the frame, the encoding of the response body is known,
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h" #include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h" #include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h" #include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
...@@ -938,8 +939,13 @@ static bool ShouldNavigate(WebNavigationParams* params, LocalFrame* frame) { ...@@ -938,8 +939,13 @@ static bool ShouldNavigate(WebNavigationParams* params, LocalFrame* frame) {
if (MIMETypeRegistry::IsSupportedMIMEType(mime_type)) if (MIMETypeRegistry::IsSupportedMIMEType(mime_type))
return true; return true;
PluginData* plugin_data = frame->GetPluginData(); PluginData* plugin_data = frame->GetPluginData();
return !mime_type.IsEmpty() && plugin_data && bool can_load_with_plugin = !mime_type.IsEmpty() && plugin_data &&
plugin_data->SupportsMimeType(mime_type); plugin_data->SupportsMimeType(mime_type);
if (!can_load_with_plugin) {
WebLocalFrameImpl::FromFrame(frame)->Client()->WillFailCommitNavigation(
WebLocalFrameClient::CommitFailureReason::kNoPluginForMimeType);
}
return can_load_with_plugin;
} }
void FrameLoader::CommitNavigation( void FrameLoader::CommitNavigation(
......
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