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