OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PRINTING_PDF_TO_EMF_CONVERTER_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_ |
6 #define CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_ | 6 #define CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
12 | 12 |
13 namespace printing { | 13 namespace printing { |
14 | 14 |
15 class MetafilePlayer; | 15 class MetafilePlayer; |
16 struct PdfRenderSettings; | 16 struct PdfRenderSettings; |
17 | 17 |
18 class PdfConverter { | 18 class PdfConverter { |
19 public: | 19 public: |
20 using StartCallback = base::Callback<void(int page_count)>; | 20 using StartCallback = base::Callback<void(int page_count)>; |
21 using GetPageCallback = | 21 using GetPageCallback = |
22 base::Callback<void(int page_number, | 22 base::Callback<void(int page_number, |
23 float scale_factor, | 23 float scale_factor, |
24 std::unique_ptr<MetafilePlayer> file)>; | 24 std::unique_ptr<MetafilePlayer> file)>; |
25 | |
26 virtual ~PdfConverter(); | 25 virtual ~PdfConverter(); |
27 | 26 |
28 static std::unique_ptr<PdfConverter> CreatePdfToEmfConverter(); | |
29 | |
30 // Starts conversion of PDF provided as |data|. Calls |start_callback| | 27 // Starts conversion of PDF provided as |data|. Calls |start_callback| |
31 // with positive |page_count|. |page_count| is 0 if initialization failed. | 28 // with positive |page_count|. |page_count| is 0 if initialization failed. |
32 virtual void Start(const scoped_refptr<base::RefCountedMemory>& data, | 29 static std::unique_ptr<PdfConverter> StartPdfConverter( |
33 const PdfRenderSettings& conversion_settings, | 30 const scoped_refptr<base::RefCountedMemory>& data, |
34 const StartCallback& start_callback) = 0; | 31 const PdfRenderSettings& conversion_settings, |
| 32 const StartCallback& start_callback); |
35 | 33 |
36 // Requests conversion of the page. |page_number| is 0-base page number in | 34 // Requests conversion of the page. |page_number| is 0-base page number in |
37 // PDF provided in Start() call. | 35 // PDF provided in Start() call. |
38 // Calls |get_page_callback| after conversion. |emf| of callback in not NULL | 36 // Calls |get_page_callback| after conversion. |emf| of callback in not NULL |
39 // if conversion succeeded. | 37 // if conversion succeeded. |
40 virtual void GetPage(int page_number, | 38 virtual void GetPage(int page_number, |
41 const GetPageCallback& get_page_callback) = 0; | 39 const GetPageCallback& get_page_callback) = 0; |
42 }; | 40 }; |
43 | |
44 } // namespace printing | 41 } // namespace printing |
45 | 42 |
46 #endif // CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_ | 43 #endif // CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_ |
OLD | NEW |