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

Side by Side Diff: chrome/browser/printing/print_job_worker.h

Issue 478183005: Added PrintingContext::Delegate to get parent view handle and application locale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wed Aug 20 16:46:22 PDT 2014 Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "printing/page_number.h" 12 #include "printing/page_number.h"
13 #include "printing/print_destination_interface.h" 13 #include "printing/print_destination_interface.h"
14 #include "printing/printing_context.h" 14 #include "printing/printing_context.h"
15 #include "printing/print_job_constants.h" 15 #include "printing/print_job_constants.h"
16 16
17 namespace base { 17 namespace base {
18 class DictionaryValue; 18 class DictionaryValue;
19 } 19 }
20 20
21 namespace printing { 21 namespace printing {
22 22
23 class PrintJob; 23 class PrintJob;
24 class PrintJobWorkerOwner; 24 class PrintJobWorkerOwner;
25 class PrintedDocument; 25 class PrintedDocument;
26 class PrintedPage; 26 class PrintedPage;
27 class PrintingUIWebContentsObserver;
28 27
29 // Worker thread code. It manages the PrintingContext, which can be blocking 28 // Worker thread code. It manages the PrintingContext, which can be blocking
30 // and/or run a message loop. This is the object that generates most 29 // and/or run a message loop. This is the object that generates most
31 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a 30 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a
32 // NotificationTask task to be executed from the right thread, the UI thread. 31 // NotificationTask task to be executed from the right thread, the UI thread.
33 // PrintJob always outlives its worker instance. 32 // PrintJob always outlives its worker instance.
34 class PrintJobWorker { 33 class PrintJobWorker {
35 public: 34 public:
36 explicit PrintJobWorker(PrintJobWorkerOwner* owner); 35 PrintJobWorker(int render_process_id,
36 int render_view_id,
37 PrintJobWorkerOwner* owner);
37 virtual ~PrintJobWorker(); 38 virtual ~PrintJobWorker();
38 39
39 void SetNewOwner(PrintJobWorkerOwner* new_owner); 40 void SetNewOwner(PrintJobWorkerOwner* new_owner);
40 41
41 // Set a destination for print. 42 // Set a destination for print.
42 // This supersedes the document's rendering destination. 43 // This supersedes the document's rendering destination.
43 void SetPrintDestination(PrintDestinationInterface* destination); 44 void SetPrintDestination(PrintDestinationInterface* destination);
44 45
45 // Initializes the print settings. If |ask_user_for_settings| is true, a 46 // Initializes the print settings. If |ask_user_for_settings| is true, a
46 // Print... dialog box will be shown to ask the user his preference. 47 // Print... dialog box will be shown to ask the user his preference.
47 void GetSettings( 48 void GetSettings(
48 bool ask_user_for_settings, 49 bool ask_user_for_settings,
49 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer,
50 int document_page_count, 50 int document_page_count,
51 bool has_selection, 51 bool has_selection,
52 MarginType margin_type); 52 MarginType margin_type);
53 53
54 // Set the new print settings. 54 // Set the new print settings.
55 void SetSettings( 55 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings);
56 scoped_ptr<base::DictionaryValue> new_settings);
57 56
58 // Starts the printing loop. Every pages are printed as soon as the data is 57 // Starts the printing loop. Every pages are printed as soon as the data is
59 // available. Makes sure the new_document is the right one. 58 // available. Makes sure the new_document is the right one.
60 void StartPrinting(PrintedDocument* new_document); 59 void StartPrinting(PrintedDocument* new_document);
61 60
62 // Updates the printed document. 61 // Updates the printed document.
63 void OnDocumentChanged(PrintedDocument* new_document); 62 void OnDocumentChanged(PrintedDocument* new_document);
64 63
65 // Dequeues waiting pages. Called when PrintJob receives a 64 // Dequeues waiting pages. Called when PrintJob receives a
66 // NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if 65 // NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void OnDocumentDone(); 104 void OnDocumentDone();
106 105
107 // Discards the current document, the current page and cancels the printing 106 // Discards the current document, the current page and cancels the printing
108 // context. 107 // context.
109 void OnFailure(); 108 void OnFailure();
110 109
111 // Asks the user for print settings. Must be called on the UI thread. 110 // Asks the user for print settings. Must be called on the UI thread.
112 // Required on Mac and Linux. Windows can display UI from non-main threads, 111 // Required on Mac and Linux. Windows can display UI from non-main threads,
113 // but sticks with this for consistency. 112 // but sticks with this for consistency.
114 void GetSettingsWithUI( 113 void GetSettingsWithUI(
115 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer,
116 int document_page_count, 114 int document_page_count,
117 bool has_selection); 115 bool has_selection);
118 116
119 // The callback used by PrintingContext::GetSettingsWithUI() to notify this 117 // The callback used by PrintingContext::GetSettingsWithUI() to notify this
120 // object that the print settings are set. This is needed in order to bounce 118 // object that the print settings are set. This is needed in order to bounce
121 // back into the IO thread for GetSettingsDone(). 119 // back into the IO thread for GetSettingsDone().
122 void GetSettingsWithUIDone(PrintingContext::Result result); 120 void GetSettingsWithUIDone(PrintingContext::Result result);
123 121
124 // Called on the UI thread to update the print settings. 122 // Called on the UI thread to update the print settings.
125 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings); 123 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings);
126 124
127 // Reports settings back to owner_. 125 // Reports settings back to owner_.
128 void GetSettingsDone(PrintingContext::Result result); 126 void GetSettingsDone(PrintingContext::Result result);
129 127
130 // Use the default settings. When using GTK+ or Mac, this can still end up 128 // Use the default settings. When using GTK+ or Mac, this can still end up
131 // displaying a dialog. So this needs to happen from the UI thread on these 129 // displaying a dialog. So this needs to happen from the UI thread on these
132 // systems. 130 // systems.
133 void UseDefaultSettings(); 131 void UseDefaultSettings();
134 132
133 // Printing context delegate.
134 scoped_ptr<PrintingContext::Delegate> printing_context_delegate_;
135
135 // Information about the printer setting. 136 // Information about the printer setting.
136 scoped_ptr<PrintingContext> printing_context_; 137 scoped_ptr<PrintingContext> printing_context_;
137 138
138 // The printed document. Only has read-only access. 139 // The printed document. Only has read-only access.
139 scoped_refptr<PrintedDocument> document_; 140 scoped_refptr<PrintedDocument> document_;
140 141
141 // The print destination, may be NULL. 142 // The print destination, may be NULL.
142 scoped_refptr<PrintDestinationInterface> destination_; 143 scoped_refptr<PrintDestinationInterface> destination_;
143 144
144 // The print job owning this worker thread. It is guaranteed to outlive this 145 // The print job owning this worker thread. It is guaranteed to outlive this
(...skipping 11 matching lines...) Expand all
156 157
157 // Used to generate a WeakPtr for callbacks. 158 // Used to generate a WeakPtr for callbacks.
158 base::WeakPtrFactory<PrintJobWorker> weak_factory_; 159 base::WeakPtrFactory<PrintJobWorker> weak_factory_;
159 160
160 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); 161 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker);
161 }; 162 };
162 163
163 } // namespace printing 164 } // namespace printing
164 165
165 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ 166 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698