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 "content/renderer/renderer_webkitclient_impl.h" | 5 #include "content/renderer/renderer_webkitclient_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 virtual base::PlatformFile openFile(const WebKit::WebString& path, | 106 virtual base::PlatformFile openFile(const WebKit::WebString& path, |
107 int mode); | 107 int mode); |
108 }; | 108 }; |
109 | 109 |
110 class RendererWebKitClientImpl::SandboxSupport | 110 class RendererWebKitClientImpl::SandboxSupport |
111 : public WebKit::WebSandboxSupport { | 111 : public WebKit::WebSandboxSupport { |
112 public: | 112 public: |
113 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
114 virtual bool ensureFontLoaded(HFONT); | 114 virtual bool ensureFontLoaded(HFONT); |
115 #elif defined(OS_MACOSX) | 115 #elif defined(OS_MACOSX) |
| 116 // TODO(jeremy): Remove once WebKit side of patch lands - crbug.com/72727 . |
116 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); | 117 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); |
| 118 virtual bool loadFont( |
| 119 NSFont* srcFont, ATSFontContainerRef* container, uint32* fontID); |
117 #elif defined(OS_LINUX) | 120 #elif defined(OS_LINUX) |
118 virtual WebKit::WebString getFontFamilyForCharacters( | 121 virtual WebKit::WebString getFontFamilyForCharacters( |
119 const WebKit::WebUChar* characters, | 122 const WebKit::WebUChar* characters, |
120 size_t numCharacters, | 123 size_t numCharacters, |
121 const char* preferred_locale); | 124 const char* preferred_locale); |
122 virtual void getRenderStyleForStrike( | 125 virtual void getRenderStyleForStrike( |
123 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | 126 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
124 | 127 |
125 private: | 128 private: |
126 // WebKit likes to ask us for the correct font family to use for a set of | 129 // WebKit likes to ask us for the correct font family to use for a set of |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 459 } |
457 | 460 |
458 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( | 461 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( |
459 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { | 462 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { |
460 child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, | 463 child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, |
461 out); | 464 out); |
462 } | 465 } |
463 | 466 |
464 #elif defined(OS_MACOSX) | 467 #elif defined(OS_MACOSX) |
465 | 468 |
466 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, | 469 // TODO(jeremy): Remove once WebKit side of patch lands - crbug.com/72727 . |
467 ATSFontContainerRef* out) { | 470 bool RendererWebKitClientImpl::SandboxSupport::loadFont( |
| 471 NSFont* srcFont, ATSFontContainerRef* out) { |
| 472 uint32 temp; |
| 473 return loadFont(srcFont, out, &temp); |
| 474 } |
| 475 |
| 476 bool RendererWebKitClientImpl::SandboxSupport::loadFont( |
| 477 NSFont* srcFont, ATSFontContainerRef* container, uint32* fontID) { |
468 DCHECK(srcFont); | 478 DCHECK(srcFont); |
469 DCHECK(out); | 479 DCHECK(container); |
| 480 DCHECK(fontID); |
470 | 481 |
471 uint32 font_data_size; | 482 uint32 font_data_size; |
472 FontDescriptor src_font_descriptor(srcFont); | 483 FontDescriptor src_font_descriptor(srcFont); |
473 base::SharedMemoryHandle font_data; | 484 base::SharedMemoryHandle font_data; |
474 if (!RenderThread::current()->Send(new ViewHostMsg_LoadFont( | 485 if (!RenderThread::current()->Send(new ViewHostMsg_LoadFont( |
475 src_font_descriptor, &font_data_size, &font_data))) { | 486 src_font_descriptor, &font_data_size, &font_data, fontID))) { |
476 LOG(ERROR) << "Sending ViewHostMsg_LoadFont() IPC failed for " << | 487 LOG(ERROR) << "Sending ViewHostMsg_LoadFont() IPC failed for " << |
477 src_font_descriptor.font_name; | 488 src_font_descriptor.font_name; |
478 *out = kATSFontContainerRefUnspecified; | 489 *container = kATSFontContainerRefUnspecified; |
| 490 *fontID = 0; |
479 return false; | 491 return false; |
480 } | 492 } |
481 | 493 |
482 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle()) { | 494 if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle() || |
| 495 *fontID == 0) { |
483 LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " << | 496 LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " << |
484 src_font_descriptor.font_name; | 497 src_font_descriptor.font_name; |
485 *out = kATSFontContainerRefUnspecified; | 498 *container = kATSFontContainerRefUnspecified; |
| 499 *fontID = 0; |
486 return false; | 500 return false; |
487 } | 501 } |
488 | 502 |
489 return FontLoader::ATSFontContainerFromBuffer(font_data, font_data_size, out); | 503 // TODO(jeremy): Need to call back into WebKit to make sure that the font |
| 504 // isn't already activated, based on the font id. If it's already |
| 505 // activated, don't reactivate it here - crbug.com/72727 . |
| 506 return FontLoader::ATSFontContainerFromBuffer(font_data, font_data_size, |
| 507 container); |
490 } | 508 } |
491 | 509 |
492 #endif | 510 #endif |
493 | 511 |
494 //------------------------------------------------------------------------------ | 512 //------------------------------------------------------------------------------ |
495 | 513 |
496 WebKitClient::FileHandle RendererWebKitClientImpl::databaseOpenFile( | 514 WebKitClient::FileHandle RendererWebKitClientImpl::databaseOpenFile( |
497 const WebString& vfs_file_name, int desired_flags) { | 515 const WebString& vfs_file_name, int desired_flags) { |
498 return DatabaseUtil::DatabaseOpenFile(vfs_file_name, desired_flags); | 516 return DatabaseUtil::DatabaseOpenFile(vfs_file_name, desired_flags); |
499 } | 517 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 } | 594 } |
577 | 595 |
578 //------------------------------------------------------------------------------ | 596 //------------------------------------------------------------------------------ |
579 | 597 |
580 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | 598 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { |
581 // RenderThread::current can be NULL when running some tests. | 599 // RenderThread::current can be NULL when running some tests. |
582 if (!blob_registry_.get() && RenderThread::current()) | 600 if (!blob_registry_.get() && RenderThread::current()) |
583 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | 601 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); |
584 return blob_registry_.get(); | 602 return blob_registry_.get(); |
585 } | 603 } |
OLD | NEW |