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 3d71a985f6b852e3e650efd9de959ff2a7b7e9c5..ef14d00c22a08235f07bcf8146658cd7ad51ac16 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. |
+static bool g_oopif_enabled; |
Lei Zhang
2017/08/30 02:00:35
Can we initialize this to false, and only enable i
Wei Li
2017/08/31 21:00:25
Done.
|
+ |
+void SetOopifEnabled(bool enabled) { |
+ g_oopif_enabled = enabled; |
+} |
+ |
+bool IsOopifEnabled() { |
+ return g_oopif_enabled; |
+} |
+ |
+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); |
Lei Zhang
2017/08/30 02:00:35
Why do we have to set this once per WebContents?
Wei Li
2017/08/31 21:00:25
We don't need to, but it is easier this way. We ma
|
+ } |
+} |
+ |
void RenderParamsFromPrintSettings(const PrintSettings& settings, |
PrintMsg_Print_Params* params) { |
params->page_size = settings.page_setup_device_units().physical_size(); |
@@ -32,7 +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 = SkiaDocumentType::PDF; |
+ params->printed_doc_type = |
+ IsOopifEnabled() ? SkiaDocumentType::MSKP : SkiaDocumentType::PDF; |
} |
} // namespace printing |