| OLD | NEW |
| 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" | |
| 9 #include "chrome/renderer/printing/print_web_view_helper.h" | 8 #include "chrome/renderer/printing/print_web_view_helper.h" |
| 9 #include "components/pdf/common/pdf_messages.h" |
| 10 #include "content/app/strings/grit/content_strings.h" | 10 #include "content/app/strings/grit/content_strings.h" |
| 11 #include "content/public/common/referrer.h" | 11 #include "content/public/common/referrer.h" |
| 12 #include "content/public/renderer/pepper_plugin_instance.h" | 12 #include "content/public/renderer/pepper_plugin_instance.h" |
| 13 #include "content/public/renderer/render_thread.h" | 13 #include "content/public/renderer/render_thread.h" |
| 14 #include "content/public/renderer/render_view.h" | 14 #include "content/public/renderer/render_view.h" |
| 15 #include "content/public/renderer/renderer_ppapi_host.h" | 15 #include "content/public/renderer/renderer_ppapi_host.h" |
| 16 #include "grit/webkit_resources.h" | 16 #include "grit/webkit_resources.h" |
| 17 #include "ppapi/host/dispatch_host_message.h" | 17 #include "ppapi/host/dispatch_host_message.h" |
| 18 #include "ppapi/host/host_message_context.h" | 18 #include "ppapi/host/host_message_context.h" |
| 19 #include "ppapi/host/ppapi_host.h" | 19 #include "ppapi/host/ppapi_host.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 178 } |
| 179 | 179 |
| 180 int32_t PepperPDFHost::OnHostMsgSetContentRestriction( | 180 int32_t PepperPDFHost::OnHostMsgSetContentRestriction( |
| 181 ppapi::host::HostMessageContext* context, | 181 ppapi::host::HostMessageContext* context, |
| 182 int restrictions) { | 182 int restrictions) { |
| 183 content::PepperPluginInstance* instance = | 183 content::PepperPluginInstance* instance = |
| 184 host_->GetPluginInstance(pp_instance()); | 184 host_->GetPluginInstance(pp_instance()); |
| 185 if (!instance) | 185 if (!instance) |
| 186 return PP_ERROR_FAILED; | 186 return PP_ERROR_FAILED; |
| 187 instance->GetRenderView()->Send( | 187 instance->GetRenderView()->Send( |
| 188 new ChromeViewHostMsg_PDFUpdateContentRestrictions( | 188 new PDFHostMsg_PDFUpdateContentRestrictions( |
| 189 instance->GetRenderView()->GetRoutingID(), restrictions)); | 189 instance->GetRenderView()->GetRoutingID(), restrictions)); |
| 190 return PP_OK; | 190 return PP_OK; |
| 191 } | 191 } |
| 192 | 192 |
| 193 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction( | 193 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction( |
| 194 ppapi::host::HostMessageContext* context, | 194 ppapi::host::HostMessageContext* context, |
| 195 const std::string& action) { | 195 const std::string& action) { |
| 196 if (action.empty()) | 196 if (action.empty()) |
| 197 return PP_ERROR_FAILED; | 197 return PP_ERROR_FAILED; |
| 198 content::RenderThread::Get()->RecordComputedAction(action); | 198 content::RenderThread::Get()->RecordComputedAction(action); |
| 199 return PP_OK; | 199 return PP_OK; |
| 200 } | 200 } |
| 201 | 201 |
| 202 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( | 202 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( |
| 203 ppapi::host::HostMessageContext* context) { | 203 ppapi::host::HostMessageContext* context) { |
| 204 content::PepperPluginInstance* instance = | 204 content::PepperPluginInstance* instance = |
| 205 host_->GetPluginInstance(pp_instance()); | 205 host_->GetPluginInstance(pp_instance()); |
| 206 if (!instance) | 206 if (!instance) |
| 207 return PP_ERROR_FAILED; | 207 return PP_ERROR_FAILED; |
| 208 | 208 |
| 209 blink::WebView* view = | 209 blink::WebView* view = |
| 210 instance->GetContainer()->element().document().frame()->view(); | 210 instance->GetContainer()->element().document().frame()->view(); |
| 211 content::RenderView* render_view = content::RenderView::FromWebView(view); | 211 content::RenderView* render_view = content::RenderView::FromWebView(view); |
| 212 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature( | 212 render_view->Send(new PDFHostMsg_PDFHasUnsupportedFeature( |
| 213 render_view->GetRoutingID())); | 213 render_view->GetRoutingID())); |
| 214 return PP_OK; | 214 return PP_OK; |
| 215 } | 215 } |
| 216 | 216 |
| 217 int32_t PepperPDFHost::OnHostMsgPrint( | 217 int32_t PepperPDFHost::OnHostMsgPrint( |
| 218 ppapi::host::HostMessageContext* context) { | 218 ppapi::host::HostMessageContext* context) { |
| 219 #if defined(ENABLE_FULL_PRINTING) | 219 #if defined(ENABLE_FULL_PRINTING) |
| 220 content::PepperPluginInstance* instance = | 220 content::PepperPluginInstance* instance = |
| 221 host_->GetPluginInstance(pp_instance()); | 221 host_->GetPluginInstance(pp_instance()); |
| 222 if (!instance) | 222 if (!instance) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 241 content::PepperPluginInstance* instance = | 241 content::PepperPluginInstance* instance = |
| 242 host_->GetPluginInstance(pp_instance()); | 242 host_->GetPluginInstance(pp_instance()); |
| 243 if (!instance) | 243 if (!instance) |
| 244 return PP_ERROR_FAILED; | 244 return PP_ERROR_FAILED; |
| 245 GURL url = instance->GetPluginURL(); | 245 GURL url = instance->GetPluginURL(); |
| 246 content::RenderView* render_view = instance->GetRenderView(); | 246 content::RenderView* render_view = instance->GetRenderView(); |
| 247 blink::WebLocalFrame* frame = | 247 blink::WebLocalFrame* frame = |
| 248 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); | 248 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
| 249 content::Referrer referrer(frame->document().url(), | 249 content::Referrer referrer(frame->document().url(), |
| 250 frame->document().referrerPolicy()); | 250 frame->document().referrerPolicy()); |
| 251 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( | 251 render_view->Send(new PDFHostMsg_PDFSaveURLAs( |
| 252 render_view->GetRoutingID(), url, referrer)); | 252 render_view->GetRoutingID(), url, referrer)); |
| 253 return PP_OK; | 253 return PP_OK; |
| 254 } | 254 } |
| 255 | 255 |
| 256 int32_t PepperPDFHost::OnHostMsgGetResourceImage( | 256 int32_t PepperPDFHost::OnHostMsgGetResourceImage( |
| 257 ppapi::host::HostMessageContext* context, | 257 ppapi::host::HostMessageContext* context, |
| 258 PP_ResourceImage image_id, | 258 PP_ResourceImage image_id, |
| 259 float scale) { | 259 float scale) { |
| 260 int res_id = 0; | 260 int res_id = 0; |
| 261 for (size_t i = 0; i < arraysize(kResourceImageMap); ++i) { | 261 for (size_t i = 0; i < arraysize(kResourceImageMap); ++i) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 384 |
| 385 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); | 385 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); |
| 386 pixels_to_write.copyPixelsTo( | 386 pixels_to_write.copyPixelsTo( |
| 387 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); | 387 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); |
| 388 | 388 |
| 389 if (needs_unmapping) | 389 if (needs_unmapping) |
| 390 image_data->Unmap(); | 390 image_data->Unmap(); |
| 391 | 391 |
| 392 return true; | 392 return true; |
| 393 } | 393 } |
| OLD | NEW |