diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-29 18:58:34 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-29 18:58:34 +0000 |
commit | d53e403f3380ffa77b87114fa803a7f533d4abdd (patch) | |
tree | 1219534b889d04b50205cb1e006e971dc45582e0 /printing | |
parent | 8077d05f0e0270fc20223db380e543ba5e92892a (diff) | |
download | chromium_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')
-rw-r--r-- | printing/print_destination_interface.h | 33 | ||||
-rw-r--r-- | printing/print_destination_none.cc | 13 | ||||
-rw-r--r-- | printing/print_destination_win.cc | 52 | ||||
-rw-r--r-- | printing/printing.gyp | 6 |
4 files changed, 104 insertions, 0 deletions
diff --git a/printing/print_destination_interface.h b/printing/print_destination_interface.h new file mode 100644 index 0000000..13e8c95 --- /dev/null +++ b/printing/print_destination_interface.h @@ -0,0 +1,33 @@ +// 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. + +#ifndef PRINTING_PRINT_DESTINATION_INTERFACE_H_ +#define PRINTING_PRINT_DESTINATION_INTERFACE_H_ +#pragma once + +#include "base/memory/ref_counted.h" +#include "printing/printing_export.h" + +namespace printing { + +class PrintDestinationInterface + : public base::RefCountedThreadSafe<PrintDestinationInterface> { + public: + // Sets the number of pages to print as soon as it is known. + virtual void SetPageCount(int page_count) = 0; + + // Sets the metafile bits for a given page as soon as it is ready. + virtual void SetPageContent(int page_number, + void* content, + size_t content_size) = 0; + protected: + friend class base::RefCountedThreadSafe<PrintDestinationInterface>; + virtual ~PrintDestinationInterface() {} +}; + +PRINTING_EXPORT PrintDestinationInterface* CreatePrintDestination(); + +} // namespace printing + +#endif // PRINTING_PRINT_DESTINATION_INTERFACE_H_ diff --git a/printing/print_destination_none.cc b/printing/print_destination_none.cc new file mode 100644 index 0000000..66b838e --- /dev/null +++ b/printing/print_destination_none.cc @@ -0,0 +1,13 @@ +// 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" + +namespace printing { + +PrintDestinationInterface* CreatePrintDestination() { + return NULL; +} + +} // namespace printing 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 diff --git a/printing/printing.gyp b/printing/printing.gyp index 19fa1b2..6af7b88 100644 --- a/printing/printing.gyp +++ b/printing/printing.gyp @@ -55,6 +55,9 @@ 'pdf_metafile_cg_mac.h', 'pdf_metafile_skia.h', 'pdf_metafile_skia.cc', + 'print_destination_interface.h', + 'print_destination_none.cc', + 'print_destination_win.cc', 'printed_document_gtk.cc', 'printed_document.cc', 'printed_document.h', @@ -146,6 +149,9 @@ 'backend/win_helper.h', 'backend/print_backend_win.cc', ], + 'sources!': [ + 'print_destination_none.cc', + ], }], ['chromeos==1 or use_aura==1',{ 'sources': [ |