| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ppb_pdf_impl.h" | 5 #include "chrome/renderer/pepper/ppb_pdf_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 gfx::ImageSkia* res_image_skia = | 342 gfx::ImageSkia* res_image_skia = |
| 343 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(res_id); | 343 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(res_id); |
| 344 | 344 |
| 345 if (!res_image_skia) | 345 if (!res_image_skia) |
| 346 return 0; | 346 return 0; |
| 347 | 347 |
| 348 // Validate the instance. | 348 // Validate the instance. |
| 349 if (!content::GetHostGlobals()->GetInstance(instance_id)) | 349 if (!content::GetHostGlobals()->GetInstance(instance_id)) |
| 350 return 0; | 350 return 0; |
| 351 | 351 |
| 352 if (!res_image_skia->HasRepresentation(scale_factor)) | |
| 353 return 0; | |
| 354 | |
| 355 gfx::ImageSkiaRep image_skia_rep = res_image_skia->GetRepresentation( | 352 gfx::ImageSkiaRep image_skia_rep = res_image_skia->GetRepresentation( |
| 356 scale_factor); | 353 scale_factor); |
| 357 | 354 |
| 355 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) |
| 356 return 0; |
| 357 |
| 358 scoped_refptr<webkit::ppapi::PPB_ImageData_Impl> image_data( | 358 scoped_refptr<webkit::ppapi::PPB_ImageData_Impl> image_data( |
| 359 new webkit::ppapi::PPB_ImageData_Impl( | 359 new webkit::ppapi::PPB_ImageData_Impl( |
| 360 instance_id, | 360 instance_id, |
| 361 webkit::ppapi::PPB_ImageData_Impl::PLATFORM)); | 361 webkit::ppapi::PPB_ImageData_Impl::PLATFORM)); |
| 362 if (!image_data->Init( | 362 if (!image_data->Init( |
| 363 webkit::ppapi::PPB_ImageData_Impl::GetNativeImageDataFormat(), | 363 webkit::ppapi::PPB_ImageData_Impl::GetNativeImageDataFormat(), |
| 364 image_skia_rep.pixel_width(), | 364 image_skia_rep.pixel_width(), |
| 365 image_skia_rep.pixel_height(), | 365 image_skia_rep.pixel_height(), |
| 366 false)) { | 366 false)) { |
| 367 return 0; | 367 return 0; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 418 |
| 419 WebKit::WebElement element = instance->container()->element(); | 419 WebKit::WebElement element = instance->container()->element(); |
| 420 WebKit::WebView* view = element.document().frame()->view(); | 420 WebKit::WebView* view = element.document().frame()->view(); |
| 421 content::RenderView* render_view = content::RenderView::FromWebView(view); | 421 content::RenderView* render_view = content::RenderView::FromWebView(view); |
| 422 | 422 |
| 423 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); | 423 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); |
| 424 if (print_view_helper) | 424 if (print_view_helper) |
| 425 print_view_helper->PrintNode(element); | 425 print_view_helper->PrintNode(element); |
| 426 #endif | 426 #endif |
| 427 } | 427 } |
| OLD | NEW |