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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
50 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebSandboxSupport
.h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebSandboxSupport
.h" |
51 #endif | 51 #endif |
52 | 52 |
53 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
54 #include "content/common/font_descriptor_mac.h" | 54 #include "content/common/font_descriptor_mac.h" |
55 #include "content/common/font_loader_mac.h" | 55 #include "content/common/font_loader_mac.h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport
.h" | 56 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport
.h" |
57 #endif | 57 #endif |
58 | 58 |
59 #if defined(OS_LINUX) | 59 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
60 #include <string> | 60 #include <string> |
61 #include <map> | 61 #include <map> |
62 | 62 |
63 #include "base/synchronization/lock.h" | 63 #include "base/synchronization/lock.h" |
64 #include "content/common/child_process_sandbox_support_linux.h" | 64 #include "content/common/child_process_sandbox_support_linux.h" |
65 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSuppo
rt.h" | 65 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSuppo
rt.h" |
66 #endif | 66 #endif |
67 | 67 |
68 #if defined(OS_POSIX) | 68 #if defined(OS_POSIX) |
69 #include "base/file_descriptor_posix.h" | 69 #include "base/file_descriptor_posix.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // TODO(jeremy): Remove once WebKit side of patch lands - crbug.com/72727 . |
117 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); | 117 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); |
118 virtual bool loadFont( | 118 virtual bool loadFont( |
119 NSFont* srcFont, ATSFontContainerRef* container, uint32* fontID); | 119 NSFont* srcFont, ATSFontContainerRef* container, uint32* fontID); |
120 #elif defined(OS_LINUX) | 120 #elif defined(OS_POSIX) |
121 virtual WebKit::WebString getFontFamilyForCharacters( | 121 virtual WebKit::WebString getFontFamilyForCharacters( |
122 const WebKit::WebUChar* characters, | 122 const WebKit::WebUChar* characters, |
123 size_t numCharacters, | 123 size_t numCharacters, |
124 const char* preferred_locale); | 124 const char* preferred_locale); |
125 virtual void getRenderStyleForStrike( | 125 virtual void getRenderStyleForStrike( |
126 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | 126 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
127 | 127 |
128 private: | 128 private: |
129 // 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 |
130 // unicode code points. It needs this information frequently so we cache it | 130 // unicode code points. It needs this information frequently so we cache it |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 //------------------------------------------------------------------------------ | 429 //------------------------------------------------------------------------------ |
430 | 430 |
431 #if defined(OS_WIN) | 431 #if defined(OS_WIN) |
432 | 432 |
433 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { | 433 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { |
434 LOGFONT logfont; | 434 LOGFONT logfont; |
435 GetObject(font, sizeof(LOGFONT), &logfont); | 435 GetObject(font, sizeof(LOGFONT), &logfont); |
436 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); | 436 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); |
437 } | 437 } |
438 | 438 |
439 #elif defined(OS_LINUX) | |
440 | |
441 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( | |
442 const WebKit::WebUChar* characters, | |
443 size_t num_characters, | |
444 const char* preferred_locale) { | |
445 base::AutoLock lock(unicode_font_families_mutex_); | |
446 const string16 key(characters, num_characters); | |
447 const std::map<string16, std::string>::const_iterator iter = | |
448 unicode_font_families_.find(key); | |
449 if (iter != unicode_font_families_.end()) | |
450 return WebString::fromUTF8(iter->second); | |
451 | |
452 const std::string family_name = | |
453 child_process_sandbox_support::getFontFamilyForCharacters( | |
454 characters, | |
455 num_characters, | |
456 preferred_locale); | |
457 unicode_font_families_.insert(make_pair(key, family_name)); | |
458 return WebString::fromUTF8(family_name); | |
459 } | |
460 | |
461 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( | |
462 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { | |
463 child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, | |
464 out); | |
465 } | |
466 | |
467 #elif defined(OS_MACOSX) | 439 #elif defined(OS_MACOSX) |
468 | 440 |
469 // TODO(jeremy): Remove once WebKit side of patch lands - crbug.com/72727 . | 441 // TODO(jeremy): Remove once WebKit side of patch lands - crbug.com/72727 . |
470 bool RendererWebKitClientImpl::SandboxSupport::loadFont( | 442 bool RendererWebKitClientImpl::SandboxSupport::loadFont( |
471 NSFont* srcFont, ATSFontContainerRef* out) { | 443 NSFont* srcFont, ATSFontContainerRef* out) { |
472 uint32 temp; | 444 uint32 temp; |
473 return loadFont(srcFont, out, &temp); | 445 return loadFont(srcFont, out, &temp); |
474 } | 446 } |
475 | 447 |
476 bool RendererWebKitClientImpl::SandboxSupport::loadFont( | 448 bool RendererWebKitClientImpl::SandboxSupport::loadFont( |
(...skipping 23 matching lines...) Expand all Loading... |
500 return false; | 472 return false; |
501 } | 473 } |
502 | 474 |
503 // TODO(jeremy): Need to call back into WebKit to make sure that the font | 475 // 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 | 476 // isn't already activated, based on the font id. If it's already |
505 // activated, don't reactivate it here - crbug.com/72727 . | 477 // activated, don't reactivate it here - crbug.com/72727 . |
506 return FontLoader::ATSFontContainerFromBuffer(font_data, font_data_size, | 478 return FontLoader::ATSFontContainerFromBuffer(font_data, font_data_size, |
507 container); | 479 container); |
508 } | 480 } |
509 | 481 |
| 482 #elif defined(OS_POSIX) |
| 483 |
| 484 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( |
| 485 const WebKit::WebUChar* characters, |
| 486 size_t num_characters, |
| 487 const char* preferred_locale) { |
| 488 base::AutoLock lock(unicode_font_families_mutex_); |
| 489 const string16 key(characters, num_characters); |
| 490 const std::map<string16, std::string>::const_iterator iter = |
| 491 unicode_font_families_.find(key); |
| 492 if (iter != unicode_font_families_.end()) |
| 493 return WebString::fromUTF8(iter->second); |
| 494 |
| 495 const std::string family_name = |
| 496 child_process_sandbox_support::getFontFamilyForCharacters( |
| 497 characters, |
| 498 num_characters, |
| 499 preferred_locale); |
| 500 unicode_font_families_.insert(make_pair(key, family_name)); |
| 501 return WebString::fromUTF8(family_name); |
| 502 } |
| 503 |
| 504 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( |
| 505 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { |
| 506 child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, |
| 507 out); |
| 508 } |
| 509 |
510 #endif | 510 #endif |
511 | 511 |
512 //------------------------------------------------------------------------------ | 512 //------------------------------------------------------------------------------ |
513 | 513 |
514 WebKitClient::FileHandle RendererWebKitClientImpl::databaseOpenFile( | 514 WebKitClient::FileHandle RendererWebKitClientImpl::databaseOpenFile( |
515 const WebString& vfs_file_name, int desired_flags) { | 515 const WebString& vfs_file_name, int desired_flags) { |
516 return DatabaseUtil::DatabaseOpenFile(vfs_file_name, desired_flags); | 516 return DatabaseUtil::DatabaseOpenFile(vfs_file_name, desired_flags); |
517 } | 517 } |
518 | 518 |
519 int RendererWebKitClientImpl::databaseDeleteFile( | 519 int RendererWebKitClientImpl::databaseDeleteFile( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 594 } |
595 | 595 |
596 //------------------------------------------------------------------------------ | 596 //------------------------------------------------------------------------------ |
597 | 597 |
598 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | 598 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { |
599 // RenderThread::current can be NULL when running some tests. | 599 // RenderThread::current can be NULL when running some tests. |
600 if (!blob_registry_.get() && RenderThread::current()) | 600 if (!blob_registry_.get() && RenderThread::current()) |
601 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | 601 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); |
602 return blob_registry_.get(); | 602 return blob_registry_.get(); |
603 } | 603 } |
OLD | NEW |