OLD | NEW |
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 "chrome/browser/printing/printer_query.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "printing/page_number.h" | 14 #include "printing/page_number.h" |
14 #include "printing/print_job_constants.h" | 15 #include "printing/print_job_constants.h" |
15 #include "printing/printing_context.h" | 16 #include "printing/printing_context.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class DictionaryValue; | 19 class DictionaryValue; |
19 } | 20 } |
20 | 21 |
21 namespace printing { | 22 namespace printing { |
(...skipping 10 matching lines...) Loading... |
32 // PrintJob always outlives its worker instance. | 33 // PrintJob always outlives its worker instance. |
33 class PrintJobWorker { | 34 class PrintJobWorker { |
34 public: | 35 public: |
35 PrintJobWorker(int render_process_id, | 36 PrintJobWorker(int render_process_id, |
36 int render_view_id, | 37 int render_view_id, |
37 PrintJobWorkerOwner* owner); | 38 PrintJobWorkerOwner* owner); |
38 virtual ~PrintJobWorker(); | 39 virtual ~PrintJobWorker(); |
39 | 40 |
40 void SetNewOwner(PrintJobWorkerOwner* new_owner); | 41 void SetNewOwner(PrintJobWorkerOwner* new_owner); |
41 | 42 |
42 // Initializes the print settings. If |ask_user_for_settings| is true, a | 43 // Initializes the print settings. If |ask_settings_type| is ASK_USER, a |
43 // Print... dialog box will be shown to ask the user his preference. | 44 // Print... dialog box will be shown by the browser to ask the user his |
| 45 // preference. If it is SYSTEM_SPECIFIC, showing that dialog box will be |
| 46 // delegated to the system. It's used for script printing on android |
| 47 // (see https://codereview.chromium.org/740983002/) |
44 void GetSettings( | 48 void GetSettings( |
45 bool ask_user_for_settings, | 49 PrinterQuery::GetSettingsAskParam ask_settings_type, |
46 int document_page_count, | 50 int document_page_count, |
47 bool has_selection, | 51 bool has_selection, |
48 MarginType margin_type); | 52 MarginType margin_type); |
49 | 53 |
50 // Set the new print settings. | 54 // Set the new print settings. |
51 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); | 55 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); |
52 | 56 |
53 // 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 |
54 // available. Makes sure the new_document is the right one. | 58 // available. Makes sure the new_document is the right one. |
55 void StartPrinting(PrintedDocument* new_document); | 59 void StartPrinting(PrintedDocument* new_document); |
(...skipping 52 matching lines...) Loading... |
108 // but sticks with this for consistency. | 112 // but sticks with this for consistency. |
109 void GetSettingsWithUI( | 113 void GetSettingsWithUI( |
110 int document_page_count, | 114 int document_page_count, |
111 bool has_selection); | 115 bool has_selection); |
112 | 116 |
113 // The callback used by PrintingContext::GetSettingsWithUI() to notify this | 117 // The callback used by PrintingContext::GetSettingsWithUI() to notify this |
114 // 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 |
115 // back into the IO thread for GetSettingsDone(). | 119 // back into the IO thread for GetSettingsDone(). |
116 void GetSettingsWithUIDone(PrintingContext::Result result); | 120 void GetSettingsWithUIDone(PrintingContext::Result result); |
117 | 121 |
| 122 // Called on the UI thread to ask the system to show a print dialog. |
| 123 void ShowSystemDialog(); |
| 124 |
118 // Called on the UI thread to update the print settings. | 125 // Called on the UI thread to update the print settings. |
119 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings); | 126 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings); |
120 | 127 |
121 // Reports settings back to owner_. | 128 // Reports settings back to owner_. |
122 void GetSettingsDone(PrintingContext::Result result); | 129 void GetSettingsDone(PrintingContext::Result result); |
123 | 130 |
124 // Use the default settings. When using GTK+ or Mac, this can still end up | 131 // Use the default settings. When using GTK+ or Mac, this can still end up |
125 // displaying a dialog. So this needs to happen from the UI thread on these | 132 // displaying a dialog. So this needs to happen from the UI thread on these |
126 // systems. | 133 // systems. |
127 void UseDefaultSettings(); | 134 void UseDefaultSettings(); |
(...skipping 22 matching lines...) Loading... |
150 | 157 |
151 // Used to generate a WeakPtr for callbacks. | 158 // Used to generate a WeakPtr for callbacks. |
152 base::WeakPtrFactory<PrintJobWorker> weak_factory_; | 159 base::WeakPtrFactory<PrintJobWorker> weak_factory_; |
153 | 160 |
154 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); | 161 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); |
155 }; | 162 }; |
156 | 163 |
157 } // namespace printing | 164 } // namespace printing |
158 | 165 |
159 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ | 166 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ |
OLD | NEW |