| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_VIEW_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "content/browser/tab_contents/tab_contents_observer.h" | 11 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 12 #include "content/common/notification_observer.h" | 12 #include "content/common/notification_observer.h" |
| 13 #include "content/common/notification_registrar.h" | 13 #include "content/common/notification_registrar.h" |
| 14 #include "printing/printed_pages_source.h" | 14 #include "printing/printed_pages_source.h" |
| 15 | 15 |
| 16 class RenderViewHost; | 16 class RenderViewHost; |
| 17 class TabContentsWrapper; | 17 class TabContentsWrapper; |
| 18 struct PrintHostMsg_DidPrintPage_Params; | 18 struct PrintHostMsg_DidPrintPage_Params; |
| 19 | 19 |
| 20 namespace printing { | 20 namespace printing { |
| 21 | 21 |
| 22 class JobEventDetails; | 22 class JobEventDetails; |
| 23 class PrintJob; | 23 class PrintJob; |
| 24 class PrintJobWorkerOwner; | 24 class PrintJobWorkerOwner; |
| 25 class PrintViewManagerDelegate; |
| 25 | 26 |
| 26 // Manages the print commands in relation to a TabContents. TabContents | 27 // Manages the print commands in relation to a TabContents. TabContents |
| 27 // delegates a few printing related commands to this instance. | 28 // delegates a few printing related commands to this instance. |
| 28 class PrintViewManager : public NotificationObserver, | 29 class PrintViewManager : public NotificationObserver, |
| 29 public PrintedPagesSource, | 30 public PrintedPagesSource, |
| 30 public TabContentsObserver { | 31 public TabContentsObserver { |
| 31 public: | 32 public: |
| 32 explicit PrintViewManager(TabContentsWrapper* tab); | 33 explicit PrintViewManager(TabContentsWrapper* tab); |
| 33 virtual ~PrintViewManager(); | 34 virtual ~PrintViewManager(); |
| 34 | 35 |
| 35 // Override the title for this PrintViewManager's PrintJobs using the title | 36 // Override the title for this PrintViewManager's PrintJobs using the title |
| 36 // in |tab_contents|. | 37 // in |tab_contents|. |
| 37 void OverrideTitle(TabContents* tab_contents); | 38 void OverrideTitle(TabContents* tab_contents); |
| 38 | 39 |
| 39 // Prints the current document immediately. Since the rendering is | 40 // Prints the current document immediately. Since the rendering is |
| 40 // asynchronous, the actual printing will not be completed on the return of | 41 // asynchronous, the actual printing will not be completed on the return of |
| 41 // this function. Returns false if printing is impossible at the moment. | 42 // this function. |delegate| is optional and may be used to be notified when |
| 42 bool PrintNow(); | 43 // the print dialog is shown. Returns false if printing is impossible at the |
| 44 // moment. |
| 45 bool PrintNow(PrintViewManagerDelegate* delegate); |
| 43 | 46 |
| 44 // Initiate print preview of the current document by first notifying the | 47 // Initiate print preview of the current document by first notifying the |
| 45 // renderer. Since this happens asynchronous, the print preview tab creation | 48 // renderer. Since this happens asynchronous, the print preview tab creation |
| 46 // will not be completed on the return of this function. Returns false if | 49 // will not be completed on the return of this function. Returns false if |
| 47 // print preview is impossible at the moment. | 50 // print preview is impossible at the moment. |
| 48 bool PrintPreviewNow(); | 51 bool PrintPreviewNow(); |
| 49 | 52 |
| 50 // Handles cancelled preview printing request. | 53 // Handles cancelled preview printing request. |
| 51 void PreviewPrintingRequestCancelled(); | 54 void PreviewPrintingRequestCancelled(); |
| 52 | 55 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 | 67 |
| 65 // Terminates or cancels the print job if one was pending. | 68 // Terminates or cancels the print job if one was pending. |
| 66 virtual void RenderViewGone(); | 69 virtual void RenderViewGone(); |
| 67 | 70 |
| 68 // Cancels the print job. | 71 // Cancels the print job. |
| 69 virtual void StopNavigation(); | 72 virtual void StopNavigation(); |
| 70 | 73 |
| 71 private: | 74 private: |
| 72 // IPC Message handlers. | 75 // IPC Message handlers. |
| 73 void OnDidGetPrintedPagesCount(int cookie, int number_pages); | 76 void OnDidGetPrintedPagesCount(int cookie, int number_pages); |
| 77 void OnDidShowPrintDialog(); |
| 74 void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); | 78 void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); |
| 75 void OnPrintingFailed(int cookie); | 79 void OnPrintingFailed(int cookie); |
| 76 | 80 |
| 77 // Processes a NOTIFY_PRINT_JOB_EVENT notification. | 81 // Processes a NOTIFY_PRINT_JOB_EVENT notification. |
| 78 void OnNotifyPrintJobEvent(const JobEventDetails& event_details); | 82 void OnNotifyPrintJobEvent(const JobEventDetails& event_details); |
| 79 | 83 |
| 80 // Requests the RenderView to render all the missing pages for the print job. | 84 // Requests the RenderView to render all the missing pages for the print job. |
| 81 // Noop if no print job is pending. Returns true if at least one page has been | 85 // Noop if no print job is pending. Returns true if at least one page has been |
| 82 // requested to the renderer. | 86 // requested to the renderer. |
| 83 bool RenderAllMissingPagesNow(); | 87 bool RenderAllMissingPagesNow(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 147 |
| 144 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 148 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 145 // Set to true when OnDidPrintPage() should be expecting the first page. | 149 // Set to true when OnDidPrintPage() should be expecting the first page. |
| 146 bool expecting_first_page_; | 150 bool expecting_first_page_; |
| 147 #endif | 151 #endif |
| 148 | 152 |
| 149 // Title override. | 153 // Title override. |
| 150 bool is_title_overridden_; | 154 bool is_title_overridden_; |
| 151 string16 overridden_title_; | 155 string16 overridden_title_; |
| 152 | 156 |
| 157 // Weak pointer to a delegate that is notified when the print dialog is shown. |
| 158 PrintViewManagerDelegate* delegate_; |
| 159 |
| 153 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); | 160 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); |
| 154 }; | 161 }; |
| 155 | 162 |
| 156 } // namespace printing | 163 } // namespace printing |
| 157 | 164 |
| 158 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 165 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
| OLD | NEW |