diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-09-18 14:34:04 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-10-04 11:15:27 +0000 |
commit | e6430e577f105ad8813c92e75c54660c4985026e (patch) | |
tree | 88115e5d1fb471fea807111924dcccbeadbf9e4f /chromium/components/printing | |
parent | 53d399fe6415a96ea6986ec0d402a9c07da72453 (diff) | |
download | qtwebengine-chromium-e6430e577f105ad8813c92e75c54660c4985026e.tar.gz |
BASELINE: Update Chromium to 61.0.3163.99
Change-Id: I8452f34574d88ca2b27af9bd56fc9ff3f16b1367
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/printing')
8 files changed, 54 insertions, 47 deletions
diff --git a/chromium/components/printing/browser/print_manager.cc b/chromium/components/printing/browser/print_manager.cc index 1094a260bb6..6dbe709f01f 100644 --- a/chromium/components/printing/browser/print_manager.cc +++ b/chromium/components/printing/browser/print_manager.cc @@ -50,20 +50,20 @@ void PrintManager::OnPrintingFailed(int cookie) { return; } #if defined(OS_ANDROID) - PdfWritingDone(false); + PdfWritingDone(0); #endif } void PrintManager::PrintingRenderFrameDeleted() { #if defined(OS_ANDROID) - PdfWritingDone(false); + PdfWritingDone(0); #endif } #if defined(OS_ANDROID) -void PrintManager::PdfWritingDone(bool result) { +void PrintManager::PdfWritingDone(int page_count) { if (!pdf_writing_done_callback_.is_null()) - pdf_writing_done_callback_.Run(file_descriptor().fd, result); + pdf_writing_done_callback_.Run(file_descriptor().fd, page_count); // Invalidate the file descriptor so it doesn't get reused. file_descriptor_ = base::FileDescriptor(-1, false); } diff --git a/chromium/components/printing/browser/print_manager.h b/chromium/components/printing/browser/print_manager.h index 8fdba958d58..1635d36825c 100644 --- a/chromium/components/printing/browser/print_manager.h +++ b/chromium/components/printing/browser/print_manager.h @@ -22,9 +22,9 @@ class PrintManager : public content::WebContentsObserver { #if defined(OS_ANDROID) // TODO(timvolodine): consider introducing PrintManagerAndroid (crbug/500960) - typedef base::Callback<void(int, bool)> PdfWritingDoneCallback; + using PdfWritingDoneCallback = base::Callback<void(int, int)>; - void PdfWritingDone(bool result); + void PdfWritingDone(int page_count); // Sets the file descriptor into which the PDF will be written. void set_file_descriptor(const base::FileDescriptor& file_descriptor) { diff --git a/chromium/components/printing/common/print_messages.h b/chromium/components/printing/common/print_messages.h index 32b0451b60d..fd395915885 100644 --- a/chromium/components/printing/common/print_messages.h +++ b/chromium/components/printing/common/print_messages.h @@ -398,9 +398,10 @@ IPC_SYNC_MESSAGE_CONTROL1_2(PrintHostMsg_AllocateTempFileForPrinting, int /* render_frame_id */, base::FileDescriptor /* temp file fd */, int /* fd in browser*/) -IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten, +IPC_MESSAGE_CONTROL3(PrintHostMsg_TempFileForPrintingWritten, int /* render_frame_id */, - int /* fd in browser */) + int /* fd in browser */, + int /* page count */) #endif // defined(OS_ANDROID) #if BUILDFLAG(ENABLE_PRINT_PREVIEW) diff --git a/chromium/components/printing/renderer/print_web_view_helper.cc b/chromium/components/printing/renderer/print_web_view_helper.cc index 829b2dc1c65..3c9dfc0d1ed 100644 --- a/chromium/components/printing/renderer/print_web_view_helper.cc +++ b/chromium/components/printing/renderer/print_web_view_helper.cc @@ -99,7 +99,7 @@ const char kPageLoadScriptFormat[] = const char kPageSetupScriptFormat[] = "setup(%s);"; -void ExecuteScript(blink::WebFrame* frame, +void ExecuteScript(blink::WebLocalFrame* frame, const char* script_format, const base::Value& parameters) { std::string json; @@ -565,7 +565,7 @@ void PrintWebViewHelper::PrintHeaderAndFooter( blink::WebCanvas* canvas, int page_number, int total_pages, - const blink::WebFrame& source_frame, + const blink::WebLocalFrame& source_frame, float webkit_scale_factor, const PageSizeMargins& page_layout, const PrintMsg_Print_Params& params) { @@ -590,11 +590,10 @@ void PrintWebViewHelper::PrintHeaderAndFooter( } }; HeaderAndFooterClient frame_client; - blink::WebLocalFrame* frame = blink::WebLocalFrame::Create( - blink::WebTreeScopeType::kDocument, &frame_client, nullptr, nullptr); - web_view->SetMainFrame(frame); + blink::WebLocalFrame* frame = blink::WebLocalFrame::CreateMainFrame( + web_view, &frame_client, nullptr, nullptr); blink::WebWidgetClient web_widget_client; - blink::WebFrameWidget::Create(&web_widget_client, web_view, frame); + blink::WebFrameWidget::Create(&web_widget_client, frame); base::Value html( base::UTF8ToUTF16(ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -628,7 +627,7 @@ void PrintWebViewHelper::PrintHeaderAndFooter( } // static - Not anonymous so that platform implementations can use it. -float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, +float PrintWebViewHelper::RenderPageContent(blink::WebLocalFrame* frame, int page_number, const gfx::Rect& canvas_area, const gfx::Rect& content_area, @@ -690,7 +689,9 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, const blink::WebFrameOwnerProperties& frame_owner_properties) override; void FrameDetached(blink::WebLocalFrame* frame, DetachType detach_type) override; - std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override; + std::unique_ptr<blink::WebURLLoader> CreateURLLoader( + const blink::WebURLRequest& request, + base::SingleThreadTaskRunner* task_runner) override; void CallOnReady(); void ResizeForPrinting(); @@ -769,8 +770,10 @@ void PrepareFrameAndViewForPrint::ResizeForPrinting() { // Backup size and offset if it's a local frame. blink::WebView* web_view = frame_.view(); if (blink::WebFrame* web_frame = web_view->MainFrame()) { + // TODO(lukasza, weili): Support restoring scroll offset of a remote main + // frame - https://crbug.com/734815. if (web_frame->IsWebLocalFrame()) - prev_scroll_offset_ = web_frame->GetScrollOffset(); + prev_scroll_offset_ = web_frame->ToWebLocalFrame()->GetScrollOffset(); } prev_view_size_ = web_view->Size(); @@ -815,10 +818,9 @@ void PrepareFrameAndViewForPrint::CopySelection( blink::WebView::Create(this, blink::kWebPageVisibilityStateVisible); owns_web_view_ = true; content::RenderView::ApplyWebPreferences(prefs, web_view); - blink::WebLocalFrame* main_frame = blink::WebLocalFrame::Create( - blink::WebTreeScopeType::kDocument, this, nullptr, nullptr); - web_view->SetMainFrame(main_frame); - blink::WebFrameWidget::Create(this, web_view, main_frame); + blink::WebLocalFrame* main_frame = + blink::WebLocalFrame::CreateMainFrame(web_view, this, nullptr, nullptr); + blink::WebFrameWidget::Create(this, main_frame); frame_.Reset(web_view->MainFrame()->ToWebLocalFrame()); node_to_print_.Reset(); @@ -863,9 +865,11 @@ void PrepareFrameAndViewForPrint::FrameDetached(blink::WebLocalFrame* frame, } std::unique_ptr<blink::WebURLLoader> -PrepareFrameAndViewForPrint::CreateURLLoader() { +PrepareFrameAndViewForPrint::CreateURLLoader( + const blink::WebURLRequest& request, + base::SingleThreadTaskRunner* task_runner) { // TODO(yhirano): Stop using Platform::CreateURLLoader() here. - return blink::Platform::Current()->CreateURLLoader(); + return blink::Platform::Current()->CreateURLLoader(request, task_runner); } void PrepareFrameAndViewForPrint::CallOnReady() { @@ -879,8 +883,10 @@ void PrepareFrameAndViewForPrint::RestoreSize() { blink::WebView* web_view = frame_.GetFrame()->View(); web_view->Resize(prev_view_size_); if (blink::WebFrame* web_frame = web_view->MainFrame()) { + // TODO(lukasza, weili): Support restoring scroll offset of a remote main + // frame - https://crbug.com/734815. if (web_frame->IsWebLocalFrame()) - web_frame->SetScrollOffset(prev_scroll_offset_); + web_frame->ToWebLocalFrame()->SetScrollOffset(prev_scroll_offset_); } } @@ -1181,13 +1187,10 @@ void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) { if (!UpdatePrintSettings(print_preview_context_.source_frame(), print_preview_context_.source_node(), settings)) { if (print_preview_context_.last_error() != PREVIEW_ERROR_BAD_SETTING) { - Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings( - routing_id(), print_pages_params_ - ? print_pages_params_->params.document_cookie - : 0)); - notify_browser_of_print_failure_ = false; // Already sent. + DidFinishPrinting(INVALID_SETTINGS); + } else { + DidFinishPrinting(FAIL_PREVIEW); } - DidFinishPrinting(FAIL_PREVIEW); return; } @@ -1551,6 +1554,8 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame, #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { + int cookie = + print_pages_params_ ? print_pages_params_->params.document_cookie : 0; switch (result) { case OK: break; @@ -1561,23 +1566,27 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { case FAIL_PRINT: if (notify_browser_of_print_failure_ && print_pages_params_) { - int cookie = print_pages_params_->params.document_cookie; Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie)); } break; #if BUILDFLAG(ENABLE_PRINT_PREVIEW) case FAIL_PREVIEW: - int cookie = - print_pages_params_ ? print_pages_params_->params.document_cookie : 0; - if (notify_browser_of_print_failure_) { - LOG(ERROR) << "CreatePreviewDocument failed"; - Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie)); - } else { - Send(new PrintHostMsg_PrintPreviewCancelled(routing_id(), cookie)); + if (!is_print_ready_metafile_sent_) { + if (notify_browser_of_print_failure_) { + LOG(ERROR) << "CreatePreviewDocument failed"; + Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie)); + } else { + Send(new PrintHostMsg_PrintPreviewCancelled(routing_id(), cookie)); + } } print_preview_context_.Failed(notify_browser_of_print_failure_); break; + case INVALID_SETTINGS: + Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings(routing_id(), + cookie)); + print_preview_context_.Failed(false); + break; #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) } prep_frame_view_.reset(); diff --git a/chromium/components/printing/renderer/print_web_view_helper.h b/chromium/components/printing/renderer/print_web_view_helper.h index c4339d474ad..fc5e9648a33 100644 --- a/chromium/components/printing/renderer/print_web_view_helper.h +++ b/chromium/components/printing/renderer/print_web_view_helper.h @@ -44,7 +44,6 @@ class DictionaryValue; } namespace blink { -class WebFrame; class WebLocalFrame; class WebView; } @@ -155,6 +154,7 @@ class PrintWebViewHelper FAIL_PRINT, #if BUILDFLAG(ENABLE_PRINT_PREVIEW) FAIL_PREVIEW, + INVALID_SETTINGS, #endif }; @@ -322,7 +322,7 @@ class PrintWebViewHelper // |page_number| is zero-based. // When method is called, canvas should be setup to draw to |canvas_area| // with |scale_factor|. - static float RenderPageContent(blink::WebFrame* frame, + static float RenderPageContent(blink::WebLocalFrame* frame, int page_number, const gfx::Rect& canvas_area, const gfx::Rect& content_area, @@ -354,7 +354,7 @@ class PrintWebViewHelper static void PrintHeaderAndFooter(blink::WebCanvas* canvas, int page_number, int total_pages, - const blink::WebFrame& source_frame, + const blink::WebLocalFrame& source_frame, float webkit_scale_factor, const PageSizeMargins& page_layout_in_points, const PrintMsg_Print_Params& params); diff --git a/chromium/components/printing/renderer/print_web_view_helper_linux.cc b/chromium/components/printing/renderer/print_web_view_helper_linux.cc index 910c471105f..024ff6a1755 100644 --- a/chromium/components/printing/renderer/print_web_view_helper_linux.cc +++ b/chromium/components/printing/renderer/print_web_view_helper_linux.cc @@ -76,8 +76,8 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame, return false; // Tell the browser we've finished writing the file. - Send(new PrintHostMsg_TempFileForPrintingWritten(routing_id(), - sequence_number)); + Send(new PrintHostMsg_TempFileForPrintingWritten( + routing_id(), sequence_number, printed_pages.size())); return true; #else PrintHostMsg_DidPrintPage_Params printed_page_params; diff --git a/chromium/components/printing/service/pdf_compositor_service.cc b/chromium/components/printing/service/pdf_compositor_service.cc index d00f3ed76bd..40456fe47aa 100644 --- a/chromium/components/printing/service/pdf_compositor_service.cc +++ b/chromium/components/printing/service/pdf_compositor_service.cc @@ -22,7 +22,6 @@ namespace { void OnPdfCompositorRequest( const std::string& creator, service_manager::ServiceContextRefFactory* ref_factory, - const service_manager::BindSourceInfo& source_info, printing::mojom::PdfCompositorRequest request) { mojo::MakeStrongBinding(base::MakeUnique<printing::PdfCompositorImpl>( creator, ref_factory->CreateRef()), @@ -66,8 +65,7 @@ void PdfCompositorService::OnBindInterface( const service_manager::BindSourceInfo& source_info, const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe) { - registry_.BindInterface(source_info, interface_name, - std::move(interface_pipe)); + registry_.BindInterface(interface_name, std::move(interface_pipe)); } } // namespace printing diff --git a/chromium/components/printing/service/pdf_compositor_service.h b/chromium/components/printing/service/pdf_compositor_service.h index 31672988b5c..6f7bdb8c2c9 100644 --- a/chromium/components/printing/service/pdf_compositor_service.h +++ b/chromium/components/printing/service/pdf_compositor_service.h @@ -12,7 +12,6 @@ #include "base/memory/weak_ptr.h" #include "components/discardable_memory/client/client_discardable_shared_memory_manager.h" #include "components/printing/service/public/interfaces/pdf_compositor.mojom.h" -#include "services/service_manager/public/cpp/bind_source_info.h" #include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/service.h" #include "services/service_manager/public/cpp/service_context_ref.h" |