Commit 335f3d63 authored by sammc's avatar sammc Committed by Commit bot

Ignore the default zoom level for the PDF extension and print preview.

Previously, the PDF extension UI was zoomed to the default zoom level
and the PDF was inversely affected (due to various calculations using
zoomed and not zoomed sizes). This resets the zoom level for extensions
used as mime handlers on mime handler WebContents creation and for print
preview (as the PDF extension zoom as controlled by the embedding print
preview dialog WebContents.

BUG=450910

Review URL: https://codereview.chromium.org/881553003

Cr-Commit-Position: refs/heads/master@{#313444}
parent ea5b158e
......@@ -28,6 +28,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
......@@ -384,6 +385,13 @@ WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
initiator);
WebContents* preview_dialog = web_dialog_delegate->GetWebContents();
// Clear the zoom level for the print preview dialog so it isn't affected by
// the default zoom level. This also controls the zoom level of the OOP PDF
// extension when iframed by the print preview dialog.
GURL print_url(chrome::kChromeUIPrintURL);
content::HostZoomMap::Get(preview_dialog->GetSiteInstance())
->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0);
EnableInternalPDFPluginForContents(preview_dialog);
PrintViewManager::CreateForWebContents(preview_dialog);
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
......
......@@ -6,6 +6,7 @@
#include "base/strings/stringprintf.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/browser/stream_info.h"
......@@ -18,6 +19,7 @@
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_constants.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/guest_view/guest_view_constants.h"
#include "extensions/strings/grit/extensions_strings.h"
......@@ -123,8 +125,15 @@ void MimeHandlerViewGuest::CreateWebContents(
// goes under the same process as the extension.
ProcessManager* process_manager = ProcessManager::Get(browser_context());
content::SiteInstance* guest_site_instance =
process_manager->GetSiteInstanceForURL(
Extension::GetBaseURLFromExtensionId(GetOwnerSiteURL().host()));
process_manager->GetSiteInstanceForURL(stream_->handler_url());
// Clear the zoom level for the mime handler extension. The extension is
// responsible for managing its own zoom. This is necessary for OOP PDF, as
// otherwise the UI is zoomed and the calculations to determine the PDF size
// mix zoomed and unzoomed units.
content::HostZoomMap::Get(guest_site_instance)
->SetZoomLevelForHostAndScheme(kExtensionScheme, stream_->extension_id(),
0);
WebContents::CreateParams params(browser_context(), guest_site_instance);
params.guest_delegate = this;
......
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