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.
5 #include "printing/print_destination_interface.h"
7 #include "base/numerics/safe_conversions.h"
8 #include "base/win/metro.h"
9 #include "win8/util/win8_util.h"
13 class PrintDestinationWin
: public PrintDestinationInterface
{
16 : metro_set_print_page_count_(NULL
),
17 metro_set_print_page_content_(NULL
) {
18 HMODULE metro_module
= base::win::GetMetroModule();
19 if (metro_module
!= NULL
) {
20 metro_set_print_page_count_
=
21 reinterpret_cast<MetroSetPrintPageCount
>(
22 ::GetProcAddress(metro_module
, "MetroSetPrintPageCount"));
23 metro_set_print_page_content_
=
24 reinterpret_cast<MetroSetPrintPageContent
>(
25 ::GetProcAddress(metro_module
, "MetroSetPrintPageContent"));
28 virtual void SetPageCount(int page_count
) {
29 if (metro_set_print_page_count_
)
30 metro_set_print_page_count_(page_count
);
33 virtual void SetPageContent(int page_number
,
35 size_t content_size
) {
36 if (metro_set_print_page_content_
)
37 metro_set_print_page_content_(page_number
- 1, content
,
38 base::checked_cast
<UINT32
>(content_size
));
41 typedef void (*MetroSetPrintPageCount
)(INT
);
42 typedef void (*MetroSetPrintPageContent
)(INT
, VOID
*, UINT32
);
43 MetroSetPrintPageCount metro_set_print_page_count_
;
44 MetroSetPrintPageContent metro_set_print_page_content_
;
47 PrintDestinationInterface
* CreatePrintDestination() {
48 // We currently only support the Metro print destination.
49 if (win8::IsSingleWindowMetroMode())
50 return new PrintDestinationWin
;
55 } // namespace printing