OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_webkitclient_impl.h" | 5 #include "chrome/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/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
52 #include "chrome/common/font_descriptor_mac.h" | 52 #include "chrome/common/font_descriptor_mac.h" |
53 #include "chrome/common/font_loader_mac.h" | 53 #include "chrome/common/font_loader_mac.h" |
54 #include "third_party/WebKit/WebKit/chromium/public/mac/WebSandboxSupport.h" | 54 #include "third_party/WebKit/WebKit/chromium/public/mac/WebSandboxSupport.h" |
55 #endif | 55 #endif |
56 | 56 |
57 #if defined(OS_LINUX) | 57 #if defined(OS_LINUX) |
58 #include <string> | 58 #include <string> |
59 #include <map> | 59 #include <map> |
60 | 60 |
61 #include "base/lock.h" | 61 #include "base/synchronization/lock.h" |
62 #include "chrome/renderer/renderer_sandbox_support_linux.h" | 62 #include "chrome/renderer/renderer_sandbox_support_linux.h" |
63 #include "third_party/WebKit/WebKit/chromium/public/linux/WebSandboxSupport.h" | 63 #include "third_party/WebKit/WebKit/chromium/public/linux/WebSandboxSupport.h" |
64 #endif | 64 #endif |
65 | 65 |
66 #if defined(OS_POSIX) | 66 #if defined(OS_POSIX) |
67 #include "base/file_descriptor_posix.h" | 67 #include "base/file_descriptor_posix.h" |
68 #endif | 68 #endif |
69 | 69 |
70 using WebKit::WebBlobRegistry; | 70 using WebKit::WebBlobRegistry; |
71 using WebKit::WebFileSystem; | 71 using WebKit::WebFileSystem; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 virtual WebKit::WebString getFontFamilyForCharacters( | 115 virtual WebKit::WebString getFontFamilyForCharacters( |
116 const WebKit::WebUChar* characters, size_t numCharacters); | 116 const WebKit::WebUChar* characters, size_t numCharacters); |
117 virtual void getRenderStyleForStrike( | 117 virtual void getRenderStyleForStrike( |
118 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | 118 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
119 | 119 |
120 private: | 120 private: |
121 // WebKit likes to ask us for the correct font family to use for a set of | 121 // WebKit likes to ask us for the correct font family to use for a set of |
122 // unicode code points. It needs this information frequently so we cache it | 122 // unicode code points. It needs this information frequently so we cache it |
123 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. | 123 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
124 // The value is a string containing the correct font family. | 124 // The value is a string containing the correct font family. |
125 Lock unicode_font_families_mutex_; | 125 base::Lock unicode_font_families_mutex_; |
126 std::map<std::string, std::string> unicode_font_families_; | 126 std::map<std::string, std::string> unicode_font_families_; |
127 #endif | 127 #endif |
128 }; | 128 }; |
129 | 129 |
130 //------------------------------------------------------------------------------ | 130 //------------------------------------------------------------------------------ |
131 | 131 |
132 RendererWebKitClientImpl::RendererWebKitClientImpl() | 132 RendererWebKitClientImpl::RendererWebKitClientImpl() |
133 : clipboard_(new webkit_glue::WebClipboardImpl), | 133 : clipboard_(new webkit_glue::WebClipboardImpl), |
134 mime_registry_(new RendererWebKitClientImpl::MimeRegistry), | 134 mime_registry_(new RendererWebKitClientImpl::MimeRegistry), |
135 sandbox_support_(new RendererWebKitClientImpl::SandboxSupport), | 135 sandbox_support_(new RendererWebKitClientImpl::SandboxSupport), |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { | 414 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { |
415 LOGFONT logfont; | 415 LOGFONT logfont; |
416 GetObject(font, sizeof(LOGFONT), &logfont); | 416 GetObject(font, sizeof(LOGFONT), &logfont); |
417 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); | 417 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); |
418 } | 418 } |
419 | 419 |
420 #elif defined(OS_LINUX) | 420 #elif defined(OS_LINUX) |
421 | 421 |
422 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( | 422 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( |
423 const WebKit::WebUChar* characters, size_t num_characters) { | 423 const WebKit::WebUChar* characters, size_t num_characters) { |
424 AutoLock lock(unicode_font_families_mutex_); | 424 base::AutoLock lock(unicode_font_families_mutex_); |
425 const std::string key(reinterpret_cast<const char*>(characters), | 425 const std::string key(reinterpret_cast<const char*>(characters), |
426 num_characters * sizeof(characters[0])); | 426 num_characters * sizeof(characters[0])); |
427 const std::map<std::string, std::string>::const_iterator iter = | 427 const std::map<std::string, std::string>::const_iterator iter = |
428 unicode_font_families_.find(key); | 428 unicode_font_families_.find(key); |
429 if (iter != unicode_font_families_.end()) | 429 if (iter != unicode_font_families_.end()) |
430 return WebString::fromUTF8(iter->second); | 430 return WebString::fromUTF8(iter->second); |
431 | 431 |
432 const std::string family_name = | 432 const std::string family_name = |
433 renderer_sandbox_support::getFontFamilyForCharacters(characters, | 433 renderer_sandbox_support::getFontFamilyForCharacters(characters, |
434 num_characters); | 434 num_characters); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 return WebString::fromUTF8(signed_public_key); | 534 return WebString::fromUTF8(signed_public_key); |
535 } | 535 } |
536 | 536 |
537 //------------------------------------------------------------------------------ | 537 //------------------------------------------------------------------------------ |
538 | 538 |
539 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | 539 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { |
540 if (!blob_registry_.get()) | 540 if (!blob_registry_.get()) |
541 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | 541 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); |
542 return blob_registry_.get(); | 542 return blob_registry_.get(); |
543 } | 543 } |
OLD | NEW |