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_webkitplatformsupport_impl.h" | 5 #include "content/renderer/renderer_webkitplatformsupport_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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "content/common/mac/font_loader.h" | 55 #include "content/common/mac/font_loader.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_POSIX) && !defined(OS_MACOSX) | 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_impl_linux.h" | 64 #include "content/common/child_process_sandbox_support_impl_linux.h" |
| 65 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontFamily.h
" |
65 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSuppo
rt.h" | 66 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSuppo
rt.h" |
66 #endif | 67 #endif |
67 | 68 |
68 #if defined(OS_POSIX) | 69 #if defined(OS_POSIX) |
69 #include "base/file_descriptor_posix.h" | 70 #include "base/file_descriptor_posix.h" |
70 #endif | 71 #endif |
71 | 72 |
72 using WebKit::WebAudioDevice; | 73 using WebKit::WebAudioDevice; |
73 using WebKit::WebBlobRegistry; | 74 using WebKit::WebBlobRegistry; |
74 using WebKit::WebFileSystem; | 75 using WebKit::WebFileSystem; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 virtual ~SandboxSupport() {} | 114 virtual ~SandboxSupport() {} |
114 | 115 |
115 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
116 virtual bool ensureFontLoaded(HFONT); | 117 virtual bool ensureFontLoaded(HFONT); |
117 #elif defined(OS_MACOSX) | 118 #elif defined(OS_MACOSX) |
118 virtual bool loadFont( | 119 virtual bool loadFont( |
119 NSFont* src_font, | 120 NSFont* src_font, |
120 CGFontRef* container, | 121 CGFontRef* container, |
121 uint32* font_id); | 122 uint32* font_id); |
122 #elif defined(OS_POSIX) | 123 #elif defined(OS_POSIX) |
123 virtual WebKit::WebString getFontFamilyForCharacters( | 124 virtual void getFontFamilyForCharacters( |
124 const WebKit::WebUChar* characters, | 125 const WebKit::WebUChar* characters, |
125 size_t numCharacters, | 126 size_t numCharacters, |
126 const char* preferred_locale); | 127 const char* preferred_locale, |
| 128 WebKit::WebFontFamily* family); |
127 virtual void getRenderStyleForStrike( | 129 virtual void getRenderStyleForStrike( |
128 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | 130 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
129 | 131 |
130 private: | 132 private: |
131 // WebKit likes to ask us for the correct font family to use for a set of | 133 // WebKit likes to ask us for the correct font family to use for a set of |
132 // unicode code points. It needs this information frequently so we cache it | 134 // unicode code points. It needs this information frequently so we cache it |
133 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. | 135 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
134 // The value is a string containing the correct font family. | 136 // The value is a string containing the correct font family. |
135 base::Lock unicode_font_families_mutex_; | 137 base::Lock unicode_font_families_mutex_; |
136 std::map<string16, std::string> unicode_font_families_; | 138 std::map<string16, WebKit::WebFontFamily> unicode_font_families_; |
137 #endif | 139 #endif |
138 }; | 140 }; |
139 | 141 |
140 //------------------------------------------------------------------------------ | 142 //------------------------------------------------------------------------------ |
141 | 143 |
142 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() | 144 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() |
143 : clipboard_(new webkit_glue::WebClipboardImpl), | 145 : clipboard_(new webkit_glue::WebClipboardImpl), |
144 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), | 146 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), |
145 sandbox_support_(new RendererWebKitPlatformSupportImpl::SandboxSupport), | 147 sandbox_support_(new RendererWebKitPlatformSupportImpl::SandboxSupport), |
146 sudden_termination_disables_(0), | 148 sudden_termination_disables_(0), |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 475 |
474 // TODO(jeremy): Need to call back into WebKit to make sure that the font | 476 // TODO(jeremy): Need to call back into WebKit to make sure that the font |
475 // isn't already activated, based on the font id. If it's already | 477 // isn't already activated, based on the font id. If it's already |
476 // activated, don't reactivate it here - crbug.com/72727 . | 478 // activated, don't reactivate it here - crbug.com/72727 . |
477 | 479 |
478 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out); | 480 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out); |
479 } | 481 } |
480 | 482 |
481 #elif defined(OS_POSIX) | 483 #elif defined(OS_POSIX) |
482 | 484 |
483 WebString | 485 void |
484 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( | 486 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( |
485 const WebKit::WebUChar* characters, | 487 const WebKit::WebUChar* characters, |
486 size_t num_characters, | 488 size_t num_characters, |
487 const char* preferred_locale) { | 489 const char* preferred_locale, |
| 490 WebKit::WebFontFamily* family) { |
488 base::AutoLock lock(unicode_font_families_mutex_); | 491 base::AutoLock lock(unicode_font_families_mutex_); |
489 const string16 key(characters, num_characters); | 492 const string16 key(characters, num_characters); |
490 const std::map<string16, std::string>::const_iterator iter = | 493 const std::map<string16, WebKit::WebFontFamily>::const_iterator iter = |
491 unicode_font_families_.find(key); | 494 unicode_font_families_.find(key); |
492 if (iter != unicode_font_families_.end()) | 495 if (iter != unicode_font_families_.end()) { |
493 return WebString::fromUTF8(iter->second); | 496 family->name = iter->second.name; |
| 497 family->isBold = iter->second.isBold; |
| 498 family->isItalic = iter->second.isItalic; |
| 499 return; |
| 500 } |
494 | 501 |
495 const std::string family_name = content::GetFontFamilyForCharacters( | 502 content::GetFontFamilyForCharacters( |
496 characters, | 503 characters, |
497 num_characters, | 504 num_characters, |
498 preferred_locale); | 505 preferred_locale, |
499 unicode_font_families_.insert(make_pair(key, family_name)); | 506 family); |
500 return WebString::fromUTF8(family_name); | 507 unicode_font_families_.insert(make_pair(key, *family)); |
501 } | 508 } |
502 | 509 |
503 void | 510 void |
504 RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( | 511 RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( |
505 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { | 512 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { |
506 content::GetRenderStyleForStrike(family, sizeAndStyle, out); | 513 content::GetRenderStyleForStrike(family, sizeAndStyle, out); |
507 } | 514 } |
508 | 515 |
509 #endif | 516 #endif |
510 | 517 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 blob_registry_.reset(new WebBlobRegistryImpl(ChildThread::current())); | 614 blob_registry_.reset(new WebBlobRegistryImpl(ChildThread::current())); |
608 } | 615 } |
609 return blob_registry_.get(); | 616 return blob_registry_.get(); |
610 } | 617 } |
611 | 618 |
612 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent( | 619 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent( |
613 const WebKit::WebURL& url) { | 620 const WebKit::WebURL& url) { |
614 return WebKitPlatformSupportImpl::userAgent(url); | 621 return WebKitPlatformSupportImpl::userAgent(url); |
615 } | 622 } |
616 | 623 |
OLD | NEW |