OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "printing/print_destination_interface.h" |
| 6 |
| 7 #include "base/win/metro.h" |
| 8 |
| 9 namespace printing { |
| 10 |
| 11 class PrintDestinationWin : public PrintDestinationInterface { |
| 12 public: |
| 13 PrintDestinationWin() |
| 14 : metro_set_print_page_count_(NULL), |
| 15 metro_set_print_page_content_(NULL) { |
| 16 HMODULE metro_module = base::win::GetMetroModule(); |
| 17 if (metro_module != NULL) { |
| 18 metro_set_print_page_count_ = |
| 19 reinterpret_cast<MetroSetPrintPageCount>( |
| 20 ::GetProcAddress(metro_module, "MetroSetPrintPageCount")); |
| 21 metro_set_print_page_content_ = |
| 22 reinterpret_cast<MetroSetPrintPageContent>( |
| 23 ::GetProcAddress(metro_module, "MetroSetPrintPageContent")); |
| 24 } |
| 25 } |
| 26 virtual void SetPageCount(int page_count) { |
| 27 if (metro_set_print_page_count_) |
| 28 metro_set_print_page_count_(page_count); |
| 29 } |
| 30 |
| 31 virtual void SetPageContent(int page_number, |
| 32 void* content, |
| 33 size_t content_size) { |
| 34 if (metro_set_print_page_content_) |
| 35 metro_set_print_page_content_(page_number - 1, content, content_size); |
| 36 } |
| 37 private: |
| 38 typedef void (*MetroSetPrintPageCount)(INT); |
| 39 typedef void (*MetroSetPrintPageContent)(INT, VOID*, UINT32); |
| 40 MetroSetPrintPageCount metro_set_print_page_count_; |
| 41 MetroSetPrintPageContent metro_set_print_page_content_; |
| 42 }; |
| 43 |
| 44 PrintDestinationInterface* CreatePrintDestination() { |
| 45 // We currently only support the Metro print destination. |
| 46 if (base::win::IsMetroProcess()) |
| 47 return new PrintDestinationWin; |
| 48 else |
| 49 return NULL; |
| 50 } |
| 51 |
| 52 } // namespace printing |
OLD | NEW |