OLD | NEW |
1 // Copyright (c) 2010 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" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_LINUX) |
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/renderer/renderer_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" |
70 #endif | 70 #endif |
71 | 71 |
72 using WebKit::WebAudioDevice; | 72 using WebKit::WebAudioDevice; |
73 using WebKit::WebBlobRegistry; | 73 using WebKit::WebBlobRegistry; |
74 using WebKit::WebFileSystem; | 74 using WebKit::WebFileSystem; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const char* preferred_locale); | 121 const char* preferred_locale); |
122 virtual void getRenderStyleForStrike( | 122 virtual void getRenderStyleForStrike( |
123 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | 123 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
124 | 124 |
125 private: | 125 private: |
126 // WebKit likes to ask us for the correct font family to use for a set of | 126 // WebKit likes to ask us for the correct font family to use for a set of |
127 // unicode code points. It needs this information frequently so we cache it | 127 // unicode code points. It needs this information frequently so we cache it |
128 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. | 128 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
129 // The value is a string containing the correct font family. | 129 // The value is a string containing the correct font family. |
130 base::Lock unicode_font_families_mutex_; | 130 base::Lock unicode_font_families_mutex_; |
131 std::map<std::string, std::string> unicode_font_families_; | 131 std::map<string16, std::string> unicode_font_families_; |
132 #endif | 132 #endif |
133 }; | 133 }; |
134 | 134 |
135 //------------------------------------------------------------------------------ | 135 //------------------------------------------------------------------------------ |
136 | 136 |
137 RendererWebKitClientImpl::RendererWebKitClientImpl() | 137 RendererWebKitClientImpl::RendererWebKitClientImpl() |
138 : clipboard_(new webkit_glue::WebClipboardImpl), | 138 : clipboard_(new webkit_glue::WebClipboardImpl), |
139 mime_registry_(new RendererWebKitClientImpl::MimeRegistry), | 139 mime_registry_(new RendererWebKitClientImpl::MimeRegistry), |
140 sandbox_support_(new RendererWebKitClientImpl::SandboxSupport), | 140 sandbox_support_(new RendererWebKitClientImpl::SandboxSupport), |
141 sudden_termination_disables_(0), | 141 sudden_termination_disables_(0), |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); | 433 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); |
434 } | 434 } |
435 | 435 |
436 #elif defined(OS_LINUX) | 436 #elif defined(OS_LINUX) |
437 | 437 |
438 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( | 438 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( |
439 const WebKit::WebUChar* characters, | 439 const WebKit::WebUChar* characters, |
440 size_t num_characters, | 440 size_t num_characters, |
441 const char* preferred_locale) { | 441 const char* preferred_locale) { |
442 base::AutoLock lock(unicode_font_families_mutex_); | 442 base::AutoLock lock(unicode_font_families_mutex_); |
443 const std::string key(reinterpret_cast<const char*>(characters), | 443 const string16 key(characters, num_characters); |
444 num_characters * sizeof(characters[0])); | 444 const std::map<string16, std::string>::const_iterator iter = |
445 const std::map<std::string, std::string>::const_iterator iter = | |
446 unicode_font_families_.find(key); | 445 unicode_font_families_.find(key); |
447 if (iter != unicode_font_families_.end()) | 446 if (iter != unicode_font_families_.end()) |
448 return WebString::fromUTF8(iter->second); | 447 return WebString::fromUTF8(iter->second); |
449 | 448 |
450 const std::string family_name = | 449 const std::string family_name = |
451 renderer_sandbox_support::getFontFamilyForCharacters(characters, | 450 child_process_sandbox_support::getFontFamilyForCharacters( |
452 num_characters, | 451 characters, |
453 preferred_locale); | 452 num_characters, |
| 453 preferred_locale); |
454 unicode_font_families_.insert(make_pair(key, family_name)); | 454 unicode_font_families_.insert(make_pair(key, family_name)); |
455 return WebString::fromUTF8(family_name); | 455 return WebString::fromUTF8(family_name); |
456 } | 456 } |
457 | 457 |
458 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( | 458 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( |
459 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { | 459 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { |
460 renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out); | 460 child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, |
| 461 out); |
461 } | 462 } |
462 | 463 |
463 #elif defined(OS_MACOSX) | 464 #elif defined(OS_MACOSX) |
464 | 465 |
465 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, | 466 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, |
466 ATSFontContainerRef* out) { | 467 ATSFontContainerRef* out) { |
467 DCHECK(srcFont); | 468 DCHECK(srcFont); |
468 DCHECK(out); | 469 DCHECK(out); |
469 | 470 |
470 uint32 font_data_size; | 471 uint32 font_data_size; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return WebString::fromUTF8(signed_public_key); | 570 return WebString::fromUTF8(signed_public_key); |
570 } | 571 } |
571 | 572 |
572 //------------------------------------------------------------------------------ | 573 //------------------------------------------------------------------------------ |
573 | 574 |
574 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | 575 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { |
575 if (!blob_registry_.get()) | 576 if (!blob_registry_.get()) |
576 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | 577 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); |
577 return blob_registry_.get(); | 578 return blob_registry_.get(); |
578 } | 579 } |
OLD | NEW |