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

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

Issue 740983002: Implement window.print() on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed mounir's comments Created 6 years 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
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" 12 #include "content/public/browser/browser_thread.h"
13 #include "printing/page_number.h" 13 #include "printing/page_number.h"
14 #include "printing/print_job_constants.h" 14 #include "printing/print_job_constants.h"
15 #include "printing/printing_context.h" 15 #include "printing/printing_context.h"
16 16
17 #include "chrome/browser/printing/printer_query.h"
Vitaly Buka (NO REVIEWS) 2014/12/09 23:46:48 wrong include location
18
17 namespace base { 19 namespace base {
18 class DictionaryValue; 20 class DictionaryValue;
19 } 21 }
20 22
21 namespace printing { 23 namespace printing {
22 24
23 class PrintJob; 25 class PrintJob;
24 class PrintJobWorkerOwner; 26 class PrintJobWorkerOwner;
25 class PrintedDocument; 27 class PrintedDocument;
26 class PrintedPage; 28 class PrintedPage;
27 29
28 // Worker thread code. It manages the PrintingContext, which can be blocking 30 // Worker thread code. It manages the PrintingContext, which can be blocking
29 // and/or run a message loop. This is the object that generates most 31 // and/or run a message loop. This is the object that generates most
30 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a 32 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a
31 // NotificationTask task to be executed from the right thread, the UI thread. 33 // NotificationTask task to be executed from the right thread, the UI thread.
32 // PrintJob always outlives its worker instance. 34 // PrintJob always outlives its worker instance.
33 class PrintJobWorker { 35 class PrintJobWorker {
34 public: 36 public:
35 PrintJobWorker(int render_process_id, 37 PrintJobWorker(int render_process_id,
36 int render_view_id, 38 int render_view_id,
37 PrintJobWorkerOwner* owner); 39 PrintJobWorkerOwner* owner);
38 virtual ~PrintJobWorker(); 40 virtual ~PrintJobWorker();
39 41
40 void SetNewOwner(PrintJobWorkerOwner* new_owner); 42 void SetNewOwner(PrintJobWorkerOwner* new_owner);
41 43
42 // Initializes the print settings. If |ask_user_for_settings| is true, a 44 // 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. 45 // Print... dialog box will be shown by the browser to ask the user his
46 // preference. If it is SYSTEM_SPECIFIC, showing that dialog box will be
47 // delegated to the system. It's used for script printing on android
48 // (see https://codereview.chromium.org/740983002/)
44 void GetSettings( 49 void GetSettings(
45 bool ask_user_for_settings, 50 PrinterQuery::GetSettingsAskParam ask_settings_type,
46 int document_page_count, 51 int document_page_count,
47 bool has_selection, 52 bool has_selection,
48 MarginType margin_type); 53 MarginType margin_type);
49 54
50 // Set the new print settings. 55 // Set the new print settings.
51 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); 56 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings);
52 57
53 // 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
54 // available. Makes sure the new_document is the right one. 59 // available. Makes sure the new_document is the right one.
55 void StartPrinting(PrintedDocument* new_document); 60 void StartPrinting(PrintedDocument* new_document);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // but sticks with this for consistency. 113 // but sticks with this for consistency.
109 void GetSettingsWithUI( 114 void GetSettingsWithUI(
110 int document_page_count, 115 int document_page_count,
111 bool has_selection); 116 bool has_selection);
112 117
113 // The callback used by PrintingContext::GetSettingsWithUI() to notify this 118 // The callback used by PrintingContext::GetSettingsWithUI() to notify this
114 // object that the print settings are set. This is needed in order to bounce 119 // object that the print settings are set. This is needed in order to bounce
115 // back into the IO thread for GetSettingsDone(). 120 // back into the IO thread for GetSettingsDone().
116 void GetSettingsWithUIDone(PrintingContext::Result result); 121 void GetSettingsWithUIDone(PrintingContext::Result result);
117 122
123 // Called on the UI thread to ask the system to show a print dialog.
124 void ShowSystemDialog();
125
118 // Called on the UI thread to update the print settings. 126 // Called on the UI thread to update the print settings.
119 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings); 127 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings);
120 128
121 // Reports settings back to owner_. 129 // Reports settings back to owner_.
122 void GetSettingsDone(PrintingContext::Result result); 130 void GetSettingsDone(PrintingContext::Result result);
123 131
124 // Use the default settings. When using GTK+ or Mac, this can still end up 132 // 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 133 // displaying a dialog. So this needs to happen from the UI thread on these
126 // systems. 134 // systems.
127 void UseDefaultSettings(); 135 void UseDefaultSettings();
(...skipping 22 matching lines...) Expand all
150 158
151 // Used to generate a WeakPtr for callbacks. 159 // Used to generate a WeakPtr for callbacks.
152 base::WeakPtrFactory<PrintJobWorker> weak_factory_; 160 base::WeakPtrFactory<PrintJobWorker> weak_factory_;
153 161
154 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); 162 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker);
155 }; 163 };
156 164
157 } // namespace printing 165 } // namespace printing
158 166
159 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ 167 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698