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

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

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

Powered by Google App Engine
This is Rietveld 408576698