| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "stdafx.h" | 5 #include "stdafx.h" |
| 6 #include "win8/metro_driver/print_handler.h" | 6 #include "win8/metro_driver/print_handler.h" |
| 7 | 7 |
| 8 #include <windows.graphics.display.h> | 8 #include <windows.graphics.display.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/safe_numerics.h" | 12 #include "base/numerics/safe_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "win8/metro_driver/chrome_app_view.h" | 14 #include "win8/metro_driver/chrome_app_view.h" |
| 15 #include "win8/metro_driver/winrt_utils.h" | 15 #include "win8/metro_driver/winrt_utils.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 typedef winfoundtn::ITypedEventHandler< | 19 typedef winfoundtn::ITypedEventHandler< |
| 20 wingfx::Printing::PrintManager*, | 20 wingfx::Printing::PrintManager*, |
| 21 wingfx::Printing::PrintTaskRequestedEventArgs*> PrintRequestedHandler; | 21 wingfx::Printing::PrintTaskRequestedEventArgs*> PrintRequestedHandler; |
| 22 | 22 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 size_t data_size) { | 467 size_t data_size) { |
| 468 DVLOG(1) << __FUNCTION__ << " Page number: " << page_number; | 468 DVLOG(1) << __FUNCTION__ << " Page number: " << page_number; |
| 469 DCHECK(data != NULL); | 469 DCHECK(data != NULL); |
| 470 DCHECK(data_size > 0); | 470 DCHECK(data_size > 0); |
| 471 mswr::ComPtr<IStream> metafile_stream; | 471 mswr::ComPtr<IStream> metafile_stream; |
| 472 HRESULT hr = ::CreateStreamOnHGlobal( | 472 HRESULT hr = ::CreateStreamOnHGlobal( |
| 473 NULL, TRUE, metafile_stream.GetAddressOf()); | 473 NULL, TRUE, metafile_stream.GetAddressOf()); |
| 474 if (metafile_stream.Get() != NULL) { | 474 if (metafile_stream.Get() != NULL) { |
| 475 ULONG bytes_written = 0; | 475 ULONG bytes_written = 0; |
| 476 hr = metafile_stream->Write(data, | 476 hr = metafile_stream->Write(data, |
| 477 base::checked_numeric_cast<ULONG>(data_size), | 477 base::checked_cast<ULONG>(data_size), |
| 478 &bytes_written); | 478 &bytes_written); |
| 479 LOG_IF(ERROR, FAILED(hr)) << "Failed to Write to Stream " << std::hex << hr; | 479 LOG_IF(ERROR, FAILED(hr)) << "Failed to Write to Stream " << std::hex << hr; |
| 480 DCHECK(bytes_written == data_size); | 480 DCHECK(bytes_written == data_size); |
| 481 | 481 |
| 482 metro_driver::PrintHandler::AddPage(page_number, metafile_stream.Get()); | 482 metro_driver::PrintHandler::AddPage(page_number, metafile_stream.Get()); |
| 483 } else { | 483 } else { |
| 484 NOTREACHED() << "Failed to CreateStreamOnHGlobal " << std::hex << hr; | 484 NOTREACHED() << "Failed to CreateStreamOnHGlobal " << std::hex << hr; |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 void MetroShowPrintUI() { | 488 void MetroShowPrintUI() { |
| 489 metro_driver::PrintHandler::ShowPrintUI(); | 489 metro_driver::PrintHandler::ShowPrintUI(); |
| 490 } | 490 } |
| OLD | NEW |