summaryrefslogtreecommitdiffstats
path: root/printing/print_destination_win.cc
diff options
context:
space:
mode:
authormad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-29 18:58:34 +0000
committermad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-29 18:58:34 +0000
commitd53e403f3380ffa77b87114fa803a7f533d4abdd (patch)
tree1219534b889d04b50205cb1e006e971dc45582e0 /printing/print_destination_win.cc
parent8077d05f0e0270fc20223db380e543ba5e92892a (diff)
downloadchromium_src-d53e403f3380ffa77b87114fa803a7f533d4abdd.zip
chromium_src-d53e403f3380ffa77b87114fa803a7f533d4abdd.tar.gz
chromium_src-d53e403f3380ffa77b87114fa803a7f533d4abdd.tar.bz2
These are the Chrome side changes to support the Print device charm in Metro.
We now expose a print destination interface (not quite complete yet) to bypass the current print flow so that the metafile bits get sent to Metro instead of the print spooler. Other changes will come to make this more complete, e.g., pass in the destination object from the metro module, and expose print settings on the destination interface. BUG=125675 TEST=Make sure you can still print as usual outside the Metro world. Review URL: https://chromiumcodereview.appspot.com/10483006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/print_destination_win.cc')
-rw-r--r--printing/print_destination_win.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/printing/print_destination_win.cc b/printing/print_destination_win.cc
new file mode 100644
index 0000000..dc99469
--- /dev/null
+++ b/printing/print_destination_win.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/print_destination_interface.h"
+
+#include "base/win/metro.h"
+
+namespace printing {
+
+class PrintDestinationWin : public PrintDestinationInterface {
+ public:
+ PrintDestinationWin()
+ : metro_set_print_page_count_(NULL),
+ metro_set_print_page_content_(NULL) {
+ HMODULE metro_module = base::win::GetMetroModule();
+ if (metro_module != NULL) {
+ metro_set_print_page_count_ =
+ reinterpret_cast<MetroSetPrintPageCount>(
+ ::GetProcAddress(metro_module, "MetroSetPrintPageCount"));
+ metro_set_print_page_content_ =
+ reinterpret_cast<MetroSetPrintPageContent>(
+ ::GetProcAddress(metro_module, "MetroSetPrintPageContent"));
+ }
+ }
+ virtual void SetPageCount(int page_count) {
+ if (metro_set_print_page_count_)
+ metro_set_print_page_count_(page_count);
+ }
+
+ virtual void SetPageContent(int page_number,
+ void* content,
+ size_t content_size) {
+ if (metro_set_print_page_content_)
+ metro_set_print_page_content_(page_number - 1, content, content_size);
+ }
+ private:
+ typedef void (*MetroSetPrintPageCount)(INT);
+ typedef void (*MetroSetPrintPageContent)(INT, VOID*, UINT32);
+ MetroSetPrintPageCount metro_set_print_page_count_;
+ MetroSetPrintPageContent metro_set_print_page_content_;
+};
+
+PrintDestinationInterface* CreatePrintDestination() {
+ // We currently only support the Metro print destination.
+ if (base::win::IsMetroProcess())
+ return new PrintDestinationWin;
+ else
+ return NULL;
+}
+
+} // namespace printing