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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/pepper/pepper_printing_host.cc
diff --git a/content/browser/renderer_host/pepper/pepper_printing_host.cc b/content/browser/renderer_host/pepper/pepper_printing_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0e8d52b42c6d76e02ab704c8d5355df5f7ca805
--- /dev/null
+++ b/content/browser/renderer_host/pepper/pepper_printing_host.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/pepper/pepper_printing_host.h"
+
+#include "ppapi/c/dev/pp_print_settings_dev.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+namespace content {
+
+namespace {
+
+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.
+ base::WeakPtr<PepperPrintingHost> printing_host,
+ ppapi::proxy::ResourceMessageReplyParams reply_params,
+ PepperPrintSettingsManager::Result result) {
+ if (!printing_host.get())
+ return;
+ reply_params.set_result(result.second);
+ printing_host->host()->SendReply(reply_params,
+ PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply(result.first));
+}
+
+} // namespace
+
+PepperPrintingHost::PepperPrintingHost(
+ ppapi::host::PpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource,
+ scoped_ptr<PepperPrintSettingsManager> print_settings_manager)
+ : ResourceHost(host, instance, resource),
+ print_settings_manager_(print_settings_manager.Pass()),
+ weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
+
+PepperPrintingHost::~PepperPrintingHost() {
+}
+
+int32_t PepperPrintingHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ IPC_BEGIN_MESSAGE_MAP(PepperPrintingHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
+ PpapiHostMsg_Printing_GetDefaultPrintSettings,
+ OnMsgGetDefaultPrintSettings)
+ IPC_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperPrintingHost::OnMsgGetDefaultPrintSettings(
+ ppapi::host::HostMessageContext* context) {
+ print_settings_manager_->GetDefaultPrintSettings(
+ base::Bind(PrintSettingsCallback, weak_factory_.GetWeakPtr(),
+ context->MakeReplyParams()));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698