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" | 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 ppapi::host::HostMessageContext* context) { | 227 ppapi::host::HostMessageContext* context) { |
228 content::PepperPluginInstance* instance = | 228 content::PepperPluginInstance* instance = |
229 host_->GetPluginInstance(pp_instance()); | 229 host_->GetPluginInstance(pp_instance()); |
230 if (!instance) | 230 if (!instance) |
231 return PP_ERROR_FAILED; | 231 return PP_ERROR_FAILED; |
232 | 232 |
233 // Only want to show an info bar if the pdf is the whole tab. | 233 // Only want to show an info bar if the pdf is the whole tab. |
234 if (!instance->IsFullPagePlugin()) | 234 if (!instance->IsFullPagePlugin()) |
235 return PP_OK; | 235 return PP_OK; |
236 | 236 |
237 WebKit::WebView* view = | 237 blink::WebView* view = |
238 instance->GetContainer()->element().document().frame()->view(); | 238 instance->GetContainer()->element().document().frame()->view(); |
239 content::RenderView* render_view = content::RenderView::FromWebView(view); | 239 content::RenderView* render_view = content::RenderView::FromWebView(view); |
240 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature( | 240 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature( |
241 render_view->GetRoutingID())); | 241 render_view->GetRoutingID())); |
242 return PP_OK; | 242 return PP_OK; |
243 } | 243 } |
244 | 244 |
245 int32_t PepperPDFHost::OnHostMsgPrint( | 245 int32_t PepperPDFHost::OnHostMsgPrint( |
246 ppapi::host::HostMessageContext* context) { | 246 ppapi::host::HostMessageContext* context) { |
247 #if defined(ENABLE_FULL_PRINTING) | 247 #if defined(ENABLE_FULL_PRINTING) |
248 content::PepperPluginInstance* instance = | 248 content::PepperPluginInstance* instance = |
249 host_->GetPluginInstance(pp_instance()); | 249 host_->GetPluginInstance(pp_instance()); |
250 if (!instance) | 250 if (!instance) |
251 return PP_ERROR_FAILED; | 251 return PP_ERROR_FAILED; |
252 | 252 |
253 WebKit::WebElement element = instance->GetContainer()->element(); | 253 blink::WebElement element = instance->GetContainer()->element(); |
254 WebKit::WebView* view = element.document().frame()->view(); | 254 blink::WebView* view = element.document().frame()->view(); |
255 content::RenderView* render_view = content::RenderView::FromWebView(view); | 255 content::RenderView* render_view = content::RenderView::FromWebView(view); |
256 | 256 |
257 using printing::PrintWebViewHelper; | 257 using printing::PrintWebViewHelper; |
258 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); | 258 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); |
259 if (print_view_helper) { | 259 if (print_view_helper) { |
260 print_view_helper->PrintNode(element); | 260 print_view_helper->PrintNode(element); |
261 return PP_OK; | 261 return PP_OK; |
262 } | 262 } |
263 #endif | 263 #endif |
264 return PP_ERROR_FAILED; | 264 return PP_ERROR_FAILED; |
265 } | 265 } |
266 | 266 |
267 int32_t PepperPDFHost::OnHostMsgSaveAs( | 267 int32_t PepperPDFHost::OnHostMsgSaveAs( |
268 ppapi::host::HostMessageContext* context) { | 268 ppapi::host::HostMessageContext* context) { |
269 content::PepperPluginInstance* instance = | 269 content::PepperPluginInstance* instance = |
270 host_->GetPluginInstance(pp_instance()); | 270 host_->GetPluginInstance(pp_instance()); |
271 if (!instance) | 271 if (!instance) |
272 return PP_ERROR_FAILED; | 272 return PP_ERROR_FAILED; |
273 GURL url = instance->GetPluginURL(); | 273 GURL url = instance->GetPluginURL(); |
274 content::RenderView* render_view = instance->GetRenderView(); | 274 content::RenderView* render_view = instance->GetRenderView(); |
275 WebKit::WebFrame* frame = render_view->GetWebView()->mainFrame(); | 275 blink::WebFrame* frame = render_view->GetWebView()->mainFrame(); |
276 content::Referrer referrer(frame->document().url(), | 276 content::Referrer referrer(frame->document().url(), |
277 frame->document().referrerPolicy()); | 277 frame->document().referrerPolicy()); |
278 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( | 278 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( |
279 render_view->GetRoutingID(), url, referrer)); | 279 render_view->GetRoutingID(), url, referrer)); |
280 return PP_OK; | 280 return PP_OK; |
281 } | 281 } |
282 | 282 |
283 int32_t PepperPDFHost::OnHostMsgGetResourceImage( | 283 int32_t PepperPDFHost::OnHostMsgGetResourceImage( |
284 ppapi::host::HostMessageContext* context, | 284 ppapi::host::HostMessageContext* context, |
285 PP_ResourceImage image_id, | 285 PP_ResourceImage image_id, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); | 387 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); |
388 pixels_to_write.copyPixelsTo(bitmap->getPixels(), | 388 pixels_to_write.copyPixelsTo(bitmap->getPixels(), |
389 bitmap->getSize(), | 389 bitmap->getSize(), |
390 bitmap->rowBytes()); | 390 bitmap->rowBytes()); |
391 | 391 |
392 if (needs_unmapping) | 392 if (needs_unmapping) |
393 image_data->Unmap(); | 393 image_data->Unmap(); |
394 | 394 |
395 return true; | 395 return true; |
396 } | 396 } |
OLD | NEW |