OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/pdf/renderer/pepper_pdf_host.h" | 5 #include "components/pdf/renderer/pepper_pdf_host.h" |
6 | 6 |
7 #include "components/pdf/common/pdf_messages.h" | 7 #include "components/pdf/common/pdf_messages.h" |
8 #include "components/pdf/renderer/pdf_resource_util.h" | 8 #include "components/pdf/renderer/pdf_resource_util.h" |
9 #include "components/pdf/renderer/ppb_pdf_impl.h" | 9 #include "components/pdf/renderer/ppb_pdf_impl.h" |
10 #include "content/public/common/referrer.h" | 10 #include "content/public/common/referrer.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 OnHostMsgGetLocalizedString) | 52 OnHostMsgGetLocalizedString) |
53 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStartLoading, | 53 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStartLoading, |
54 OnHostMsgDidStartLoading) | 54 OnHostMsgDidStartLoading) |
55 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStopLoading, | 55 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStopLoading, |
56 OnHostMsgDidStopLoading) | 56 OnHostMsgDidStopLoading) |
57 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_UserMetricsRecordAction, | 57 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_UserMetricsRecordAction, |
58 OnHostMsgUserMetricsRecordAction) | 58 OnHostMsgUserMetricsRecordAction) |
59 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_HasUnsupportedFeature, | 59 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_HasUnsupportedFeature, |
60 OnHostMsgHasUnsupportedFeature) | 60 OnHostMsgHasUnsupportedFeature) |
61 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_Print, OnHostMsgPrint) | 61 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_Print, OnHostMsgPrint) |
62 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_SaveAs, | 62 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SaveAs, |
63 OnHostMsgSaveAs) | 63 OnHostMsgSaveAs) |
64 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_GetResourceImage, | 64 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_GetResourceImage, |
65 OnHostMsgGetResourceImage) | 65 OnHostMsgGetResourceImage) |
66 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetSelectedText, | 66 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetSelectedText, |
67 OnHostMsgSetSelectedText) | 67 OnHostMsgSetSelectedText) |
68 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetLinkUnderCursor, | 68 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetLinkUnderCursor, |
69 OnHostMsgSetLinkUnderCursor) | 69 OnHostMsgSetLinkUnderCursor) |
70 PPAPI_END_MESSAGE_MAP() | 70 PPAPI_END_MESSAGE_MAP() |
71 return PP_ERROR_FAILED; | 71 return PP_ERROR_FAILED; |
72 } | 72 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return PP_OK; | 135 return PP_OK; |
136 } | 136 } |
137 | 137 |
138 int32_t PepperPDFHost::OnHostMsgPrint( | 138 int32_t PepperPDFHost::OnHostMsgPrint( |
139 ppapi::host::HostMessageContext* context) { | 139 ppapi::host::HostMessageContext* context) { |
140 return PPB_PDF_Impl::InvokePrintingForInstance(pp_instance()) ? PP_OK : | 140 return PPB_PDF_Impl::InvokePrintingForInstance(pp_instance()) ? PP_OK : |
141 PP_ERROR_FAILED; | 141 PP_ERROR_FAILED; |
142 } | 142 } |
143 | 143 |
144 int32_t PepperPDFHost::OnHostMsgSaveAs( | 144 int32_t PepperPDFHost::OnHostMsgSaveAs( |
145 ppapi::host::HostMessageContext* context) { | 145 ppapi::host::HostMessageContext* context, |
| 146 const std::string& stream_original_url) { |
| 147 printf("PepperPDFHost::OnHostMsgSaveAs\n"); |
146 content::PepperPluginInstance* instance = | 148 content::PepperPluginInstance* instance = |
147 host_->GetPluginInstance(pp_instance()); | 149 host_->GetPluginInstance(pp_instance()); |
148 if (!instance) | 150 if (!instance) |
149 return PP_ERROR_FAILED; | 151 return PP_ERROR_FAILED; |
150 GURL url = instance->GetPluginURL(); | 152 GURL url = instance->GetPluginURL(); |
| 153 printf("url in renderer/ %s\n", url.possibly_invalid_spec().c_str()); |
| 154 printf("url.is_valid() = %d\n", url.is_valid()); |
| 155 printf("stream_original_url renderer/: %s\n", stream_original_url.c_str()); |
| 156 if (!url.is_valid() && !stream_original_url.empty()) |
| 157 url = GURL(stream_original_url); |
151 content::RenderView* render_view = instance->GetRenderView(); | 158 content::RenderView* render_view = instance->GetRenderView(); |
152 blink::WebLocalFrame* frame = | 159 blink::WebLocalFrame* frame = |
153 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); | 160 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
154 content::Referrer referrer(frame->document().url(), | 161 content::Referrer referrer(frame->document().url(), |
155 frame->document().referrerPolicy()); | 162 frame->document().referrerPolicy()); |
156 render_view->Send( | 163 render_view->Send( |
157 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); | 164 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); |
158 return PP_OK; | 165 return PP_OK; |
159 } | 166 } |
160 | 167 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 pixels_to_write.copyPixelsTo( | 287 pixels_to_write.copyPixelsTo( |
281 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); | 288 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); |
282 | 289 |
283 if (needs_unmapping) | 290 if (needs_unmapping) |
284 image_data->Unmap(); | 291 image_data->Unmap(); |
285 | 292 |
286 return true; | 293 return true; |
287 } | 294 } |
288 | 295 |
289 } // namespace pdf | 296 } // namespace pdf |
OLD | NEW |