Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: content/browser/renderer_host/pepper/pepper_printing_host.cc

Issue 10826072: Implement browser side of PPB_Printing resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 namespace {
17
18 void PrintSettingsCallback(
brettw 2012/09/18 21:41:38 You should be able to make this a member function.
raymes 2012/09/18 23:43:57 Cool I wasn't sure about that. Done.
19 base::WeakPtr<PepperPrintingHost> printing_host,
20 ppapi::proxy::ResourceMessageReplyParams reply_params,
21 PepperPrintSettingsManager::Result result) {
22 if (!printing_host.get())
23 return;
24 reply_params.set_result(result.second);
25 printing_host->host()->SendReply(reply_params,
26 PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply(result.first));
27 }
28
29 } // namespace
30
31 PepperPrintingHost::PepperPrintingHost(
32 ppapi::host::PpapiHost* host,
33 PP_Instance instance,
34 PP_Resource resource,
35 scoped_ptr<PepperPrintSettingsManager> print_settings_manager)
36 : ResourceHost(host, instance, resource),
37 print_settings_manager_(print_settings_manager.Pass()),
38 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
39 }
40
41 PepperPrintingHost::~PepperPrintingHost() {
42 }
43
44 int32_t PepperPrintingHost::OnResourceMessageReceived(
45 const IPC::Message& msg,
46 ppapi::host::HostMessageContext* context) {
47 IPC_BEGIN_MESSAGE_MAP(PepperPrintingHost, msg)
48 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
49 PpapiHostMsg_Printing_GetDefaultPrintSettings,
50 OnMsgGetDefaultPrintSettings)
51 IPC_END_MESSAGE_MAP()
52 return PP_ERROR_FAILED;
53 }
54
55 int32_t PepperPrintingHost::OnMsgGetDefaultPrintSettings(
56 ppapi::host::HostMessageContext* context) {
57 print_settings_manager_->GetDefaultPrintSettings(
58 base::Bind(PrintSettingsCallback, weak_factory_.GetWeakPtr(),
59 context->MakeReplyParams()));
60 return PP_OK_COMPLETIONPENDING;
61 }
62
63 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698