| 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/safe_numerics.h" | 9 #include "base/safe_numerics.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 PP_Instance instance_id, | 196 PP_Instance instance_id, |
| 197 const PP_BrowserFont_Trusted_Description* description, | 197 const PP_BrowserFont_Trusted_Description* description, |
| 198 PP_PrivateFontCharset charset) { | 198 PP_PrivateFontCharset charset) { |
| 199 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 199 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 200 // Validate the instance before using it below. | 200 // Validate the instance before using it below. |
| 201 if (!content::GetHostGlobals()->GetInstance(instance_id)) | 201 if (!content::GetHostGlobals()->GetInstance(instance_id)) |
| 202 return 0; | 202 return 0; |
| 203 | 203 |
| 204 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( | 204 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( |
| 205 description->face)); | 205 description->face)); |
| 206 if (!face_name) | 206 if (!face_name.get()) |
| 207 return 0; | 207 return 0; |
| 208 | 208 |
| 209 int fd = content::MatchFontWithFallback( | 209 int fd = content::MatchFontWithFallback( |
| 210 face_name->value().c_str(), | 210 face_name->value().c_str(), |
| 211 description->weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD, | 211 description->weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD, |
| 212 description->italic, | 212 description->italic, |
| 213 charset); | 213 charset); |
| 214 if (fd == -1) | 214 if (fd == -1) |
| 215 return 0; | 215 return 0; |
| 216 | 216 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 instance->delegate()->SetContentRestriction(restrictions); | 315 instance->delegate()->SetContentRestriction(restrictions); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void HistogramPDFPageCount(PP_Instance /*instance*/, int count) { | 318 void HistogramPDFPageCount(PP_Instance /*instance*/, int count) { |
| 319 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); | 319 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void UserMetricsRecordAction(PP_Instance /*instance*/, PP_Var action) { | 322 void UserMetricsRecordAction(PP_Instance /*instance*/, PP_Var action) { |
| 323 scoped_refptr<ppapi::StringVar> action_str( | 323 scoped_refptr<ppapi::StringVar> action_str( |
| 324 ppapi::StringVar::FromPPVar(action)); | 324 ppapi::StringVar::FromPPVar(action)); |
| 325 if (action_str) | 325 if (action_str.get()) |
| 326 RenderThread::Get()->RecordUserMetrics(action_str->value()); | 326 RenderThread::Get()->RecordUserMetrics(action_str->value()); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void HasUnsupportedFeature(PP_Instance instance_id) { | 329 void HasUnsupportedFeature(PP_Instance instance_id) { |
| 330 PluginInstance* instance = | 330 PluginInstance* instance = |
| 331 content::GetHostGlobals()->GetInstance(instance_id); | 331 content::GetHostGlobals()->GetInstance(instance_id); |
| 332 if (!instance) | 332 if (!instance) |
| 333 return; | 333 return; |
| 334 | 334 |
| 335 // Only want to show an info bar if the pdf is the whole tab. | 335 // Only want to show an info bar if the pdf is the whole tab. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 instance_id, | 396 instance_id, |
| 397 webkit::ppapi::PPB_ImageData_Impl::PLATFORM)); | 397 webkit::ppapi::PPB_ImageData_Impl::PLATFORM)); |
| 398 if (!image_data->Init( | 398 if (!image_data->Init( |
| 399 webkit::ppapi::PPB_ImageData_Impl::GetNativeImageDataFormat(), | 399 webkit::ppapi::PPB_ImageData_Impl::GetNativeImageDataFormat(), |
| 400 image_skia_rep.pixel_width(), | 400 image_skia_rep.pixel_width(), |
| 401 image_skia_rep.pixel_height(), | 401 image_skia_rep.pixel_height(), |
| 402 false)) { | 402 false)) { |
| 403 return 0; | 403 return 0; |
| 404 } | 404 } |
| 405 | 405 |
| 406 webkit::ppapi::ImageDataAutoMapper mapper(image_data); | 406 webkit::ppapi::ImageDataAutoMapper mapper(image_data.get()); |
| 407 if (!mapper.is_valid()) | 407 if (!mapper.is_valid()) |
| 408 return 0; | 408 return 0; |
| 409 | 409 |
| 410 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); | 410 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); |
| 411 // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will | 411 // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will |
| 412 // ignore the allocated pixels in shared memory and re-allocate a new buffer. | 412 // ignore the allocated pixels in shared memory and re-allocate a new buffer. |
| 413 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); | 413 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); |
| 414 | 414 |
| 415 return image_data->GetReference(); | 415 return image_data->GetReference(); |
| 416 } | 416 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 447 | 447 |
| 448 // static | 448 // static |
| 449 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 449 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
| 450 #if defined(ENABLE_PRINTING) | 450 #if defined(ENABLE_PRINTING) |
| 451 WebKit::WebElement element = GetWebElement(instance_id); | 451 WebKit::WebElement element = GetWebElement(instance_id); |
| 452 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | 452 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); |
| 453 if (helper) | 453 if (helper) |
| 454 helper->PrintNode(element); | 454 helper->PrintNode(element); |
| 455 #endif // ENABLE_PRINTING | 455 #endif // ENABLE_PRINTING |
| 456 } | 456 } |
| OLD | NEW |