| 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 "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 #include "ui/gfx/native_widget_types.h" | 16 |
| 17 class PrintingUIWebContentsObserver; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class DictionaryValue; | 20 class DictionaryValue; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace printing { | 23 namespace printing { |
| 23 | 24 |
| 24 class PrintedDocument; | 25 class PrintedDocument; |
| 25 class PrintedPage; | 26 class PrintedPage; |
| 26 class PrintJob; | 27 class PrintJob; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 virtual ~PrintJobWorker(); | 39 virtual ~PrintJobWorker(); |
| 39 | 40 |
| 40 void SetNewOwner(PrintJobWorkerOwner* new_owner); | 41 void SetNewOwner(PrintJobWorkerOwner* new_owner); |
| 41 | 42 |
| 42 // Set a destination for print. | 43 // Set a destination for print. |
| 43 // This supercedes the document's rendering destination. | 44 // This supercedes the document's rendering destination. |
| 44 void SetPrintDestination(PrintDestinationInterface* destination); | 45 void SetPrintDestination(PrintDestinationInterface* destination); |
| 45 | 46 |
| 46 // Initializes the print settings. If |ask_user_for_settings| is true, a | 47 // Initializes the print settings. If |ask_user_for_settings| is true, a |
| 47 // Print... dialog box will be shown to ask the user his preference. | 48 // Print... dialog box will be shown to ask the user his preference. |
| 48 void GetSettings(bool ask_user_for_settings, | 49 void GetSettings( |
| 49 gfx::NativeView parent_view, | 50 bool ask_user_for_settings, |
| 50 int document_page_count, | 51 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer, |
| 51 bool has_selection, | 52 int document_page_count, |
| 52 MarginType margin_type); | 53 bool has_selection, |
| 54 MarginType margin_type); |
| 53 | 55 |
| 54 // Set the new print settings. This function takes ownership of | 56 // Set the new print settings. This function takes ownership of |
| 55 // |new_settings|. | 57 // |new_settings|. |
| 56 void SetSettings(const base::DictionaryValue* const new_settings); | 58 void SetSettings(const base::DictionaryValue* const new_settings); |
| 57 | 59 |
| 58 // Starts the printing loop. Every pages are printed as soon as the data is | 60 // 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. | 61 // available. Makes sure the new_document is the right one. |
| 60 void StartPrinting(PrintedDocument* new_document); | 62 void StartPrinting(PrintedDocument* new_document); |
| 61 | 63 |
| 62 // Updates the printed document. | 64 // Updates the printed document. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 88 // Closes the job since spooling is done. | 90 // Closes the job since spooling is done. |
| 89 void OnDocumentDone(); | 91 void OnDocumentDone(); |
| 90 | 92 |
| 91 // Discards the current document, the current page and cancels the printing | 93 // Discards the current document, the current page and cancels the printing |
| 92 // context. | 94 // context. |
| 93 void OnFailure(); | 95 void OnFailure(); |
| 94 | 96 |
| 95 // Asks the user for print settings. Must be called on the UI thread. | 97 // Asks the user for print settings. Must be called on the UI thread. |
| 96 // Required on Mac and Linux. Windows can display UI from non-main threads, | 98 // Required on Mac and Linux. Windows can display UI from non-main threads, |
| 97 // but sticks with this for consistency. | 99 // but sticks with this for consistency. |
| 98 void GetSettingsWithUI(gfx::NativeView parent_view, | 100 void GetSettingsWithUI( |
| 99 int document_page_count, | 101 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer, |
| 100 bool has_selection); | 102 int document_page_count, |
| 103 bool has_selection); |
| 101 | 104 |
| 102 // The callback used by PrintingContext::GetSettingsWithUI() to notify this | 105 // The callback used by PrintingContext::GetSettingsWithUI() to notify this |
| 103 // object that the print settings are set. This is needed in order to bounce | 106 // object that the print settings are set. This is needed in order to bounce |
| 104 // back into the IO thread for GetSettingsDone(). | 107 // back into the IO thread for GetSettingsDone(). |
| 105 void GetSettingsWithUIDone(PrintingContext::Result result); | 108 void GetSettingsWithUIDone(PrintingContext::Result result); |
| 106 | 109 |
| 107 // Called on the UI thread to update the print settings. This function takes | 110 // Called on the UI thread to update the print settings. This function takes |
| 108 // the ownership of |new_settings|. | 111 // the ownership of |new_settings|. |
| 109 void UpdatePrintSettings(const base::DictionaryValue* const new_settings); | 112 void UpdatePrintSettings(const base::DictionaryValue* const new_settings); |
| 110 | 113 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 133 PageNumber page_number_; | 136 PageNumber page_number_; |
| 134 | 137 |
| 135 // Used to generate a WeakPtr for callbacks. | 138 // Used to generate a WeakPtr for callbacks. |
| 136 base::WeakPtrFactory<PrintJobWorker> weak_factory_; | 139 base::WeakPtrFactory<PrintJobWorker> weak_factory_; |
| 137 | 140 |
| 138 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); | 141 DISALLOW_COPY_AND_ASSIGN(PrintJobWorker); |
| 139 }; | 142 }; |
| 140 | 143 |
| 141 } // namespace printing | 144 } // namespace printing |
| 142 | 145 |
| 143 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ | 146 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H_ |
| OLD | NEW |