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

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

Issue 8566026: Implement skia sandbox callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | skia/skia.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/print_web_view_helper.h" 5 #include "chrome/renderer/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 27 matching lines...) Expand all
38 #include "webkit/glue/webpreferences.h" 38 #include "webkit/glue/webpreferences.h"
39 39
40 #if defined(OS_POSIX) 40 #if defined(OS_POSIX)
41 #include "base/process_util.h" 41 #include "base/process_util.h"
42 #endif 42 #endif
43 43
44 #if defined(USE_SKIA) 44 #if defined(USE_SKIA)
45 #include "skia/ext/vector_canvas.h" 45 #include "skia/ext/vector_canvas.h"
46 #include "skia/ext/vector_platform_device_skia.h" 46 #include "skia/ext/vector_platform_device_skia.h"
47 #include "third_party/skia/include/core/SkTypeface.h" 47 #include "third_party/skia/include/core/SkTypeface.h"
48 #if defined (OS_WIN)
49 #include "content/common/child_process_messages.h"
50 #include "third_party/skia/include/ports/SkSandbox_win.h"
51 #endif
48 #elif defined(OS_MACOSX) 52 #elif defined(OS_MACOSX)
49 #include <CoreGraphics/CGContext.h> 53 #include <CoreGraphics/CGContext.h>
50 54
51 #include "base/mac/scoped_cftyperef.h" 55 #include "base/mac/scoped_cftyperef.h"
52 #include "base/sys_string_conversions.h" 56 #include "base/sys_string_conversions.h"
53 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" 57 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h"
54 #endif 58 #endif
55 59
56 #if defined(OS_MACOSX) 60 #if defined(OS_MACOSX)
57 using base::mac::ScopedCFTypeRef; 61 using base::mac::ScopedCFTypeRef;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 vertical_position, offset_to_baseline, 252 vertical_position, offset_to_baseline,
249 text_width_in_points); 253 text_width_in_points);
250 CGContextSetTextPosition(canvas, SkScalarToDouble(point.x()), 254 CGContextSetTextPosition(canvas, SkScalarToDouble(point.x()),
251 SkScalarToDouble(point.y())); 255 SkScalarToDouble(point.y()));
252 CTLineDraw(line, canvas); 256 CTLineDraw(line, canvas);
253 #endif 257 #endif
254 } 258 }
255 259
256 } // namespace 260 } // namespace
257 261
262 #if defined (OS_WIN) && defined (USE_SKIA)
263 class PrintWebViewHelperSkSandbox : public skia::SkSandbox {
vandebo (ex-Chrome) 2011/11/15 17:03:30 This is the wrong place for this. It should go in
264 public:
265 explicit PrintWebViewHelperSkSandbox(PrintWebViewHelper* container) {
266 container_ = container;
267 }
268 virtual ~PrintWebViewHelperSkSandbox() {}
269
270 virtual bool EnsureFontLoad(LOGFONT logfont) {
271 return container_->EnsureFontLoad(logfont);
272 }
273
274 private:
275 PrintWebViewHelper* container_;
276 };
277 #endif // defined (OS_WIN) && defined (USE_SKIA)
278
258 // static - Not anonymous so that platform implementations can use it. 279 // static - Not anonymous so that platform implementations can use it.
259 void PrintWebViewHelper::PrintHeaderAndFooter( 280 void PrintWebViewHelper::PrintHeaderAndFooter(
260 WebKit::WebCanvas* canvas, 281 WebKit::WebCanvas* canvas,
261 int page_number, 282 int page_number,
262 int total_pages, 283 int total_pages,
263 float webkit_scale_factor, 284 float webkit_scale_factor,
264 const PageSizeMargins& page_layout, 285 const PageSizeMargins& page_layout,
265 const DictionaryValue& header_footer_info) { 286 const DictionaryValue& header_footer_info) {
266 #if defined(USE_SKIA) 287 #if defined(USE_SKIA)
267 skia::VectorPlatformDeviceSkia* device = 288 skia::VectorPlatformDeviceSkia* device =
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 456 }
436 457
437 PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view) 458 PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
438 : content::RenderViewObserver(render_view), 459 : content::RenderViewObserver(render_view),
439 content::RenderViewObserverTracker<PrintWebViewHelper>(render_view), 460 content::RenderViewObserverTracker<PrintWebViewHelper>(render_view),
440 print_web_view_(NULL), 461 print_web_view_(NULL),
441 is_preview_enabled_(switches::IsPrintPreviewEnabled()), 462 is_preview_enabled_(switches::IsPrintPreviewEnabled()),
442 is_print_ready_metafile_sent_(false), 463 is_print_ready_metafile_sent_(false),
443 user_cancelled_scripted_print_count_(0), 464 user_cancelled_scripted_print_count_(0),
444 notify_browser_of_print_failure_(true) { 465 notify_browser_of_print_failure_(true) {
466 #if defined(OS_WIN) && defined(USE_SKIA)
467 if (!skia::gSandbox) {
468 skia::gSandbox = new PrintWebViewHelperSkSandbox(this);
469 }
470 #endif
445 } 471 }
446 472
447 PrintWebViewHelper::~PrintWebViewHelper() {} 473 PrintWebViewHelper::~PrintWebViewHelper() {
474 #if defined(OS_WIN) && defined(USE_SKIA)
475 delete skia::gSandbox;
476 skia::gSandbox = NULL;
477 #endif
478 }
448 479
449 // Prints |frame| which called window.print(). 480 // Prints |frame| which called window.print().
450 void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame) { 481 void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame) {
451 DCHECK(frame); 482 DCHECK(frame);
452 483
453 // Allow Prerendering to cancel this print request if necessary. 484 // Allow Prerendering to cancel this print request if necessary.
454 if (prerender::PrerenderHelper::IsPrerendering(render_view())) { 485 if (prerender::PrerenderHelper::IsPrerendering(render_view())) {
455 Send(new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id())); 486 Send(new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id()));
456 return; 487 return;
457 } 488 }
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 DCHECK(IsRendering()); 1593 DCHECK(IsRendering());
1563 return prep_frame_view_->GetPrintCanvasSize(); 1594 return prep_frame_view_->GetPrintCanvasSize();
1564 } 1595 }
1565 1596
1566 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 1597 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
1567 prep_frame_view_.reset(); 1598 prep_frame_view_.reset();
1568 metafile_.reset(); 1599 metafile_.reset();
1569 pages_to_render_.clear(); 1600 pages_to_render_.clear();
1570 error_ = PREVIEW_ERROR_NONE; 1601 error_ = PREVIEW_ERROR_NONE;
1571 } 1602 }
1603
1604 #if defined(OS_WIN) && defined(USE_SKIA)
1605 bool PrintWebViewHelper::EnsureFontLoad(LOGFONT logfont) {
1606 return Send(new ChildProcessHostMsg_PreCacheFont(logfont));
1607 }
1608 #endif
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | skia/skia.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698