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 "printing/print_destination_interface.h" | 5 #include "printing/print_destination_interface.h" |
6 | 6 |
7 #include "base/safe_numerics.h" | 7 #include "base/numerics/safe_conversions.h" |
8 #include "base/win/metro.h" | 8 #include "base/win/metro.h" |
9 #include "win8/util/win8_util.h" | 9 #include "win8/util/win8_util.h" |
10 | 10 |
11 namespace printing { | 11 namespace printing { |
12 | 12 |
13 class PrintDestinationWin : public PrintDestinationInterface { | 13 class PrintDestinationWin : public PrintDestinationInterface { |
14 public: | 14 public: |
15 PrintDestinationWin() | 15 PrintDestinationWin() |
16 : metro_set_print_page_count_(NULL), | 16 : metro_set_print_page_count_(NULL), |
17 metro_set_print_page_content_(NULL) { | 17 metro_set_print_page_content_(NULL) { |
(...skipping 10 matching lines...) Expand all Loading... |
28 virtual void SetPageCount(int page_count) { | 28 virtual void SetPageCount(int page_count) { |
29 if (metro_set_print_page_count_) | 29 if (metro_set_print_page_count_) |
30 metro_set_print_page_count_(page_count); | 30 metro_set_print_page_count_(page_count); |
31 } | 31 } |
32 | 32 |
33 virtual void SetPageContent(int page_number, | 33 virtual void SetPageContent(int page_number, |
34 void* content, | 34 void* content, |
35 size_t content_size) { | 35 size_t content_size) { |
36 if (metro_set_print_page_content_) | 36 if (metro_set_print_page_content_) |
37 metro_set_print_page_content_(page_number - 1, content, | 37 metro_set_print_page_content_(page_number - 1, content, |
38 base::checked_numeric_cast<UINT32>(content_size)); | 38 base::checked_cast<UINT32>(content_size)); |
39 } | 39 } |
40 private: | 40 private: |
41 typedef void (*MetroSetPrintPageCount)(INT); | 41 typedef void (*MetroSetPrintPageCount)(INT); |
42 typedef void (*MetroSetPrintPageContent)(INT, VOID*, UINT32); | 42 typedef void (*MetroSetPrintPageContent)(INT, VOID*, UINT32); |
43 MetroSetPrintPageCount metro_set_print_page_count_; | 43 MetroSetPrintPageCount metro_set_print_page_count_; |
44 MetroSetPrintPageContent metro_set_print_page_content_; | 44 MetroSetPrintPageContent metro_set_print_page_content_; |
45 }; | 45 }; |
46 | 46 |
47 PrintDestinationInterface* CreatePrintDestination() { | 47 PrintDestinationInterface* CreatePrintDestination() { |
48 // We currently only support the Metro print destination. | 48 // We currently only support the Metro print destination. |
49 if (win8::IsSingleWindowMetroMode()) | 49 if (win8::IsSingleWindowMetroMode()) |
50 return new PrintDestinationWin; | 50 return new PrintDestinationWin; |
51 else | 51 else |
52 return NULL; | 52 return NULL; |
53 } | 53 } |
54 | 54 |
55 } // namespace printing | 55 } // namespace printing |
OLD | NEW |