| 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 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "chrome/browser/printing/print_preview_data_service.h" | 14 #include "chrome/browser/printing/print_preview_data_service.h" |
| 15 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 15 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 16 | 16 |
| 17 class PrintPreviewDataService; | 17 class PrintPreviewDataService; |
| 18 class PrintPreviewHandler; | 18 class PrintPreviewHandler; |
| 19 struct PrintHostMsg_DidGetPreviewPageCount_Params; |
| 19 | 20 |
| 20 class PrintPreviewUI : public ChromeWebUI { | 21 class PrintPreviewUI : public ChromeWebUI { |
| 21 public: | 22 public: |
| 22 explicit PrintPreviewUI(TabContents* contents); | 23 explicit PrintPreviewUI(TabContents* contents); |
| 23 virtual ~PrintPreviewUI(); | 24 virtual ~PrintPreviewUI(); |
| 24 | 25 |
| 25 // Gets the print preview |data|. |index| is zero-based, and can be | 26 // Gets the print preview |data|. |index| is zero-based, and can be |
| 26 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview | 27 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview |
| 27 // document. | 28 // document. |
| 28 void GetPrintPreviewDataForIndex(int index, | 29 void GetPrintPreviewDataForIndex(int index, |
| 29 scoped_refptr<RefCountedBytes>* data); | 30 scoped_refptr<RefCountedBytes>* data); |
| 30 | 31 |
| 31 // 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 |
| 32 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview | 33 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview |
| 33 // document. | 34 // document. |
| 34 void SetPrintPreviewDataForIndex(int index, const RefCountedBytes* data); | 35 void SetPrintPreviewDataForIndex(int index, const RefCountedBytes* data); |
| 35 | 36 |
| 36 // Clear the existing print preview data. | 37 // Clear the existing print preview data. |
| 37 void ClearAllPreviewData(); | 38 void ClearAllPreviewData(); |
| 38 | 39 |
| 39 // Notifies the Web UI that there is a print preview request. There should be | 40 // Notifies the Web UI that there is a print preview request. There should be |
| 40 // a matching call to OnPreviewDataIsAvailable() or OnPrintPreviewFailed(). | 41 // a matching call to OnPreviewDataIsAvailable() or OnPrintPreviewFailed(). |
| 41 void OnPrintPreviewRequest(); | 42 void OnPrintPreviewRequest(); |
| 42 | 43 |
| 43 // Notifies the Web UI that the print preview will have |page_count| pages. | 44 // Notifies the Web UI about the page count of the request preview. |
| 44 // |is_modifiable| indicates if the preview can be rerendered with different | 45 void OnDidGetPreviewPageCount( |
| 45 // print settings. | 46 const PrintHostMsg_DidGetPreviewPageCount_Params& params); |
| 46 void OnDidGetPreviewPageCount(int document_cookie_, | |
| 47 int page_count, | |
| 48 bool is_modifiable); | |
| 49 | 47 |
| 50 // Notifies the Web UI that the 0-based page |page_number| has been rendered. | 48 // Notifies the Web UI that the 0-based page |page_number| has been rendered. |
| 51 void OnDidPreviewPage(int page_number); | 49 // |preview_request_id| indicates wich request resulted in this response. |
| 50 void OnDidPreviewPage(int page_number, int preview_request_id); |
| 52 | 51 |
| 53 // Notifies the Web UI renderer that preview data is available. | 52 // Notifies the Web UI renderer that preview data is available. |
| 54 // |expected_pages_count| specifies the total number of pages. |job_title| is | 53 // |expected_pages_count| specifies the total number of pages. |job_title| is |
| 55 // the title of the page being previewed. |preview_request_id| indicates which | 54 // the title of the page being previewed. |preview_request_id| indicates which |
| 56 // request resulted in this response. | 55 // request resulted in this response. |
| 57 void OnPreviewDataIsAvailable(int expected_pages_count, | 56 void OnPreviewDataIsAvailable(int expected_pages_count, |
| 58 const string16& job_title, | 57 const string16& job_title, |
| 59 int preview_request_id); | 58 int preview_request_id); |
| 60 | 59 |
| 61 void OnReusePreviewData(int preview_request_id); | 60 void OnReusePreviewData(int preview_request_id); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // The number of print preview requests in flight. | 99 // The number of print preview requests in flight. |
| 101 uint32 request_count_; | 100 uint32 request_count_; |
| 102 | 101 |
| 103 // Document cookie from the initiator renderer. | 102 // Document cookie from the initiator renderer. |
| 104 int document_cookie_; | 103 int document_cookie_; |
| 105 | 104 |
| 106 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); | 105 DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ | 108 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_UI_H_ |
| OLD | NEW |