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

Side by Side Diff: chrome/renderer/pepper/ppb_pdf_impl.cc

Issue 10173029: Add a PPB_Flash_Print interface and implement in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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) 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/chrome_ppb_pdf_impl.h" 5 #include "chrome/renderer/pepper/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 "chrome/renderer/pepper/ppb_flash_print_impl.h"
12 #include "content/public/common/child_process_sandbox_support_linux.h" 12 #include "content/public/common/child_process_sandbox_support_linux.h"
13 #include "content/public/common/content_client.h" 13 #include "content/public/common/content_client.h"
14 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
15 #include "content/public/renderer/render_view.h" 15 #include "content/public/renderer/render_view.h"
16 #include "grit/webkit_resources.h" 16 #include "grit/webkit_resources.h"
17 #include "grit/webkit_strings.h" 17 #include "grit/webkit_strings.h"
18 #include "ppapi/c/pp_resource.h" 18 #include "ppapi/c/pp_resource.h"
19 #include "ppapi/c/private/ppb_pdf.h" 19 #include "ppapi/c/private/ppb_pdf.h"
20 #include "ppapi/shared_impl/resource.h" 20 #include "ppapi/shared_impl/resource.h"
21 #include "ppapi/shared_impl/resource_tracker.h" 21 #include "ppapi/shared_impl/resource_tracker.h"
22 #include "ppapi/shared_impl/var.h" 22 #include "ppapi/shared_impl/var.h"
23 #include "skia/ext/platform_canvas.h" 23 #include "skia/ext/platform_canvas.h"
24 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
30 #include "third_party/skia/include/core/SkBitmap.h"
31 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
33 #include "unicode/usearch.h" 31 #include "unicode/usearch.h"
34 #include "webkit/plugins/ppapi/host_globals.h" 32 #include "webkit/plugins/ppapi/host_globals.h"
35 #include "webkit/plugins/ppapi/plugin_delegate.h" 33 #include "webkit/plugins/ppapi/plugin_delegate.h"
36 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 34 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
37 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 35 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
38 36
39 using ppapi::PpapiGlobals; 37 using ppapi::PpapiGlobals;
40 using webkit::ppapi::HostGlobals; 38 using webkit::ppapi::HostGlobals;
41 using webkit::ppapi::PluginInstance; 39 using webkit::ppapi::PluginInstance;
42 using WebKit::WebElement; 40 using WebKit::WebElement;
43 using WebKit::WebView; 41 using WebKit::WebView;
44 using content::RenderThread; 42 using content::RenderThread;
45 43
46 namespace chrome { 44 namespace {
47 45
48 #if defined(OS_LINUX) || defined(OS_OPENBSD) 46 #if defined(OS_LINUX) || defined(OS_OPENBSD)
49 class PrivateFontFile : public ppapi::Resource { 47 class PrivateFontFile : public ppapi::Resource {
50 public: 48 public:
51 PrivateFontFile(PP_Instance instance, int fd) 49 PrivateFontFile(PP_Instance instance, int fd)
52 : Resource(ppapi::OBJECT_IS_IMPL, instance), 50 : Resource(ppapi::OBJECT_IS_IMPL, instance),
53 fd_(fd) { 51 fd_(fd) {
54 } 52 }
55 virtual ~PrivateFontFile() { 53 virtual ~PrivateFontFile() {
56 } 54 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 malloc(*count * sizeof(PP_PrivateFindResult))); 281 malloc(*count * sizeof(PP_PrivateFindResult)));
284 memcpy(*results, &pp_results[0], *count * sizeof(PP_PrivateFindResult)); 282 memcpy(*results, &pp_results[0], *count * sizeof(PP_PrivateFindResult));
285 } else { 283 } else {
286 *results = NULL; 284 *results = NULL;
287 } 285 }
288 286
289 usearch_close(searcher); 287 usearch_close(searcher);
290 } 288 }
291 289
292 void DidStartLoading(PP_Instance instance_id) { 290 void DidStartLoading(PP_Instance instance_id) {
293 PluginInstance* instance = content::GetHostGlobals()->GetInstance(instance_id) ; 291 PluginInstance* instance =
292 content::GetHostGlobals()->GetInstance(instance_id);
294 if (!instance) 293 if (!instance)
295 return; 294 return;
296 instance->delegate()->DidStartLoading(); 295 instance->delegate()->DidStartLoading();
297 } 296 }
298 297
299 void DidStopLoading(PP_Instance instance_id) { 298 void DidStopLoading(PP_Instance instance_id) {
300 PluginInstance* instance = 299 PluginInstance* instance =
301 content::GetHostGlobals()->GetInstance(instance_id); 300 content::GetHostGlobals()->GetInstance(instance_id);
302 if (!instance) 301 if (!instance)
303 return; 302 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 339 }
341 340
342 void SaveAs(PP_Instance instance_id) { 341 void SaveAs(PP_Instance instance_id) {
343 PluginInstance* instance = 342 PluginInstance* instance =
344 content::GetHostGlobals()->GetInstance(instance_id); 343 content::GetHostGlobals()->GetInstance(instance_id);
345 if (!instance) 344 if (!instance)
346 return; 345 return;
347 instance->delegate()->SaveURLAs(instance->plugin_url()); 346 instance->delegate()->SaveURLAs(instance->plugin_url());
348 } 347 }
349 348
350 void Print(PP_Instance instance_id) {
351 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
352 if (!instance)
353 return;
354
355 WebElement element = instance->container()->element();
356 WebView* view = element.document().frame()->view();
357 content::RenderView* render_view = content::RenderView::FromWebView(view);
358
359 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view);
360 if (print_view_helper) {
361 print_view_helper->PrintNode(element);
362 }
363 }
364
365 const PPB_PDF ppb_pdf = { 349 const PPB_PDF ppb_pdf = {
366 &GetLocalizedString, 350 &GetLocalizedString,
367 &GetResourceImage, 351 &GetResourceImage,
368 &GetFontFileWithFallback, 352 &GetFontFileWithFallback,
369 &GetFontTableForPrivateFontFile, 353 &GetFontTableForPrivateFontFile,
370 &SearchString, 354 &SearchString,
371 &DidStartLoading, 355 &DidStartLoading,
372 &DidStopLoading, 356 &DidStopLoading,
373 &SetContentRestriction, 357 &SetContentRestriction,
374 &HistogramPDFPageCount, 358 &HistogramPDFPageCount,
375 &UserMetricsRecordAction, 359 &UserMetricsRecordAction,
376 &HasUnsupportedFeature, 360 &HasUnsupportedFeature,
377 &SaveAs, 361 &SaveAs,
378 &Print 362 &PPB_Flash_Print_Impl::InvokePrintingForInstance
jam 2012/04/25 21:31:34 this is used by pdf, so it's odd that it's calling
379 }; 363 };
380 364
365 } // namespace
366
381 // static 367 // static
382 const PPB_PDF* PPB_PDF_Impl::GetInterface() { 368 const PPB_PDF* PPB_PDF_Impl::GetInterface() {
383 return &ppb_pdf; 369 return &ppb_pdf;
384 } 370 }
385
386 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698