summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/chrome_ppb_pdf_impl.cc
diff options
context:
space:
mode:
authorgene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 21:33:03 +0000
committergene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 21:33:03 +0000
commit1a1d6c122e6ba11df8d8a29f80cbd68a1e56ac94 (patch)
tree13495c340e9547e2632c5bfb37dcefe18ecaa85e /chrome/renderer/chrome_ppb_pdf_impl.cc
parent081da1a6516d5d40bf64a4bf45a1577e2b2959cb (diff)
downloadchromium_src-1a1d6c122e6ba11df8d8a29f80cbd68a1e56ac94.zip
chromium_src-1a1d6c122e6ba11df8d8a29f80cbd68a1e56ac94.tar.gz
chromium_src-1a1d6c122e6ba11df8d8a29f80cbd68a1e56ac94.tar.bz2
Adding functionality to print PDF embedded in the html page.
Additional changes needed in PDF plugin to use this functionality. BUG=89241 TEST=Test printing using PDF toolbar on the embedded and normal PDFs. Please do so AFTER PDF changes will be submitted (they have to be submitted separately). Review URL: http://codereview.chromium.org/9139024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117699 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/chrome_ppb_pdf_impl.cc')
-rw-r--r--chrome/renderer/chrome_ppb_pdf_impl.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/chrome/renderer/chrome_ppb_pdf_impl.cc b/chrome/renderer/chrome_ppb_pdf_impl.cc
index ba7e127..5a4592c 100644
--- a/chrome/renderer/chrome_ppb_pdf_impl.cc
+++ b/chrome/renderer/chrome_ppb_pdf_impl.cc
@@ -8,6 +8,7 @@
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/common/render_messages.h"
+#include "chrome/renderer/print_web_view_helper.h"
#include "content/public/common/child_process_sandbox_support_linux.h"
#include "content/public/common/content_client.h"
#include "content/public/renderer/render_thread.h"
@@ -23,6 +24,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -37,6 +39,7 @@
using ppapi::PpapiGlobals;
using webkit::ppapi::HostGlobals;
using webkit::ppapi::PluginInstance;
+using WebKit::WebElement;
using WebKit::WebView;
using content::RenderThread;
@@ -340,6 +343,21 @@ void SaveAs(PP_Instance instance_id) {
instance->delegate()->SaveURLAs(instance->plugin_url());
}
+void Print(PP_Instance instance_id) {
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
+ if (!instance)
+ return;
+
+ WebElement element = instance->container()->element();
+ WebView* view = element.document().frame()->view();
+ content::RenderView* render_view = content::RenderView::FromWebView(view);
+
+ PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view);
+ if (print_view_helper) {
+ print_view_helper->PrintNode(element);
+ }
+}
+
const PPB_PDF ppb_pdf = {
&GetLocalizedString,
&GetResourceImage,
@@ -352,7 +370,8 @@ const PPB_PDF ppb_pdf = {
&HistogramPDFPageCount,
&UserMetricsRecordAction,
&HasUnsupportedFeature,
- &SaveAs
+ &SaveAs,
+ &Print
};
// static