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 COMPONENTS_PRINTING_TEST_PRINT_MOCK_RENDER_THREAD_H_ | 5 #ifndef COMPONENTS_PRINTING_TEST_PRINT_MOCK_RENDER_THREAD_H_ |
6 #define COMPONENTS_PRINTING_TEST_PRINT_MOCK_RENDER_THREAD_H_ | 6 #define COMPONENTS_PRINTING_TEST_PRINT_MOCK_RENDER_THREAD_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "content/public/test/mock_render_thread.h" | 17 #include "content/public/test/mock_render_thread.h" |
| 18 #include "printing/features/features.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 } | 22 } |
22 | 23 |
23 class MockPrinter; | 24 class MockPrinter; |
24 struct PrintHostMsg_DidGetPreviewPageCount_Params; | 25 struct PrintHostMsg_DidGetPreviewPageCount_Params; |
25 struct PrintHostMsg_DidPreviewPage_Params; | 26 struct PrintHostMsg_DidPreviewPage_Params; |
26 struct PrintHostMsg_DidPrintPage_Params; | 27 struct PrintHostMsg_DidPrintPage_Params; |
27 struct PrintHostMsg_ScriptedPrint_Params; | 28 struct PrintHostMsg_ScriptedPrint_Params; |
28 struct PrintMsg_PrintPages_Params; | 29 struct PrintMsg_PrintPages_Params; |
29 struct PrintMsg_Print_Params; | 30 struct PrintMsg_Print_Params; |
30 | 31 |
31 // Extends content::MockRenderThread to know about printing | 32 // Extends content::MockRenderThread to know about printing |
32 class PrintMockRenderThread : public content::MockRenderThread { | 33 class PrintMockRenderThread : public content::MockRenderThread { |
33 public: | 34 public: |
34 PrintMockRenderThread(); | 35 PrintMockRenderThread(); |
35 ~PrintMockRenderThread() override; | 36 ~PrintMockRenderThread() override; |
36 | 37 |
37 // content::RenderThread overrides. | 38 // content::RenderThread overrides. |
38 scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() override; | 39 scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() override; |
39 | 40 |
40 ////////////////////////////////////////////////////////////////////////// | 41 ////////////////////////////////////////////////////////////////////////// |
41 // The following functions are called by the test itself. | 42 // The following functions are called by the test itself. |
42 | 43 |
43 void set_io_task_runner( | 44 void set_io_task_runner( |
44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 45 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
45 | 46 |
46 #if defined(ENABLE_PRINTING) | 47 #if BUILDFLAG(ENABLE_PRINTING) |
47 // Returns the pseudo-printer instance. | 48 // Returns the pseudo-printer instance. |
48 MockPrinter* printer(); | 49 MockPrinter* printer(); |
49 | 50 |
50 // Call with |response| set to true if the user wants to print. | 51 // Call with |response| set to true if the user wants to print. |
51 // False if the user decides to cancel. | 52 // False if the user decides to cancel. |
52 void set_print_dialog_user_response(bool response); | 53 void set_print_dialog_user_response(bool response); |
53 | 54 |
54 // Cancel print preview when print preview has |page| remaining pages. | 55 // Cancel print preview when print preview has |page| remaining pages. |
55 void set_print_preview_cancel_page_number(int page); | 56 void set_print_preview_cancel_page_number(int page); |
56 | 57 |
57 // Get the number of pages to generate for print preview. | 58 // Get the number of pages to generate for print preview. |
58 int print_preview_pages_remaining() const; | 59 int print_preview_pages_remaining() const; |
59 #endif | 60 #endif |
60 | 61 |
61 private: | 62 private: |
62 // Overrides base class implementation to add custom handling for print | 63 // Overrides base class implementation to add custom handling for print |
63 bool OnMessageReceived(const IPC::Message& msg) override; | 64 bool OnMessageReceived(const IPC::Message& msg) override; |
64 | 65 |
65 #if defined(ENABLE_PRINTING) | 66 #if BUILDFLAG(ENABLE_PRINTING) |
66 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 67 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
67 void OnAllocateTempFileForPrinting(int render_view_id, | 68 void OnAllocateTempFileForPrinting(int render_view_id, |
68 base::FileDescriptor* renderer_fd, | 69 base::FileDescriptor* renderer_fd, |
69 int* browser_fd); | 70 int* browser_fd); |
70 void OnTempFileForPrintingWritten(int render_view_id, int browser_fd); | 71 void OnTempFileForPrintingWritten(int render_view_id, int browser_fd); |
71 #endif | 72 #endif |
72 | 73 |
73 // PrintWebViewHelper expects default print settings. | 74 // PrintWebViewHelper expects default print settings. |
74 void OnGetDefaultPrintSettings(PrintMsg_Print_Params* setting); | 75 void OnGetDefaultPrintSettings(PrintMsg_Print_Params* setting); |
75 | 76 |
76 // PrintWebViewHelper expects final print settings from the user. | 77 // PrintWebViewHelper expects final print settings from the user. |
77 void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params, | 78 void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params, |
78 PrintMsg_PrintPages_Params* settings); | 79 PrintMsg_PrintPages_Params* settings); |
79 | 80 |
80 void OnDidGetPrintedPagesCount(int cookie, int number_pages); | 81 void OnDidGetPrintedPagesCount(int cookie, int number_pages); |
81 void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); | 82 void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); |
82 #if defined(ENABLE_PRINT_PREVIEW) | 83 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
83 void OnDidGetPreviewPageCount( | 84 void OnDidGetPreviewPageCount( |
84 const PrintHostMsg_DidGetPreviewPageCount_Params& params); | 85 const PrintHostMsg_DidGetPreviewPageCount_Params& params); |
85 void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params); | 86 void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params); |
86 void OnCheckForCancel(int32_t preview_ui_id, | 87 void OnCheckForCancel(int32_t preview_ui_id, |
87 int preview_request_id, | 88 int preview_request_id, |
88 bool* cancel); | 89 bool* cancel); |
89 #endif | 90 #endif |
90 | 91 |
91 // For print preview, PrintWebViewHelper will update settings. | 92 // For print preview, PrintWebViewHelper will update settings. |
92 void OnUpdatePrintSettings(int document_cookie, | 93 void OnUpdatePrintSettings(int document_cookie, |
(...skipping 14 matching lines...) Expand all Loading... |
107 // Number of pages to generate for print preview. | 108 // Number of pages to generate for print preview. |
108 int print_preview_pages_remaining_; | 109 int print_preview_pages_remaining_; |
109 #endif | 110 #endif |
110 | 111 |
111 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 112 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
112 | 113 |
113 DISALLOW_COPY_AND_ASSIGN(PrintMockRenderThread); | 114 DISALLOW_COPY_AND_ASSIGN(PrintMockRenderThread); |
114 }; | 115 }; |
115 | 116 |
116 #endif // COMPONENTS_PRINTING_TEST_PRINT_MOCK_RENDER_THREAD_H_ | 117 #endif // COMPONENTS_PRINTING_TEST_PRINT_MOCK_RENDER_THREAD_H_ |
OLD | NEW |