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

Side by Side Diff: android_webview/renderer/print_web_view_helper.cc

Issue 559263002: Replaced Metafile with PdfMetafileSkia in renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thu Sep 11 15:46:31 PDT 2014 Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276 5 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276
6 6
7 #include "android_webview/renderer/print_web_view_helper.h" 7 #include "android_webview/renderer/print_web_view_helper.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "android_webview/common/print_messages.h" 11 #include "android_webview/common/print_messages.h"
12 #include "base/auto_reset.h" 12 #include "base/auto_reset.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "content/public/common/web_preferences.h" 22 #include "content/public/common/web_preferences.h"
23 #include "content/public/renderer/render_thread.h" 23 #include "content/public/renderer/render_thread.h"
24 #include "content/public/renderer/render_view.h" 24 #include "content/public/renderer/render_view.h"
25 #include "net/base/escape.h" 25 #include "net/base/escape.h"
26 #include "printing/metafile.h"
27 #include "printing/pdf_metafile_skia.h" 26 #include "printing/pdf_metafile_skia.h"
28 #include "printing/units.h" 27 #include "printing/units.h"
29 #include "skia/ext/vector_platform_device_skia.h" 28 #include "skia/ext/vector_platform_device_skia.h"
30 #include "third_party/WebKit/public/platform/WebSize.h" 29 #include "third_party/WebKit/public/platform/WebSize.h"
31 #include "third_party/WebKit/public/platform/WebURLRequest.h" 30 #include "third_party/WebKit/public/platform/WebURLRequest.h"
32 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 31 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
33 #include "third_party/WebKit/public/web/WebDocument.h" 32 #include "third_party/WebKit/public/web/WebDocument.h"
34 #include "third_party/WebKit/public/web/WebElement.h" 33 #include "third_party/WebKit/public/web/WebElement.h"
35 #include "third_party/WebKit/public/web/WebFrameClient.h" 34 #include "third_party/WebKit/public/web/WebFrameClient.h"
36 #include "third_party/WebKit/public/web/WebLocalFrame.h" 35 #include "third_party/WebKit/public/web/WebLocalFrame.h"
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 print_pages_params_->pages.empty()); 1595 print_pages_params_->pages.empty());
1597 prep_frame_view_->CopySelectionIfNeeded( 1596 prep_frame_view_->CopySelectionIfNeeded(
1598 render_view()->GetWebkitPreferences(), 1597 render_view()->GetWebkitPreferences(),
1599 base::Bind(&PrintWebViewHelper::OnFramePreparedForPrintPages, 1598 base::Bind(&PrintWebViewHelper::OnFramePreparedForPrintPages,
1600 base::Unretained(this))); 1599 base::Unretained(this)));
1601 return true; 1600 return true;
1602 } 1601 }
1603 1602
1604 #if defined(OS_POSIX) 1603 #if defined(OS_POSIX)
1605 bool PrintWebViewHelper::CopyMetafileDataToSharedMem( 1604 bool PrintWebViewHelper::CopyMetafileDataToSharedMem(
1606 Metafile* metafile, 1605 PdfMetafileSkia* metafile,
1607 base::SharedMemoryHandle* shared_mem_handle) { 1606 base::SharedMemoryHandle* shared_mem_handle) {
1608 uint32 buf_size = metafile->GetDataSize(); 1607 uint32 buf_size = metafile->GetDataSize();
1609 scoped_ptr<base::SharedMemory> shared_buf( 1608 scoped_ptr<base::SharedMemory> shared_buf(
1610 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( 1609 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(
1611 buf_size).release()); 1610 buf_size).release());
1612 1611
1613 if (shared_buf.get()) { 1612 if (shared_buf.get()) {
1614 if (shared_buf->Map(buf_size)) { 1613 if (shared_buf->Map(buf_size)) {
1615 metafile->GetData(shared_buf->memory(), buf_size); 1614 metafile->GetData(shared_buf->memory(), buf_size);
1616 shared_buf->GiveToProcess(base::GetCurrentProcessHandle(), 1615 shared_buf->GiveToProcess(base::GetCurrentProcessHandle(),
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 Send(new PrintHostMsg_CheckForCancel(routing_id(), 1734 Send(new PrintHostMsg_CheckForCancel(routing_id(),
1736 print_params.preview_ui_id, 1735 print_params.preview_ui_id,
1737 print_params.preview_request_id, 1736 print_params.preview_request_id,
1738 &cancel)); 1737 &cancel));
1739 if (cancel) 1738 if (cancel)
1740 notify_browser_of_print_failure_ = false; 1739 notify_browser_of_print_failure_ = false;
1741 return cancel; 1740 return cancel;
1742 } 1741 }
1743 1742
1744 bool PrintWebViewHelper::PreviewPageRendered(int page_number, 1743 bool PrintWebViewHelper::PreviewPageRendered(int page_number,
1745 Metafile* metafile) { 1744 PdfMetafileSkia* metafile) {
1746 DCHECK_GE(page_number, FIRST_PAGE_INDEX); 1745 DCHECK_GE(page_number, FIRST_PAGE_INDEX);
1747 1746
1748 // For non-modifiable files, |metafile| should be NULL, so do not bother 1747 // For non-modifiable files, |metafile| should be NULL, so do not bother
1749 // sending a message. If we don't generate draft metafiles, |metafile| is 1748 // sending a message. If we don't generate draft metafiles, |metafile| is
1750 // NULL. 1749 // NULL.
1751 if (!print_preview_context_.IsModifiable() || 1750 if (!print_preview_context_.IsModifiable() ||
1752 !print_preview_context_.generate_draft_pages()) { 1751 !print_preview_context_.generate_draft_pages()) {
1753 DCHECK(!metafile); 1752 DCHECK(!metafile);
1754 return true; 1753 return true;
1755 } 1754 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 } 2015 }
2017 2016
2018 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 2017 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
2019 prep_frame_view_.reset(); 2018 prep_frame_view_.reset();
2020 metafile_.reset(); 2019 metafile_.reset();
2021 pages_to_render_.clear(); 2020 pages_to_render_.clear();
2022 error_ = PREVIEW_ERROR_NONE; 2021 error_ = PREVIEW_ERROR_NONE;
2023 } 2022 }
2024 2023
2025 } // namespace printing 2024 } // namespace printing
OLDNEW
« no previous file with comments | « android_webview/renderer/print_web_view_helper.h ('k') | android_webview/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698