| 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 12 matching lines...) Expand all Loading... |
| 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_user_for_settings| is true, a |
| 43 // Print... dialog box will be shown to ask the user his preference. | 44 // Print... dialog box will be shown to ask the user his preference. |
| 45 // |is_scripted| should be true for calls coming straight from window.print(). |
| 44 void GetSettings( | 46 void GetSettings( |
| 45 bool ask_user_for_settings, | 47 bool ask_user_for_settings, |
| 46 int document_page_count, | 48 int document_page_count, |
| 47 bool has_selection, | 49 bool has_selection, |
| 48 MarginType margin_type); | 50 MarginType margin_type, |
| 51 bool is_scripted); |
| 49 | 52 |
| 50 // Set the new print settings. | 53 // Set the new print settings. |
| 51 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); | 54 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings); |
| 52 | 55 |
| 53 // Starts the printing loop. Every pages are printed as soon as the data is | 56 // 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. | 57 // available. Makes sure the new_document is the right one. |
| 55 void StartPrinting(PrintedDocument* new_document); | 58 void StartPrinting(PrintedDocument* new_document); |
| 56 | 59 |
| 57 // Updates the printed document. | 60 // Updates the printed document. |
| 58 void OnDocumentChanged(PrintedDocument* new_document); | 61 void OnDocumentChanged(PrintedDocument* new_document); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 104 |
| 102 // Discards the current document, the current page and cancels the printing | 105 // Discards the current document, the current page and cancels the printing |
| 103 // context. | 106 // context. |
| 104 void OnFailure(); | 107 void OnFailure(); |
| 105 | 108 |
| 106 // Asks the user for print settings. Must be called on the UI thread. | 109 // Asks the user for print settings. Must be called on the UI thread. |
| 107 // Required on Mac and Linux. Windows can display UI from non-main threads, | 110 // Required on Mac and Linux. Windows can display UI from non-main threads, |
| 108 // but sticks with this for consistency. | 111 // but sticks with this for consistency. |
| 109 void GetSettingsWithUI( | 112 void GetSettingsWithUI( |
| 110 int document_page_count, | 113 int document_page_count, |
| 111 bool has_selection); | 114 bool has_selection, |
| 115 bool is_scripted); |
| 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 |
| 118 // Called on the UI thread to update the print settings. | 122 // Called on the UI thread to update the print settings. |
| 119 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings); | 123 void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings); |
| 120 | 124 |
| 121 // Reports settings back to owner_. | 125 // Reports settings back to owner_. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 150 | 154 |
| 151 // Used to generate a WeakPtr for callbacks. | 155 // Used to generate a WeakPtr for callbacks. |
| 152 base::WeakPtrFactory<PrintJobWorker> weak_factory_; | 156 base::WeakPtrFactory<PrintJobWorker> weak_factory_; |
| 153 | 157 |
| 154 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); | 158 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); |
| 155 }; | 159 }; |
| 156 | 160 |
| 157 } // namespace printing | 161 } // namespace printing |
| 158 | 162 |
| 159 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ | 163 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ |
| OLD | NEW |