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