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

Side by Side Diff: chrome/renderer/pepper/pepper_pdf_host.cc

Issue 283623002: Add support for passing an arbitrary parameter to an IPC message handler. The motivation is for Web… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/renderer/pepper/pepper_pdf_host.h" 5 #include "chrome/renderer/pepper/pepper_pdf_host.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "chrome/renderer/printing/print_web_view_helper.h" 9 #include "chrome/renderer/printing/print_web_view_helper.h"
10 #include "content/public/common/referrer.h" 10 #include "content/public/common/referrer.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 PP_Instance instance, 105 PP_Instance instance,
106 PP_Resource resource) 106 PP_Resource resource)
107 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), 107 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource),
108 host_(host) {} 108 host_(host) {}
109 109
110 PepperPDFHost::~PepperPDFHost() {} 110 PepperPDFHost::~PepperPDFHost() {}
111 111
112 int32_t PepperPDFHost::OnResourceMessageReceived( 112 int32_t PepperPDFHost::OnResourceMessageReceived(
113 const IPC::Message& msg, 113 const IPC::Message& msg,
114 ppapi::host::HostMessageContext* context) { 114 ppapi::host::HostMessageContext* context) {
115 IPC_BEGIN_MESSAGE_MAP(PepperPDFHost, msg) 115 PPAPI_BEGIN_MESSAGE_MAP(PepperPDFHost, msg)
116 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_GetLocalizedString, 116 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_GetLocalizedString,
117 OnHostMsgGetLocalizedString) 117 OnHostMsgGetLocalizedString)
118 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStartLoading, 118 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStartLoading,
119 OnHostMsgDidStartLoading) 119 OnHostMsgDidStartLoading)
120 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStopLoading, 120 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStopLoading,
121 OnHostMsgDidStopLoading) 121 OnHostMsgDidStopLoading)
122 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_UserMetricsRecordAction, 122 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_UserMetricsRecordAction,
123 OnHostMsgUserMetricsRecordAction) 123 OnHostMsgUserMetricsRecordAction)
124 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_HasUnsupportedFeature, 124 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_HasUnsupportedFeature,
125 OnHostMsgHasUnsupportedFeature) 125 OnHostMsgHasUnsupportedFeature)
126 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_Print, OnHostMsgPrint) 126 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_Print, OnHostMsgPrint)
127 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_SaveAs, OnHostMsgSaveAs) 127 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_SaveAs,
128 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_GetResourceImage, 128 OnHostMsgSaveAs)
129 OnHostMsgGetResourceImage) 129 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_GetResourceImage,
130 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetSelectedText, 130 OnHostMsgGetResourceImage)
131 OnHostMsgSetSelectedText) 131 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetSelectedText,
132 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetLinkUnderCursor, 132 OnHostMsgSetSelectedText)
133 OnHostMsgSetLinkUnderCursor) 133 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetLinkUnderCursor,
134 IPC_END_MESSAGE_MAP() 134 OnHostMsgSetLinkUnderCursor)
135 PPAPI_END_MESSAGE_MAP()
135 return PP_ERROR_FAILED; 136 return PP_ERROR_FAILED;
136 } 137 }
137 138
138 int32_t PepperPDFHost::OnHostMsgGetLocalizedString( 139 int32_t PepperPDFHost::OnHostMsgGetLocalizedString(
139 ppapi::host::HostMessageContext* context, 140 ppapi::host::HostMessageContext* context,
140 PP_ResourceString string_id) { 141 PP_ResourceString string_id) {
141 std::string rv; 142 std::string rv;
142 if (string_id == PP_RESOURCESTRING_PDFGETPASSWORD) { 143 if (string_id == PP_RESOURCESTRING_PDFGETPASSWORD) {
143 rv = base::UTF16ToUTF8(l10n_util::GetStringUTF16(IDS_PDF_NEED_PASSWORD)); 144 rv = base::UTF16ToUTF8(l10n_util::GetStringUTF16(IDS_PDF_NEED_PASSWORD));
144 } else if (string_id == PP_RESOURCESTRING_PDFLOADING) { 145 } else if (string_id == PP_RESOURCESTRING_PDFLOADING) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 388
388 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); 389 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false);
389 pixels_to_write.copyPixelsTo( 390 pixels_to_write.copyPixelsTo(
390 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); 391 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes());
391 392
392 if (needs_unmapping) 393 if (needs_unmapping)
393 image_data->Unmap(); 394 image_data->Unmap();
394 395
395 return true; 396 return true;
396 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698