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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 PP_Instance instance_id, | 160 PP_Instance instance_id, |
161 const PP_FontDescription_Dev* description, | 161 const PP_FontDescription_Dev* description, |
162 PP_PrivateFontCharset charset) { | 162 PP_PrivateFontCharset charset) { |
163 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 163 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
164 // Validate the instance before using it below. | 164 // Validate the instance before using it below. |
165 if (!content::GetHostGlobals()->GetInstance(instance_id)) | 165 if (!content::GetHostGlobals()->GetInstance(instance_id)) |
166 return 0; | 166 return 0; |
167 | 167 |
168 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( | 168 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( |
169 description->face)); | 169 description->face)); |
170 if (!face_name) | 170 if (!face_name.get()) |
171 return 0; | 171 return 0; |
172 | 172 |
173 int fd = content::MatchFontWithFallback( | 173 int fd = content::MatchFontWithFallback( |
174 face_name->value().c_str(), | 174 face_name->value().c_str(), |
175 description->weight >= PP_FONTWEIGHT_BOLD, | 175 description->weight >= PP_FONTWEIGHT_BOLD, |
176 description->italic, | 176 description->italic, |
177 charset); | 177 charset); |
178 if (fd == -1) | 178 if (fd == -1) |
179 return 0; | 179 return 0; |
180 | 180 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 instance->delegate()->SetContentRestriction(restrictions); | 279 instance->delegate()->SetContentRestriction(restrictions); |
280 } | 280 } |
281 | 281 |
282 void HistogramPDFPageCount(int count) { | 282 void HistogramPDFPageCount(int count) { |
283 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); | 283 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); |
284 } | 284 } |
285 | 285 |
286 void UserMetricsRecordAction(PP_Var action) { | 286 void UserMetricsRecordAction(PP_Var action) { |
287 scoped_refptr<ppapi::StringVar> action_str( | 287 scoped_refptr<ppapi::StringVar> action_str( |
288 ppapi::StringVar::FromPPVar(action)); | 288 ppapi::StringVar::FromPPVar(action)); |
289 if (action_str) | 289 if (action_str.get()) |
290 RenderThread::Get()->RecordUserMetrics(action_str->value()); | 290 RenderThread::Get()->RecordUserMetrics(action_str->value()); |
291 } | 291 } |
292 | 292 |
293 void HasUnsupportedFeature(PP_Instance instance_id) { | 293 void HasUnsupportedFeature(PP_Instance instance_id) { |
294 PluginInstance* instance = | 294 PluginInstance* instance = |
295 content::GetHostGlobals()->GetInstance(instance_id); | 295 content::GetHostGlobals()->GetInstance(instance_id); |
296 if (!instance) | 296 if (!instance) |
297 return; | 297 return; |
298 | 298 |
299 // Only want to show an info bar if the pdf is the whole tab. | 299 // 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... |
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; |
368 } | 368 } |
369 | 369 |
370 webkit::ppapi::ImageDataAutoMapper mapper(image_data); | 370 webkit::ppapi::ImageDataAutoMapper mapper(image_data.get()); |
371 if (!mapper.is_valid()) | 371 if (!mapper.is_valid()) |
372 return 0; | 372 return 0; |
373 | 373 |
374 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); | 374 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); |
375 // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will | 375 // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will |
376 // ignore the allocated pixels in shared memory and re-allocate a new buffer. | 376 // ignore the allocated pixels in shared memory and re-allocate a new buffer. |
377 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); | 377 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); |
378 | 378 |
379 return image_data->GetReference(); | 379 return image_data->GetReference(); |
380 } | 380 } |
(...skipping 37 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 |