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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/printing/browser/print_manager_utils.cc
diff --git a/components/printing/browser/print_manager_utils.cc b/components/printing/browser/print_manager_utils.cc
index 7be67b197e5a77a7d228e3d0c8ddec6199fe7a6a..7a02cf534cea7daacbe928b079b2883a80948485 100644
--- a/components/printing/browser/print_manager_utils.cc
+++ b/components/printing/browser/print_manager_utils.cc
@@ -3,11 +3,38 @@
// found in the LICENSE file.
#include "components/printing/browser/print_manager_utils.h"
+
+#include "base/command_line.h"
+#include "components/printing/browser/print_composite_client.h"
#include "components/printing/common/print_messages.h"
+#include "content/public/common/content_features.h"
+#include "content/public/common/content_switches.h"
#include "printing/print_settings.h"
namespace printing {
+// A temporary flag which makes supporting both paths for OOPIF and non-OOPIF
+// printing easier.
+base::LazyInstance<bool>::Leaky g_oopif_enabled;
Lei Zhang 2017/08/16 21:17:00 Can this just be a bool?
Wei Li 2017/08/25 23:39:37 Yes, done.
+
+void SetOopifEnabled(bool enabled) {
+ g_oopif_enabled.Get() = enabled;
+}
+
+bool IsOopifEnabled() {
+ return g_oopif_enabled.Get();
+}
+
+void CreateCompositeClientIfNeeded(content::WebContents* web_contents) {
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess) ||
+ base::FeatureList::IsEnabled(features::kTopDocumentIsolation)) {
+ // For cases need to support OOPIFs.
+ PrintCompositeClient::CreateForWebContents(web_contents);
+ SetOopifEnabled(true);
+ }
+}
+
void RenderParamsFromPrintSettings(const PrintSettings& settings,
PrintMsg_Print_Params* params) {
params->page_size = settings.page_setup_device_units().physical_size();
@@ -32,6 +59,8 @@ void RenderParamsFromPrintSettings(const PrintSettings& settings,
params->display_header_footer = settings.display_header_footer();
params->title = settings.title();
params->url = settings.url();
+ params->printed_doc_type =
+ IsOopifEnabled() ? SkiaDocumentType::MSKP : SkiaDocumentType::PDF;
}
} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698