| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/print_messages.h" | 14 #include "chrome/common/print_messages.h" |
| 15 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 16 #include "content/renderer/render_view.h" | 16 #include "content/renderer/render_view.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "printing/metafile.h" |
| 18 #include "printing/units.h" | 19 #include "printing/units.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 WebKit::WebNode* node) { | 630 WebKit::WebNode* node) { |
| 630 PrintMsg_PrintPages_Params print_settings = *print_pages_params_; | 631 PrintMsg_PrintPages_Params print_settings = *print_pages_params_; |
| 631 // PDF printer device supports alpha blending. | 632 // PDF printer device supports alpha blending. |
| 632 print_settings.params.supports_alpha_blend = true; | 633 print_settings.params.supports_alpha_blend = true; |
| 633 // TODO(kmadhusu): Handle print selection. | 634 // TODO(kmadhusu): Handle print selection. |
| 634 CreatePreviewDocument(print_settings, frame, node); | 635 CreatePreviewDocument(print_settings, frame, node); |
| 635 } | 636 } |
| 636 | 637 |
| 637 #if defined(OS_POSIX) | 638 #if defined(OS_POSIX) |
| 638 bool PrintWebViewHelper::CopyMetafileDataToSharedMem( | 639 bool PrintWebViewHelper::CopyMetafileDataToSharedMem( |
| 639 printing::NativeMetafile* metafile, | 640 printing::Metafile* metafile, |
| 640 base::SharedMemoryHandle* shared_mem_handle) { | 641 base::SharedMemoryHandle* shared_mem_handle) { |
| 641 uint32 buf_size = metafile->GetDataSize(); | 642 uint32 buf_size = metafile->GetDataSize(); |
| 642 base::SharedMemoryHandle mem_handle; | 643 base::SharedMemoryHandle mem_handle; |
| 643 if (render_view()->Send( | 644 if (render_view()->Send( |
| 644 new ViewHostMsg_AllocateSharedMemoryBuffer(buf_size, &mem_handle))) { | 645 new ViewHostMsg_AllocateSharedMemoryBuffer(buf_size, &mem_handle))) { |
| 645 if (base::SharedMemory::IsHandleValid(mem_handle)) { | 646 if (base::SharedMemory::IsHandleValid(mem_handle)) { |
| 646 base::SharedMemory shared_buf(mem_handle, false); | 647 base::SharedMemory shared_buf(mem_handle, false); |
| 647 if (shared_buf.Map(buf_size)) { | 648 if (shared_buf.Map(buf_size)) { |
| 648 metafile->GetData(shared_buf.memory(), buf_size); | 649 metafile->GetData(shared_buf.memory(), buf_size); |
| 649 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), | 650 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 688 |
| 688 void PrintWebViewHelper::ResetScriptedPrintCount() { | 689 void PrintWebViewHelper::ResetScriptedPrintCount() { |
| 689 // Reset cancel counter on successful print. | 690 // Reset cancel counter on successful print. |
| 690 user_cancelled_scripted_print_count_ = 0; | 691 user_cancelled_scripted_print_count_ = 0; |
| 691 } | 692 } |
| 692 | 693 |
| 693 void PrintWebViewHelper::IncrementScriptedPrintCount() { | 694 void PrintWebViewHelper::IncrementScriptedPrintCount() { |
| 694 ++user_cancelled_scripted_print_count_; | 695 ++user_cancelled_scripted_print_count_; |
| 695 last_cancelled_script_print_ = base::Time::Now(); | 696 last_cancelled_script_print_ = base::Time::Now(); |
| 696 } | 697 } |
| OLD | NEW |