Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: chrome/renderer/chrome_ppb_pdf_impl.cc

Issue 9139024: Adding functionality to print PDF embedded in the html page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
Lei Zhang 2012/01/12 22:10:20 nit: WebNode before WebPluginContainer.
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
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 render_view->GetRoutingId())); 329 render_view->GetRoutingId()));
328 } 330 }
329 331
330 void SaveAs(PP_Instance instance_id) { 332 void SaveAs(PP_Instance instance_id) {
331 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); 333 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
332 if (!instance) 334 if (!instance)
333 return; 335 return;
334 instance->delegate()->SaveURLAs(instance->plugin_url()); 336 instance->delegate()->SaveURLAs(instance->plugin_url());
335 } 337 }
336 338
339 void Print(PP_Instance instance_id) {
340 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
341 if (!instance)
342 return;
343
344 WebView* view = instance->container()->element().document().frame()->view();
Lei Zhang 2012/01/12 22:10:20 nit: you can make instance->container()->element()
345 content::RenderView* render_view = content::RenderView::FromWebView(view);
346
347 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view);
348 if (print_view_helper) {
349 print_view_helper->PrintNode(instance->container()->element());
350 }
351 }
352
337 const PPB_PDF ppb_pdf = { 353 const PPB_PDF ppb_pdf = {
338 &GetLocalizedString, 354 &GetLocalizedString,
339 &GetResourceImage, 355 &GetResourceImage,
340 &GetFontFileWithFallback, 356 &GetFontFileWithFallback,
341 &GetFontTableForPrivateFontFile, 357 &GetFontTableForPrivateFontFile,
342 &SearchString, 358 &SearchString,
343 &DidStartLoading, 359 &DidStartLoading,
344 &DidStopLoading, 360 &DidStopLoading,
345 &SetContentRestriction, 361 &SetContentRestriction,
346 &HistogramPDFPageCount, 362 &HistogramPDFPageCount,
347 &UserMetricsRecordAction, 363 &UserMetricsRecordAction,
348 &HasUnsupportedFeature, 364 &HasUnsupportedFeature,
349 &SaveAs 365 &SaveAs,
366 &Print
350 }; 367 };
351 368
352 // static 369 // static
353 const PPB_PDF* PPB_PDF_Impl::GetInterface() { 370 const PPB_PDF* PPB_PDF_Impl::GetInterface() {
354 return &ppb_pdf; 371 return &ppb_pdf;
355 } 372 }
356 373
357 } // namespace chrome 374 } // namespace chrome
358 375
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698