OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_ppb_pdf_impl.h" | 5 #include "chrome/renderer/chrome_ppb_pdf_impl.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| 11 #include "chrome/renderer/print_web_view_helper.h" |
11 #include "content/public/common/child_process_sandbox_support_linux.h" | 12 #include "content/public/common/child_process_sandbox_support_linux.h" |
12 #include "content/public/renderer/render_thread.h" | 13 #include "content/public/renderer/render_thread.h" |
13 #include "content/public/renderer/render_view.h" | 14 #include "content/public/renderer/render_view.h" |
14 #include "grit/webkit_resources.h" | 15 #include "grit/webkit_resources.h" |
15 #include "grit/webkit_strings.h" | 16 #include "grit/webkit_strings.h" |
16 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
17 #include "ppapi/c/private/ppb_pdf.h" | 18 #include "ppapi/c/private/ppb_pdf.h" |
18 #include "ppapi/shared_impl/resource.h" | 19 #include "ppapi/shared_impl/resource.h" |
19 #include "ppapi/shared_impl/resource_tracker.h" | 20 #include "ppapi/shared_impl/resource_tracker.h" |
20 #include "ppapi/shared_impl/var.h" | 21 #include "ppapi/shared_impl/var.h" |
21 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
27 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
28 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
30 #include "unicode/usearch.h" | 32 #include "unicode/usearch.h" |
31 #include "webkit/plugins/ppapi/host_globals.h" | 33 #include "webkit/plugins/ppapi/host_globals.h" |
32 #include "webkit/plugins/ppapi/plugin_delegate.h" | 34 #include "webkit/plugins/ppapi/plugin_delegate.h" |
33 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 35 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
34 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 36 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
35 | 37 |
36 using ppapi::PpapiGlobals; | 38 using ppapi::PpapiGlobals; |
37 using webkit::ppapi::HostGlobals; | 39 using webkit::ppapi::HostGlobals; |
38 using webkit::ppapi::PluginInstance; | 40 using webkit::ppapi::PluginInstance; |
| 41 using WebKit::WebElement; |
39 using WebKit::WebView; | 42 using WebKit::WebView; |
40 using content::RenderThread; | 43 using content::RenderThread; |
41 | 44 |
42 namespace chrome { | 45 namespace chrome { |
43 | 46 |
44 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 47 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
45 class PrivateFontFile : public ppapi::Resource { | 48 class PrivateFontFile : public ppapi::Resource { |
46 public: | 49 public: |
47 PrivateFontFile(PP_Instance instance, int fd) : Resource(instance), fd_(fd) { | 50 PrivateFontFile(PP_Instance instance, int fd) : Resource(instance), fd_(fd) { |
48 } | 51 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 render_view->GetRoutingId())); | 330 render_view->GetRoutingId())); |
328 } | 331 } |
329 | 332 |
330 void SaveAs(PP_Instance instance_id) { | 333 void SaveAs(PP_Instance instance_id) { |
331 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); | 334 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); |
332 if (!instance) | 335 if (!instance) |
333 return; | 336 return; |
334 instance->delegate()->SaveURLAs(instance->plugin_url()); | 337 instance->delegate()->SaveURLAs(instance->plugin_url()); |
335 } | 338 } |
336 | 339 |
| 340 void Print(PP_Instance instance_id) { |
| 341 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); |
| 342 if (!instance) |
| 343 return; |
| 344 |
| 345 WebElement element = instance->container()->element(); |
| 346 WebView* view = element.document().frame()->view(); |
| 347 content::RenderView* render_view = content::RenderView::FromWebView(view); |
| 348 |
| 349 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); |
| 350 if (print_view_helper) { |
| 351 print_view_helper->PrintNode(element); |
| 352 } |
| 353 } |
| 354 |
337 const PPB_PDF ppb_pdf = { | 355 const PPB_PDF ppb_pdf = { |
338 &GetLocalizedString, | 356 &GetLocalizedString, |
339 &GetResourceImage, | 357 &GetResourceImage, |
340 &GetFontFileWithFallback, | 358 &GetFontFileWithFallback, |
341 &GetFontTableForPrivateFontFile, | 359 &GetFontTableForPrivateFontFile, |
342 &SearchString, | 360 &SearchString, |
343 &DidStartLoading, | 361 &DidStartLoading, |
344 &DidStopLoading, | 362 &DidStopLoading, |
345 &SetContentRestriction, | 363 &SetContentRestriction, |
346 &HistogramPDFPageCount, | 364 &HistogramPDFPageCount, |
347 &UserMetricsRecordAction, | 365 &UserMetricsRecordAction, |
348 &HasUnsupportedFeature, | 366 &HasUnsupportedFeature, |
349 &SaveAs | 367 &SaveAs, |
| 368 &Print |
350 }; | 369 }; |
351 | 370 |
352 // static | 371 // static |
353 const PPB_PDF* PPB_PDF_Impl::GetInterface() { | 372 const PPB_PDF* PPB_PDF_Impl::GetInterface() { |
354 return &ppb_pdf; | 373 return &ppb_pdf; |
355 } | 374 } |
356 | 375 |
357 } // namespace chrome | 376 } // namespace chrome |
358 | 377 |
OLD | NEW |