Commit 2b604d8b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Don't preload PDF page

On iOS 13, when preloading a PDF, the WebView is getting the focus,
preventing the user from typing in the omnibox.
This CL fixes it by not pre-loading the PDF pages.

Bug: 1017352
Change-Id: Ifd787ee57458df61381fff65eea3b6ed858da874
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1892215Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712546}
parent d8bb6214
......@@ -403,14 +403,19 @@ class PreloadJavaScriptDialogPresenter : public web::JavaScriptDialogPresenter {
#pragma mark - CRWWebStateObserver
- (void)webState:(web::WebState*)webState
didFinishNavigation:(web::NavigationContext*)navigation {
DCHECK_EQ(webState, _webState.get());
if ([self shouldCancelPreloadForMimeType:webState->GetContentsMimeType()])
[self schedulePrerenderCancel];
}
- (void)webState:(web::WebState*)webState
didLoadPageWithSuccess:(BOOL)loadSuccess {
DCHECK_EQ(webState, _webState.get());
// Cancel prerendering if response is "application/octet-stream". It can be a
// video file which should not be played from preload tab. See issue at
// http://crbug.com/436813 for more details.
const std::string& mimeType = webState->GetContentsMimeType();
if (mimeType == "application/octet-stream")
// The load should have been cancelled when the navigation finishes, but this
// makes sure that we didn't miss one.
if ([self shouldCancelPreloadForMimeType:webState->GetContentsMimeType()])
[self schedulePrerenderCancel];
}
......@@ -485,6 +490,16 @@ class PreloadJavaScriptDialogPresenter : public web::JavaScriptDialogPresenter {
#pragma mark - Cancellation Helpers
- (BOOL)shouldCancelPreloadForMimeType:(std::string)mimeType {
// Cancel prerendering if response is "application/octet-stream". It can be a
// video file which should not be played from preload tab. See issue at
// http://crbug.com/436813 for more details.
// On iOS 13, PDF are getting focused when loaded, preventing the user from
// typing in the omnibox. See crbug.com/1017352.
return mimeType == "application/octet-stream" ||
mimeType == "application/pdf";
}
- (void)removeScheduledPrerenderRequests {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
_scheduledRequest = nullptr;
......
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