OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "android_webview/browser/aw_print_manager.h" | 5 #include "android_webview/browser/aw_print_manager.h" |
6 | 6 |
7 #include "components/printing/browser/print_manager_utils.h" | 7 #include "components/printing/browser/print_manager_utils.h" |
8 #include "components/printing/common/print_messages.h" | 8 #include "components/printing/common/print_messages.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/render_frame_host.h" | |
11 | 10 |
12 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwPrintManager); | 11 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwPrintManager); |
13 | 12 |
14 namespace android_webview { | 13 namespace android_webview { |
15 | 14 |
16 // static | 15 // static |
17 AwPrintManager* AwPrintManager::CreateForWebContents( | 16 AwPrintManager* AwPrintManager::CreateForWebContents( |
18 content::WebContents* contents, | 17 content::WebContents* contents, |
19 const printing::PrintSettings& settings, | 18 const printing::PrintSettings& settings, |
20 const base::FileDescriptor& file_descriptor, | 19 const base::FileDescriptor& file_descriptor, |
(...skipping 17 matching lines...) Expand all Loading... |
38 } | 37 } |
39 | 38 |
40 AwPrintManager::~AwPrintManager() { | 39 AwPrintManager::~AwPrintManager() { |
41 } | 40 } |
42 | 41 |
43 bool AwPrintManager::PrintNow() { | 42 bool AwPrintManager::PrintNow() { |
44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
45 return Send(new PrintMsg_PrintPages(routing_id())); | 44 return Send(new PrintMsg_PrintPages(routing_id())); |
46 } | 45 } |
47 | 46 |
48 bool AwPrintManager::OnMessageReceived( | 47 bool AwPrintManager::OnMessageReceived(const IPC::Message& message) { |
49 const IPC::Message& message, | |
50 content::RenderFrameHost* render_frame_host) { | |
51 bool handled = true; | 48 bool handled = true; |
52 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(AwPrintManager, message, render_frame_host) | 49 IPC_BEGIN_MESSAGE_MAP(AwPrintManager, message) |
53 IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY( | 50 IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings, |
54 PrintHostMsg_GetDefaultPrintSettings, OnGetDefaultPrintSettings) | 51 OnGetDefaultPrintSettings) |
55 IPC_MESSAGE_UNHANDLED(handled = false) | 52 IPC_MESSAGE_UNHANDLED(handled = false) |
56 IPC_END_MESSAGE_MAP() | 53 IPC_END_MESSAGE_MAP() |
57 return handled ? true | 54 return handled ? true : PrintManager::OnMessageReceived(message); |
58 : PrintManager::OnMessageReceived(message, render_frame_host); | |
59 } | 55 } |
60 | 56 |
61 void AwPrintManager::OnGetDefaultPrintSettings( | 57 void AwPrintManager::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { |
62 content::RenderFrameHost* render_frame_host, | |
63 IPC::Message* reply_msg) { | |
64 // Unlike the printing_message_filter, we do process this in UI thread. | 58 // Unlike the printing_message_filter, we do process this in UI thread. |
65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
66 PrintMsg_Print_Params params; | 60 PrintMsg_Print_Params params; |
67 printing::RenderParamsFromPrintSettings(settings_, ¶ms); | 61 printing::RenderParamsFromPrintSettings(settings_, ¶ms); |
68 params.document_cookie = cookie_; | 62 params.document_cookie = cookie_; |
69 PrintHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); | 63 PrintHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); |
70 render_frame_host->Send(reply_msg); | 64 Send(reply_msg); |
71 } | 65 } |
72 | 66 |
73 } // namespace android_webview | 67 } // namespace android_webview |
OLD | NEW |