Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: components/printing/browser/print_manager_utils.cc

Issue 2920013002: Use pdf compositor service for printing when OOPIF is enabled
Patch Set: rebase Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/printing/browser/print_manager_utils.h" 5 #include "components/printing/browser/print_manager_utils.h"
6
7 #include "base/command_line.h"
8 #include "components/printing/browser/print_composite_client.h"
6 #include "components/printing/common/print_messages.h" 9 #include "components/printing/common/print_messages.h"
10 #include "content/public/common/content_features.h"
11 #include "content/public/common/content_switches.h"
7 #include "printing/print_settings.h" 12 #include "printing/print_settings.h"
8 13
9 namespace printing { 14 namespace printing {
10 15
16 // A temporary flag which makes supporting both paths for OOPIF and non-OOPIF
17 // printing easier.
18 static bool g_oopif_enabled = false;
19
20 void SetOopifEnabled() {
21 g_oopif_enabled = true;
22 }
23
24 bool IsOopifEnabled() {
25 return g_oopif_enabled;
26 }
27
28 void CreateCompositeClientIfNeeded(content::WebContents* web_contents) {
29 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kSitePerProcess) ||
31 base::FeatureList::IsEnabled(features::kTopDocumentIsolation)) {
32 // For cases need to support OOPIFs.
33 PrintCompositeClient::CreateForWebContents(web_contents);
34 SetOopifEnabled();
35 }
36 }
37
11 void RenderParamsFromPrintSettings(const PrintSettings& settings, 38 void RenderParamsFromPrintSettings(const PrintSettings& settings,
12 PrintMsg_Print_Params* params) { 39 PrintMsg_Print_Params* params) {
13 params->page_size = settings.page_setup_device_units().physical_size(); 40 params->page_size = settings.page_setup_device_units().physical_size();
14 params->content_size.SetSize( 41 params->content_size.SetSize(
15 settings.page_setup_device_units().content_area().width(), 42 settings.page_setup_device_units().content_area().width(),
16 settings.page_setup_device_units().content_area().height()); 43 settings.page_setup_device_units().content_area().height());
17 params->printable_area.SetRect( 44 params->printable_area.SetRect(
18 settings.page_setup_device_units().printable_area().x(), 45 settings.page_setup_device_units().printable_area().x(),
19 settings.page_setup_device_units().printable_area().y(), 46 settings.page_setup_device_units().printable_area().y(),
20 settings.page_setup_device_units().printable_area().width(), 47 settings.page_setup_device_units().printable_area().width(),
21 settings.page_setup_device_units().printable_area().height()); 48 settings.page_setup_device_units().printable_area().height());
22 params->margin_top = settings.page_setup_device_units().content_area().y(); 49 params->margin_top = settings.page_setup_device_units().content_area().y();
23 params->margin_left = settings.page_setup_device_units().content_area().x(); 50 params->margin_left = settings.page_setup_device_units().content_area().x();
24 params->dpi = settings.dpi(); 51 params->dpi = settings.dpi();
25 params->scale_factor = settings.scale_factor(); 52 params->scale_factor = settings.scale_factor();
26 params->rasterize_pdf = settings.rasterize_pdf(); 53 params->rasterize_pdf = settings.rasterize_pdf();
27 // Always use an invalid cookie. 54 // Always use an invalid cookie.
28 params->document_cookie = 0; 55 params->document_cookie = 0;
29 params->selection_only = settings.selection_only(); 56 params->selection_only = settings.selection_only();
30 params->supports_alpha_blend = settings.supports_alpha_blend(); 57 params->supports_alpha_blend = settings.supports_alpha_blend();
31 params->should_print_backgrounds = settings.should_print_backgrounds(); 58 params->should_print_backgrounds = settings.should_print_backgrounds();
32 params->display_header_footer = settings.display_header_footer(); 59 params->display_header_footer = settings.display_header_footer();
33 params->title = settings.title(); 60 params->title = settings.title();
34 params->url = settings.url(); 61 params->url = settings.url();
35 params->printed_doc_type = SkiaDocumentType::PDF; 62 params->printed_doc_type =
63 IsOopifEnabled() ? SkiaDocumentType::MSKP : SkiaDocumentType::PDF;
36 } 64 }
37 65
38 } // namespace printing 66 } // namespace printing
OLDNEW
« no previous file with comments | « components/printing/browser/print_manager_utils.h ('k') | headless/lib/browser/headless_web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698