| 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 23 matching lines...) Expand all Loading... |
| 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 | 40 // Setters |
| 41 void SetInitiatorTabURLAndTitle(const std::string& initiator_url, | 41 void SetInitiatorTabURLAndTitle(const std::string& initiator_url, |
| 42 const string16& initiator_tab_title); | 42 const string16& initiator_tab_title); |
| 43 | 43 |
| 44 // Notifies the Web UI that there is a print preview request. There should be | 44 // Determines whether to cancel a print preview request based on |
| 45 // a matching call to OnPreviewDataIsAvailable() or OnPrintPreviewFailed(). | 45 // |preview_ui_id| and |request_id|. |
| 46 void OnPrintPreviewRequest(); | 46 // Only called on the IO thread. (thread safe) |
| 47 static void GetCurrentPrintPreviewStatus(int preview_ui_id, |
| 48 int request_id, |
| 49 bool* cancel); |
| 50 |
| 51 int uid() const; |
| 52 |
| 53 // Notifies the Web UI of a print preview request with |request_id|. |
| 54 void OnPrintPreviewRequest(int request_id); |
| 47 | 55 |
| 48 // Notifies the Web UI about the page count of the request preview. | 56 // Notifies the Web UI about the page count of the request preview. |
| 49 void OnDidGetPreviewPageCount( | 57 void OnDidGetPreviewPageCount( |
| 50 const PrintHostMsg_DidGetPreviewPageCount_Params& params); | 58 const PrintHostMsg_DidGetPreviewPageCount_Params& params); |
| 51 | 59 |
| 52 // Notifies the Web UI that the 0-based page |page_number| has been rendered. | 60 // Notifies the Web UI that the 0-based page |page_number| has been rendered. |
| 53 // |preview_request_id| indicates wich request resulted in this response. | 61 // |preview_request_id| indicates wich request resulted in this response. |
| 54 void OnDidPreviewPage(int page_number, int preview_request_id); | 62 void OnDidPreviewPage(int page_number, int preview_request_id); |
| 55 | 63 |
| 56 // Notifies the Web UI renderer that preview data is available. | 64 // Notifies the Web UI renderer that preview data is available. |
| 57 // |expected_pages_count| specifies the total number of pages. | 65 // |expected_pages_count| specifies the total number of pages. |
| 58 // |preview_request_id| indicates which request resulted in this response. | 66 // |preview_request_id| indicates which request resulted in this response. |
| 59 void OnPreviewDataIsAvailable(int expected_pages_count, | 67 void OnPreviewDataIsAvailable(int expected_pages_count, |
| 60 int preview_request_id); | 68 int preview_request_id); |
| 61 | 69 |
| 62 void OnReusePreviewData(int preview_request_id); | 70 void OnReusePreviewData(int preview_request_id); |
| 63 | 71 |
| 64 // Notifies the Web UI that preview tab is destroyed. This is the last chance | 72 // Notifies the Web UI that preview tab is destroyed. This is the last chance |
| 65 // to communicate with the source tab before the association is erased. | 73 // to communicate with the source tab before the association is erased. |
| 66 void OnTabDestroyed(); | 74 void OnTabDestroyed(); |
| 67 | 75 |
| 68 // Notifies the Web UI that the print preview failed to render. | 76 // Notifies the Web UI that the print preview failed to render. |
| 69 void OnPrintPreviewFailed(); | 77 void OnPrintPreviewFailed(); |
| 70 | 78 |
| 71 // Notifies the Web UI that the print preview request has been cancelled. | |
| 72 void OnPrintPreviewCancelled(); | |
| 73 | |
| 74 // Notifies the Web UI that initiator tab is closed, so we can disable all the | 79 // Notifies the Web UI that initiator tab is closed, so we can disable all the |
| 75 // controls that need the initiator tab for generating the preview data. | 80 // controls that need the initiator tab for generating the preview data. |
| 76 void OnInitiatorTabClosed(); | 81 void OnInitiatorTabClosed(); |
| 77 | 82 |
| 78 // Notifies the Web UI that the initiator tab has crashed. | 83 // Notifies the Web UI that the initiator tab has crashed. |
| 79 void OnInitiatorTabCrashed(); | 84 void OnInitiatorTabCrashed(); |
| 80 | 85 |
| 81 // Notifies the Web UI renderer that file selection has been cancelled. | 86 // Notifies the Web UI renderer that file selection has been cancelled. |
| 82 void OnFileSelectionCancelled(); | 87 void OnFileSelectionCancelled(); |
| 83 | 88 |
| 84 // Returns true if there are pending requests. | |
| 85 bool HasPendingRequests(); | |
| 86 | |
| 87 int document_cookie(); | |
| 88 | |
| 89 private: | 89 private: |
| 90 // Returns the Singleton instance of the PrintPreviewDataService. | 90 // Returns the Singleton instance of the PrintPreviewDataService. |
| 91 PrintPreviewDataService* print_preview_data_service(); | 91 PrintPreviewDataService* print_preview_data_service(); |
| 92 | 92 |
| 93 void DecrementRequestCount(); | |
| 94 | |
| 95 base::TimeTicks initial_preview_start_time_; | 93 base::TimeTicks initial_preview_start_time_; |
| 96 | 94 |
| 97 // Store the PrintPreviewUI address string. | 95 // A unique id to identify this print preview tab. |
| 96 int uid_; |
| 97 |
| 98 // The |uid_| in string form. |
| 98 std::string preview_ui_addr_str_; | 99 std::string preview_ui_addr_str_; |
| 99 | 100 |
| 100 // Weak pointer to the WebUI handler. | 101 // Weak pointer to the WebUI handler. |
| 101 PrintPreviewHandler* handler_; | 102 PrintPreviewHandler* handler_; |
| 102 | 103 |
| 103 // The number of print preview requests in flight. | |
| 104 uint32 request_count_; | |
| 105 | |
| 106 // Document cookie from the initiator renderer. | |
| 107 int document_cookie_; | |
| 108 | |
| 109 // Store the |initiator_url| in order to display an accurate error message | 104 // Store the |initiator_url| in order to display an accurate error message |
| 110 // when the initiator tab is closed/crashed. | 105 // when the initiator tab is closed/crashed. |
| 111 std::string initiator_url_; | 106 std::string initiator_url_; |
| 112 | 107 |
| 113 // Store the initiator tab title, used for populating the print preview tab | 108 // Store the initiator tab title, used for populating the print preview tab |
| 114 // title. | 109 // title. |
| 115 string16 initiator_tab_title_; | 110 string16 initiator_tab_title_; |
| 116 | 111 |
| 117 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); | 112 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); |
| 118 }; | 113 }; |
| 119 | 114 |
| 120 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 115 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
| OLD | NEW |