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_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 scoped_refptr<RefCountedBytes>* data); | 30 scoped_refptr<RefCountedBytes>* data); |
31 | 31 |
32 // Sets the print preview |data|. |index| is zero-based, and can be | 32 // Sets the print preview |data|. |index| is zero-based, and can be |
33 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview | 33 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview |
34 // document. | 34 // document. |
35 void SetPrintPreviewDataForIndex(int index, const RefCountedBytes* data); | 35 void SetPrintPreviewDataForIndex(int index, const RefCountedBytes* data); |
36 | 36 |
37 // Clear the existing print preview data. | 37 // Clear the existing print preview data. |
38 void ClearAllPreviewData(); | 38 void ClearAllPreviewData(); |
39 | 39 |
| 40 // Setters |
| 41 void SetInitiatorTabURL(const std::string& initiator_url); |
| 42 |
40 // Notifies the Web UI that there is a print preview request. There should be | 43 // Notifies the Web UI that there is a print preview request. There should be |
41 // a matching call to OnPreviewDataIsAvailable() or OnPrintPreviewFailed(). | 44 // a matching call to OnPreviewDataIsAvailable() or OnPrintPreviewFailed(). |
42 void OnPrintPreviewRequest(); | 45 void OnPrintPreviewRequest(); |
43 | 46 |
44 // Notifies the Web UI about the page count of the request preview. | 47 // Notifies the Web UI about the page count of the request preview. |
45 void OnDidGetPreviewPageCount( | 48 void OnDidGetPreviewPageCount( |
46 const PrintHostMsg_DidGetPreviewPageCount_Params& params); | 49 const PrintHostMsg_DidGetPreviewPageCount_Params& params); |
47 | 50 |
48 // Notifies the Web UI that the 0-based page |page_number| has been rendered. | 51 // Notifies the Web UI that the 0-based page |page_number| has been rendered. |
49 // |preview_request_id| indicates wich request resulted in this response. | 52 // |preview_request_id| indicates wich request resulted in this response. |
50 void OnDidPreviewPage(int page_number, int preview_request_id); | 53 void OnDidPreviewPage(int page_number, int preview_request_id); |
51 | 54 |
52 // Notifies the Web UI renderer that preview data is available. | 55 // Notifies the Web UI renderer that preview data is available. |
53 // |expected_pages_count| specifies the total number of pages. |job_title| is | 56 // |expected_pages_count| specifies the total number of pages. |job_title| is |
54 // the title of the page being previewed. |preview_request_id| indicates which | 57 // the title of the page being previewed. |preview_request_id| indicates which |
55 // request resulted in this response. | 58 // request resulted in this response. |
56 void OnPreviewDataIsAvailable(int expected_pages_count, | 59 void OnPreviewDataIsAvailable(int expected_pages_count, |
57 const string16& job_title, | 60 const string16& job_title, |
58 int preview_request_id); | 61 int preview_request_id); |
59 | 62 |
60 void OnReusePreviewData(int preview_request_id); | 63 void OnReusePreviewData(int preview_request_id); |
61 | 64 |
62 // Notifies the Web UI that a navigation has occurred in this tab. This is the | 65 // Notifies the Web UI that preview tab is destroyed. This is the last chance |
63 // last chance to communicate with the source tab before the association is | 66 // to communicate with the source tab before the association is erased. |
64 // erased. | 67 void OnTabDestroyed(); |
65 void OnNavigation(); | |
66 | 68 |
67 // Notifies the Web UI that the print preview failed to render. | 69 // Notifies the Web UI that the print preview failed to render. |
68 void OnPrintPreviewFailed(); | 70 void OnPrintPreviewFailed(); |
69 | 71 |
70 // Notifies the Web UI that the print preview request has been cancelled. | 72 // Notifies the Web UI that the print preview request has been cancelled. |
71 void OnPrintPreviewCancelled(); | 73 void OnPrintPreviewCancelled(); |
72 | 74 |
73 // Notifies the Web UI that initiator tab is closed, so we can disable all the | 75 // Notifies the Web UI that initiator tab is closed, so we can disable all the |
74 // controls that need the initiator tab for generating the preview data. | 76 // controls that need the initiator tab for generating the preview data. |
75 void OnInitiatorTabClosed(const std::string& initiator_url); | 77 void OnInitiatorTabClosed(); |
| 78 |
| 79 // Notifies the Web UI that the initiator tab has crashed. |
| 80 void OnInitiatorTabCrashed(); |
76 | 81 |
77 // Notifies the Web UI renderer that file selection has been cancelled. | 82 // Notifies the Web UI renderer that file selection has been cancelled. |
78 void OnFileSelectionCancelled(); | 83 void OnFileSelectionCancelled(); |
79 | 84 |
80 // Returns true if there are pending requests. | 85 // Returns true if there are pending requests. |
81 bool HasPendingRequests(); | 86 bool HasPendingRequests(); |
82 | 87 |
83 int document_cookie(); | 88 int document_cookie(); |
84 | 89 |
85 private: | 90 private: |
86 // Returns the Singleton instance of the PrintPreviewDataService. | 91 // Returns the Singleton instance of the PrintPreviewDataService. |
87 PrintPreviewDataService* print_preview_data_service(); | 92 PrintPreviewDataService* print_preview_data_service(); |
88 | 93 |
89 void DecrementRequestCount(); | 94 void DecrementRequestCount(); |
90 | 95 |
91 base::TimeTicks initial_preview_start_time_; | 96 base::TimeTicks initial_preview_start_time_; |
92 | 97 |
93 // Store the PrintPreviewUI address string. | 98 // Store the PrintPreviewUI address string. |
94 std::string preview_ui_addr_str_; | 99 std::string preview_ui_addr_str_; |
95 | 100 |
96 // Weak pointer to the WebUI handler. | 101 // Weak pointer to the WebUI handler. |
97 PrintPreviewHandler* handler_; | 102 PrintPreviewHandler* handler_; |
98 | 103 |
99 // The number of print preview requests in flight. | 104 // The number of print preview requests in flight. |
100 uint32 request_count_; | 105 uint32 request_count_; |
101 | 106 |
102 // Document cookie from the initiator renderer. | 107 // Document cookie from the initiator renderer. |
103 int document_cookie_; | 108 int document_cookie_; |
104 | 109 |
| 110 // Store the |initiator_url| in order to display an accurate error message |
| 111 // when the initiator tab is closed/crashed. |
| 112 std::string initiator_url_; |
| 113 |
105 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); | 114 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); |
106 }; | 115 }; |
107 | 116 |
108 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 117 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
OLD | NEW |