| 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" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 WebKit::WebNode* node) { | 629 WebKit::WebNode* node) { |
| 630 PrintMsg_PrintPages_Params print_settings = *print_pages_params_; | 630 PrintMsg_PrintPages_Params print_settings = *print_pages_params_; |
| 631 // PDF printer device supports alpha blending. | 631 // PDF printer device supports alpha blending. |
| 632 print_settings.params.supports_alpha_blend = true; | 632 print_settings.params.supports_alpha_blend = true; |
| 633 // TODO(kmadhusu): Handle print selection. | 633 // TODO(kmadhusu): Handle print selection. |
| 634 CreatePreviewDocument(print_settings, frame, node); | 634 CreatePreviewDocument(print_settings, frame, node); |
| 635 } | 635 } |
| 636 | 636 |
| 637 #if defined(OS_POSIX) | 637 #if defined(OS_POSIX) |
| 638 bool PrintWebViewHelper::CopyMetafileDataToSharedMem( | 638 bool PrintWebViewHelper::CopyMetafileDataToSharedMem( |
| 639 printing::NativeMetafile* metafile, | 639 printing::Metafile* metafile, |
| 640 base::SharedMemoryHandle* shared_mem_handle) { | 640 base::SharedMemoryHandle* shared_mem_handle) { |
| 641 uint32 buf_size = metafile->GetDataSize(); | 641 uint32 buf_size = metafile->GetDataSize(); |
| 642 base::SharedMemoryHandle mem_handle; | 642 base::SharedMemoryHandle mem_handle; |
| 643 if (render_view()->Send( | 643 if (render_view()->Send( |
| 644 new ViewHostMsg_AllocateSharedMemoryBuffer(buf_size, &mem_handle))) { | 644 new ViewHostMsg_AllocateSharedMemoryBuffer(buf_size, &mem_handle))) { |
| 645 if (base::SharedMemory::IsHandleValid(mem_handle)) { | 645 if (base::SharedMemory::IsHandleValid(mem_handle)) { |
| 646 base::SharedMemory shared_buf(mem_handle, false); | 646 base::SharedMemory shared_buf(mem_handle, false); |
| 647 if (shared_buf.Map(buf_size)) { | 647 if (shared_buf.Map(buf_size)) { |
| 648 metafile->GetData(shared_buf.memory(), buf_size); | 648 metafile->GetData(shared_buf.memory(), buf_size); |
| 649 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), | 649 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 687 |
| 688 void PrintWebViewHelper::ResetScriptedPrintCount() { | 688 void PrintWebViewHelper::ResetScriptedPrintCount() { |
| 689 // Reset cancel counter on successful print. | 689 // Reset cancel counter on successful print. |
| 690 user_cancelled_scripted_print_count_ = 0; | 690 user_cancelled_scripted_print_count_ = 0; |
| 691 } | 691 } |
| 692 | 692 |
| 693 void PrintWebViewHelper::IncrementScriptedPrintCount() { | 693 void PrintWebViewHelper::IncrementScriptedPrintCount() { |
| 694 ++user_cancelled_scripted_print_count_; | 694 ++user_cancelled_scripted_print_count_; |
| 695 last_cancelled_script_print_ = base::Time::Now(); | 695 last_cancelled_script_print_ = base::Time::Now(); |
| 696 } | 696 } |
| OLD | NEW |