OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/pepper/pepper_printing_host.h" |
| 6 |
| 7 #include "ppapi/c/dev/pp_print_settings_dev.h" |
| 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/host/dispatch_host_message.h" |
| 10 #include "ppapi/host/host_message_context.h" |
| 11 #include "ppapi/host/ppapi_host.h" |
| 12 #include "ppapi/proxy/ppapi_messages.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 PepperPrintingHost::PepperPrintingHost( |
| 17 ppapi::host::PpapiHost* host, |
| 18 PP_Instance instance, |
| 19 PP_Resource resource, |
| 20 scoped_ptr<PepperPrintSettingsManager> print_settings_manager) |
| 21 : ResourceHost(host, instance, resource), |
| 22 print_settings_manager_(print_settings_manager.Pass()), |
| 23 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 24 } |
| 25 |
| 26 PepperPrintingHost::~PepperPrintingHost() { |
| 27 } |
| 28 |
| 29 int32_t PepperPrintingHost::OnResourceMessageReceived( |
| 30 const IPC::Message& msg, |
| 31 ppapi::host::HostMessageContext* context) { |
| 32 IPC_BEGIN_MESSAGE_MAP(PepperPrintingHost, msg) |
| 33 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( |
| 34 PpapiHostMsg_Printing_GetDefaultPrintSettings, |
| 35 OnMsgGetDefaultPrintSettings) |
| 36 IPC_END_MESSAGE_MAP() |
| 37 return PP_ERROR_FAILED; |
| 38 } |
| 39 |
| 40 int32_t PepperPrintingHost::OnMsgGetDefaultPrintSettings( |
| 41 ppapi::host::HostMessageContext* context) { |
| 42 print_settings_manager_->GetDefaultPrintSettings( |
| 43 base::Bind(&PepperPrintingHost::PrintSettingsCallback, |
| 44 weak_factory_.GetWeakPtr(), context->MakeReplyParams())); |
| 45 return PP_OK_COMPLETIONPENDING; |
| 46 } |
| 47 |
| 48 void PepperPrintingHost::PrintSettingsCallback( |
| 49 ppapi::proxy::ResourceMessageReplyParams reply_params, |
| 50 PepperPrintSettingsManager::Result result) { |
| 51 reply_params.set_result(result.second); |
| 52 host()->SendReply(reply_params, |
| 53 PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply(result.first)); |
| 54 } |
| 55 |
| 56 |
| 57 } // namespace content |
OLD | NEW |