Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: win8/metro_driver/print_handler.h

Issue 1815463002: Remove win8/metro_driver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « win8/metro_driver/print_document_source.cc ('k') | win8/metro_driver/print_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #ifndef CHROME_BROWSER_UI_METRO_DRIVER_PRINT_HANDLER_H_
6 #define CHROME_BROWSER_UI_METRO_DRIVER_PRINT_HANDLER_H_
7
8 #include <windows.media.playto.h>
9 #include <stddef.h>
10 #include <windows.graphics.printing.h>
11 #include <windows.ui.core.h>
12
13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread.h"
15 #include "win8/metro_driver/print_document_source.h"
16 #include "win8/metro_driver/winrt_utils.h"
17
18 namespace base {
19
20 class Lock;
21
22 } // namespace base
23
24 namespace metro_driver {
25
26 // This class handles the print aspect of the devices charm.
27 class PrintHandler {
28 public:
29 PrintHandler();
30 ~PrintHandler();
31
32 HRESULT Initialize(winui::Core::ICoreWindow* window);
33
34 // Called by the exported C functions.
35 static void EnablePrinting(bool printing_enabled);
36 static void SetPageCount(size_t page_count);
37 static void AddPage(size_t page_number, IStream* metafile_stream);
38 static void ShowPrintUI();
39
40 private:
41 // Callbacks from Metro.
42 HRESULT OnPrintRequested(
43 wingfx::Printing::IPrintManager* print_mgr,
44 wingfx::Printing::IPrintTaskRequestedEventArgs* event_args);
45
46 HRESULT OnPrintTaskSourceRequest(
47 wingfx::Printing::IPrintTaskSourceRequestedArgs* args);
48
49 HRESULT OnCompleted(wingfx::Printing::IPrintTask* task,
50 wingfx::Printing::IPrintTaskCompletedEventArgs* args);
51 // Utility methods.
52 void ClearPrintTask();
53 float GetLogicalDpi();
54
55 // Callback from Metro and entry point called on lockable thread.
56 HRESULT LogicalDpiChanged(IInspectable *sender);
57 static void OnLogicalDpiChanged(float dpi);
58
59 // Called on the lockable thread to set/release the doc.
60 static void SetPrintDocumentSource(
61 const mswr::ComPtr<PrintDocumentSource>& print_document_source);
62 static void ReleasePrintDocumentSource();
63
64 // Called on the lockable thread for the exported C functions.
65 static void OnEnablePrinting(bool printing_enabled);
66 static void OnSetPageCount(size_t page_count);
67 static void OnAddPage(size_t page_number,
68 mswr::ComPtr<IStream> metafile_stream);
69
70 // Opens the prit device charm. Must be called from the metro thread.
71 static void OnShowPrintUI();
72
73 mswr::ComPtr<wingfx::Printing::IPrintTask> print_task_;
74 EventRegistrationToken print_requested_token_;
75 EventRegistrationToken print_completed_token_;
76 EventRegistrationToken dpi_change_token_;
77
78 mswr::ComPtr<wingfx::Printing::IPrintManager> print_manager_;
79 PrintDocumentSource::DirectXContext directx_context_;
80
81 // Hack to give access to the Print Document from the C style entry points.
82 // This will go away once we can pass a pointer to this interface down to
83 // the Chrome Browser as we send the command to print.
84 static mswr::ComPtr<PrintDocumentSource> current_document_source_;
85
86 // Another hack to enable/disable printing from an exported C function.
87 // TODO(mad): Find a better way to do this...
88 static bool printing_enabled_;
89
90 // This is also a temporary hack until we can pass down the print document
91 // to Chrome so it can call directly into it. We need to lock the access to
92 // current_document_source_.
93 static base::Lock* lock_;
94
95 // This thread is used to send blocking jobs
96 // out of threads we don't want to block.
97 static base::Thread* thread_;
98 };
99
100 } // namespace metro_driver
101
102 // Exported C functions for Chrome to call into the Metro module.
103 extern "C" __declspec(dllexport)
104 void MetroEnablePrinting(BOOL printing_enabled);
105
106 extern "C" __declspec(dllexport)
107 void MetroSetPrintPageCount(size_t page_count);
108
109 extern "C" __declspec(dllexport)
110 void MetroSetPrintPageContent(size_t current_page,
111 void* data,
112 size_t data_size);
113
114 extern "C" __declspec(dllexport)
115 void MetroShowPrintUI();
116
117 #endif // CHROME_BROWSER_UI_METRO_DRIVER_PRINT_HANDLER_H_
OLDNEW
« no previous file with comments | « win8/metro_driver/print_document_source.cc ('k') | win8/metro_driver/print_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698