| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "content/common/child_process_messages.h" | 56 #include "content/common/child_process_messages.h" |
| 57 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/win/WebSandb
oxSupport.h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/win/WebSandb
oxSupport.h" |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 61 #include "content/common/mac/font_descriptor.h" | 61 #include "content/common/mac/font_descriptor.h" |
| 62 #include "content/common/mac/font_loader.h" | 62 #include "content/common/mac/font_loader.h" |
| 63 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/mac/WebSandb
oxSupport.h" | 63 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/mac/WebSandb
oxSupport.h" |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 66 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 67 #include <string> | 67 #include <string> |
| 68 #include <map> | 68 #include <map> |
| 69 | 69 |
| 70 #include "base/synchronization/lock.h" | 70 #include "base/synchronization/lock.h" |
| 71 #include "content/common/child_process_sandbox_support_impl_linux.h" | 71 #include "content/common/child_process_sandbox_support_impl_linux.h" |
| 72 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon
tFamily.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon
tFamily.h" |
| 73 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebSan
dboxSupport.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebSan
dboxSupport.h" |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 #if defined(OS_POSIX) | 76 #if defined(OS_POSIX) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 : public webkit_glue::WebFileUtilitiesImpl { | 109 : public webkit_glue::WebFileUtilitiesImpl { |
| 110 public: | 110 public: |
| 111 virtual void revealFolderInOS(const WebKit::WebString& path); | 111 virtual void revealFolderInOS(const WebKit::WebString& path); |
| 112 virtual bool getFileSize(const WebKit::WebString& path, long long& result); | 112 virtual bool getFileSize(const WebKit::WebString& path, long long& result); |
| 113 virtual bool getFileModificationTime(const WebKit::WebString& path, | 113 virtual bool getFileModificationTime(const WebKit::WebString& path, |
| 114 double& result); | 114 double& result); |
| 115 virtual base::PlatformFile openFile(const WebKit::WebString& path, | 115 virtual base::PlatformFile openFile(const WebKit::WebString& path, |
| 116 int mode); | 116 int mode); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 #if defined(OS_ANDROID) |
| 120 // WebKit doesn't use WebSandboxSupport on android so we don't need to |
| 121 // implement anything here. |
| 122 class RendererWebKitPlatformSupportImpl::SandboxSupport { |
| 123 }; |
| 124 #else |
| 119 class RendererWebKitPlatformSupportImpl::SandboxSupport | 125 class RendererWebKitPlatformSupportImpl::SandboxSupport |
| 120 : public WebKit::WebSandboxSupport { | 126 : public WebKit::WebSandboxSupport { |
| 121 public: | 127 public: |
| 122 virtual ~SandboxSupport() {} | 128 virtual ~SandboxSupport() {} |
| 123 | 129 |
| 124 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 125 virtual bool ensureFontLoaded(HFONT); | 131 virtual bool ensureFontLoaded(HFONT); |
| 126 #elif defined(OS_MACOSX) | 132 #elif defined(OS_MACOSX) |
| 127 virtual bool loadFont( | 133 virtual bool loadFont( |
| 128 NSFont* src_font, | 134 NSFont* src_font, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 139 | 145 |
| 140 private: | 146 private: |
| 141 // WebKit likes to ask us for the correct font family to use for a set of | 147 // WebKit likes to ask us for the correct font family to use for a set of |
| 142 // unicode code points. It needs this information frequently so we cache it | 148 // unicode code points. It needs this information frequently so we cache it |
| 143 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. | 149 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
| 144 // The value is a string containing the correct font family. | 150 // The value is a string containing the correct font family. |
| 145 base::Lock unicode_font_families_mutex_; | 151 base::Lock unicode_font_families_mutex_; |
| 146 std::map<string16, WebKit::WebFontFamily> unicode_font_families_; | 152 std::map<string16, WebKit::WebFontFamily> unicode_font_families_; |
| 147 #endif | 153 #endif |
| 148 }; | 154 }; |
| 155 #endif // defined(OS_ANDROID) |
| 149 | 156 |
| 150 //------------------------------------------------------------------------------ | 157 //------------------------------------------------------------------------------ |
| 151 | 158 |
| 152 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() | 159 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() |
| 153 : clipboard_client_(new RendererClipboardClient), | 160 : clipboard_client_(new RendererClipboardClient), |
| 154 clipboard_(new webkit_glue::WebClipboardImpl(clipboard_client_.get())), | 161 clipboard_(new webkit_glue::WebClipboardImpl(clipboard_client_.get())), |
| 155 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), | 162 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), |
| 156 sandbox_support_(new RendererWebKitPlatformSupportImpl::SandboxSupport), | 163 sandbox_support_(new RendererWebKitPlatformSupportImpl::SandboxSupport), |
| 157 sudden_termination_disables_(0), | 164 sudden_termination_disables_(0), |
| 158 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { | 165 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 174 WebKit::WebFileUtilities* | 181 WebKit::WebFileUtilities* |
| 175 RendererWebKitPlatformSupportImpl::fileUtilities() { | 182 RendererWebKitPlatformSupportImpl::fileUtilities() { |
| 176 if (!file_utilities_.get()) { | 183 if (!file_utilities_.get()) { |
| 177 file_utilities_.reset(new FileUtilities); | 184 file_utilities_.reset(new FileUtilities); |
| 178 file_utilities_->set_sandbox_enabled(sandboxEnabled()); | 185 file_utilities_->set_sandbox_enabled(sandboxEnabled()); |
| 179 } | 186 } |
| 180 return file_utilities_.get(); | 187 return file_utilities_.get(); |
| 181 } | 188 } |
| 182 | 189 |
| 183 WebKit::WebSandboxSupport* RendererWebKitPlatformSupportImpl::sandboxSupport() { | 190 WebKit::WebSandboxSupport* RendererWebKitPlatformSupportImpl::sandboxSupport() { |
| 191 #if defined(OS_ANDROID) |
| 192 // WebKit doesn't use WebSandboxSupport on android. |
| 193 return NULL; |
| 194 #else |
| 184 return sandbox_support_.get(); | 195 return sandbox_support_.get(); |
| 196 #endif |
| 185 } | 197 } |
| 186 | 198 |
| 187 WebKit::WebCookieJar* RendererWebKitPlatformSupportImpl::cookieJar() { | 199 WebKit::WebCookieJar* RendererWebKitPlatformSupportImpl::cookieJar() { |
| 188 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; | 200 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; |
| 189 return NULL; | 201 return NULL; |
| 190 } | 202 } |
| 191 | 203 |
| 192 bool RendererWebKitPlatformSupportImpl::sandboxEnabled() { | 204 bool RendererWebKitPlatformSupportImpl::sandboxEnabled() { |
| 193 // As explained in WebKitPlatformSupport.h, this function is used to decide | 205 // As explained in WebKitPlatformSupport.h, this function is used to decide |
| 194 // whether to allow file system operations to come out of WebKit or not. | 206 // whether to allow file system operations to come out of WebKit or not. |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 return false; | 495 return false; |
| 484 } | 496 } |
| 485 | 497 |
| 486 // TODO(jeremy): Need to call back into WebKit to make sure that the font | 498 // TODO(jeremy): Need to call back into WebKit to make sure that the font |
| 487 // isn't already activated, based on the font id. If it's already | 499 // isn't already activated, based on the font id. If it's already |
| 488 // activated, don't reactivate it here - crbug.com/72727 . | 500 // activated, don't reactivate it here - crbug.com/72727 . |
| 489 | 501 |
| 490 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out); | 502 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out); |
| 491 } | 503 } |
| 492 | 504 |
| 505 #elif defined(OS_ANDROID) |
| 506 |
| 507 // WebKit doesn't use WebSandboxSupport on android so we don't need to |
| 508 // implement anything here. This is cleaner to support than excluding the |
| 509 // whole class for android. |
| 510 |
| 493 #elif defined(OS_POSIX) | 511 #elif defined(OS_POSIX) |
| 494 | 512 |
| 495 void | 513 void |
| 496 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( | 514 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( |
| 497 const WebKit::WebUChar* characters, | 515 const WebKit::WebUChar* characters, |
| 498 size_t num_characters, | 516 size_t num_characters, |
| 499 const char* preferred_locale, | 517 const char* preferred_locale, |
| 500 WebKit::WebFontFamily* family) { | 518 WebKit::WebFontFamily* family) { |
| 501 base::AutoLock lock(unicode_font_families_mutex_); | 519 base::AutoLock lock(unicode_font_families_mutex_); |
| 502 const string16 key(characters, num_characters); | 520 const string16 key(characters, num_characters); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 RendererWebKitPlatformSupportImpl::createPeerConnectionHandler( | 673 RendererWebKitPlatformSupportImpl::createPeerConnectionHandler( |
| 656 WebKit::WebPeerConnectionHandlerClient* client) { | 674 WebKit::WebPeerConnectionHandlerClient* client) { |
| 657 WebFrame* web_frame = WebFrame::frameForCurrentContext(); | 675 WebFrame* web_frame = WebFrame::frameForCurrentContext(); |
| 658 if (!web_frame) | 676 if (!web_frame) |
| 659 return NULL; | 677 return NULL; |
| 660 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 678 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
| 661 if (!render_view) | 679 if (!render_view) |
| 662 return NULL; | 680 return NULL; |
| 663 return render_view->CreatePeerConnectionHandler(client); | 681 return render_view->CreatePeerConnectionHandler(client); |
| 664 } | 682 } |
| OLD | NEW |