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

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..7d14f85ca2daa4574701eb3c6c87b37f108c3008
--- /dev/null
+++ b/content/browser/renderer_host/pepper/pepper_printing_host.cc
@@ -0,0 +1,57 @@
+// 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 {
+
+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(&PepperPrintingHost::PrintSettingsCallback,
+ weak_factory_.GetWeakPtr(), context->MakeReplyParams()));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void PepperPrintingHost::PrintSettingsCallback(
+ ppapi::proxy::ResourceMessageReplyParams reply_params,
+ PepperPrintSettingsManager::Result result) {
+ reply_params.set_result(result.second);
+ host()->SendReply(reply_params,
+ PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply(result.first));
+}
+
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698