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