Commit bae266e4 authored by jbroman's avatar jbroman Committed by Commit bot

[Win, Android] Don't create WebSandboxSupport when it would have no methods.

This removes includes of android/ and win/WebSandboxSupport.h, and only
has the platform implementations create it on the platforms that do have
a WebSandboxSupport (Mac, Linux).

If this lands, the empty WebSandboxSupport headers can be removed from Blink
in a followup CL.

BUG=463506

Review URL: https://codereview.chromium.org/976163002

Cr-Commit-Position: refs/heads/master@{#319653}
parent f5c7c479
...@@ -16,13 +16,9 @@ ...@@ -16,13 +16,9 @@
#include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/proxy_lock.h"
#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebString.h"
#if defined(OS_WIN) #if defined(OS_MACOSX)
#include "third_party/WebKit/public/platform/win/WebSandboxSupport.h"
#elif defined(OS_MACOSX)
#include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h"
#elif defined(OS_ANDROID) #elif defined(OS_POSIX) && !defined(OS_ANDROID)
#include "third_party/WebKit/public/platform/android/WebSandboxSupport.h"
#elif defined(OS_POSIX)
#include "content/common/child_process_sandbox_support_impl_linux.h" #include "content/common/child_process_sandbox_support_impl_linux.h"
#include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h"
#include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h"
...@@ -38,16 +34,14 @@ typedef struct CGFont* CGFontRef; ...@@ -38,16 +34,14 @@ typedef struct CGFont* CGFontRef;
namespace content { namespace content {
#if !defined(OS_ANDROID) && !defined(OS_WIN)
class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport { class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport {
public: public:
virtual ~SandboxSupport() {} virtual ~SandboxSupport() {}
#if defined(OS_WIN) #if defined(OS_MACOSX)
virtual bool ensureFontLoaded(HFONT);
#elif defined(OS_MACOSX)
virtual bool loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID); virtual bool loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID);
#elif defined(OS_ANDROID)
// Empty class.
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
SandboxSupport(); SandboxSupport();
virtual void getFallbackFontForCharacter( virtual void getFallbackFontForCharacter(
...@@ -68,19 +62,7 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport { ...@@ -68,19 +62,7 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport {
#endif #endif
}; };
#if defined(OS_WIN) #if defined(OS_MACOSX)
bool PpapiBlinkPlatformImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
LOGFONT logfont;
GetObject(font, sizeof(LOGFONT), &logfont);
// Use the proxy sender rather than going directly to the ChildThread since
// the proxy browser sender will properly unlock during sync messages.
return ppapi::proxy::PluginGlobals::Get()->GetBrowserSender()->Send(
new ChildProcessHostMsg_PreCacheFont(logfont));
}
#elif defined(OS_MACOSX)
bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
CGFontRef* out, CGFontRef* out,
...@@ -92,10 +74,6 @@ bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, ...@@ -92,10 +74,6 @@ bool PpapiBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
return false; return false;
} }
#elif defined(OS_ANDROID)
// Empty class.
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport() PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport()
...@@ -134,18 +112,24 @@ void PpapiBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike( ...@@ -134,18 +112,24 @@ void PpapiBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike(
#endif #endif
PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() #endif // !defined(OS_ANDROID) && !defined(OS_WIN)
: sandbox_support_(new PpapiBlinkPlatformImpl::SandboxSupport()) {
PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() {
#if !defined(OS_ANDROID) && !defined(OS_WIN)
sandbox_support_.reset(new PpapiBlinkPlatformImpl::SandboxSupport);
#endif
} }
PpapiBlinkPlatformImpl::~PpapiBlinkPlatformImpl() { PpapiBlinkPlatformImpl::~PpapiBlinkPlatformImpl() {
} }
void PpapiBlinkPlatformImpl::Shutdown() { void PpapiBlinkPlatformImpl::Shutdown() {
#if !defined(OS_ANDROID) && !defined(OS_WIN)
// SandboxSupport contains a map of WebFontFamily objects, which hold // SandboxSupport contains a map of WebFontFamily objects, which hold
// WebCStrings, which become invalidated when blink is shut down. Hence, we // WebCStrings, which become invalidated when blink is shut down. Hence, we
// need to clear that map now, just before blink::shutdown() is called. // need to clear that map now, just before blink::shutdown() is called.
sandbox_support_.reset(); sandbox_support_.reset();
#endif
} }
blink::WebClipboard* PpapiBlinkPlatformImpl::clipboard() { blink::WebClipboard* PpapiBlinkPlatformImpl::clipboard() {
...@@ -164,7 +148,11 @@ blink::WebFileUtilities* PpapiBlinkPlatformImpl::fileUtilities() { ...@@ -164,7 +148,11 @@ blink::WebFileUtilities* PpapiBlinkPlatformImpl::fileUtilities() {
} }
blink::WebSandboxSupport* PpapiBlinkPlatformImpl::sandboxSupport() { blink::WebSandboxSupport* PpapiBlinkPlatformImpl::sandboxSupport() {
#if !defined(OS_ANDROID) && !defined(OS_WIN)
return sandbox_support_.get(); return sandbox_support_.get();
#else
return nullptr;
#endif
} }
bool PpapiBlinkPlatformImpl::sandboxEnabled() { bool PpapiBlinkPlatformImpl::sandboxEnabled() {
......
...@@ -50,8 +50,10 @@ class PpapiBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -50,8 +50,10 @@ class PpapiBlinkPlatformImpl : public BlinkPlatformImpl {
bool sync_dir); bool sync_dir);
private: private:
#if !defined(OS_ANDROID) && !defined(OS_WIN)
class SandboxSupport; class SandboxSupport;
scoped_ptr<SandboxSupport> sandbox_support_; scoped_ptr<SandboxSupport> sandbox_support_;
#endif
DISALLOW_COPY_AND_ASSIGN(PpapiBlinkPlatformImpl); DISALLOW_COPY_AND_ASSIGN(PpapiBlinkPlatformImpl);
}; };
......
...@@ -111,7 +111,6 @@ ...@@ -111,7 +111,6 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "content/common/child_process_messages.h" #include "content/common/child_process_messages.h"
#include "third_party/WebKit/public/platform/win/WebSandboxSupport.h"
#endif #endif
#if defined(USE_AURA) #if defined(USE_AURA)
...@@ -188,19 +187,13 @@ class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl { ...@@ -188,19 +187,13 @@ class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl {
scoped_refptr<ThreadSafeSender> thread_safe_sender_; scoped_refptr<ThreadSafeSender> thread_safe_sender_;
}; };
#if defined(OS_ANDROID) #if !defined(OS_ANDROID) && !defined(OS_WIN)
// WebKit doesn't use WebSandboxSupport on android so we don't need to
// implement anything here.
class RendererBlinkPlatformImpl::SandboxSupport {};
#else
class RendererBlinkPlatformImpl::SandboxSupport class RendererBlinkPlatformImpl::SandboxSupport
: public blink::WebSandboxSupport { : public blink::WebSandboxSupport {
public: public:
virtual ~SandboxSupport() {} virtual ~SandboxSupport() {}
#if defined(OS_WIN) #if defined(OS_MACOSX)
virtual bool ensureFontLoaded(HFONT);
#elif defined(OS_MACOSX)
virtual bool loadFont( virtual bool loadFont(
NSFont* src_font, NSFont* src_font,
CGFontRef* container, CGFontRef* container,
...@@ -221,7 +214,7 @@ class RendererBlinkPlatformImpl::SandboxSupport ...@@ -221,7 +214,7 @@ class RendererBlinkPlatformImpl::SandboxSupport
std::map<int32_t, blink::WebFallbackFont> unicode_font_families_; std::map<int32_t, blink::WebFallbackFont> unicode_font_families_;
#endif #endif
}; };
#endif // defined(OS_ANDROID) #endif // !defined(OS_ANDROID) && !defined(OS_WIN)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -237,11 +230,13 @@ RendererBlinkPlatformImpl::RendererBlinkPlatformImpl( ...@@ -237,11 +230,13 @@ RendererBlinkPlatformImpl::RendererBlinkPlatformImpl(
plugin_refresh_allowed_(true), plugin_refresh_allowed_(true),
default_task_runner_(renderer_scheduler->DefaultTaskRunner()), default_task_runner_(renderer_scheduler->DefaultTaskRunner()),
web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) {
#if !defined(OS_ANDROID) && !defined(OS_WIN)
if (g_sandbox_enabled && sandboxEnabled()) { if (g_sandbox_enabled && sandboxEnabled()) {
sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport);
} else { } else {
DVLOG(1) << "Disabling sandbox support for testing."; DVLOG(1) << "Disabling sandbox support for testing.";
} }
#endif
// ChildThread may not exist in some tests. // ChildThread may not exist in some tests.
if (ChildThreadImpl::current()) { if (ChildThreadImpl::current()) {
...@@ -292,8 +287,8 @@ blink::WebFileUtilities* RendererBlinkPlatformImpl::fileUtilities() { ...@@ -292,8 +287,8 @@ blink::WebFileUtilities* RendererBlinkPlatformImpl::fileUtilities() {
} }
blink::WebSandboxSupport* RendererBlinkPlatformImpl::sandboxSupport() { blink::WebSandboxSupport* RendererBlinkPlatformImpl::sandboxSupport() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID) || defined(OS_WIN)
// WebKit doesn't use WebSandboxSupport on android. // These platforms do not require sandbox support.
return NULL; return NULL;
#else #else
return sandbox_support_.get(); return sandbox_support_.get();
...@@ -519,16 +514,7 @@ bool RendererBlinkPlatformImpl::FileUtilities::SendSyncMessageFromAnyThread( ...@@ -519,16 +514,7 @@ bool RendererBlinkPlatformImpl::FileUtilities::SendSyncMessageFromAnyThread(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if defined(OS_WIN) #if defined(OS_MACOSX)
bool RendererBlinkPlatformImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
LOGFONT logfont;
GetObject(font, sizeof(LOGFONT), &logfont);
RenderThread::Get()->PreCacheFont(logfont);
return true;
}
#elif defined(OS_MACOSX)
bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
CGFontRef* out, CGFontRef* out,
...@@ -559,13 +545,7 @@ bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, ...@@ -559,13 +545,7 @@ bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out); return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out);
} }
#elif defined(OS_ANDROID) #elif defined(OS_POSIX) && !defined(OS_ANDROID)
// WebKit doesn't use WebSandboxSupport on android so we don't need to
// implement anything here. This is cleaner to support than excluding the
// whole class for android.
#elif defined(OS_POSIX)
void RendererBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter( void RendererBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter(
blink::WebUChar32 character, blink::WebUChar32 character,
......
...@@ -215,8 +215,10 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -215,8 +215,10 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
class MimeRegistry; class MimeRegistry;
scoped_ptr<MimeRegistry> mime_registry_; scoped_ptr<MimeRegistry> mime_registry_;
#if !defined(OS_ANDROID) && !defined(OS_WIN)
class SandboxSupport; class SandboxSupport;
scoped_ptr<SandboxSupport> sandbox_support_; scoped_ptr<SandboxSupport> sandbox_support_;
#endif
// This counter keeps track of the number of times sudden termination is // This counter keeps track of the number of times sudden termination is
// enabled or disabled. It starts at 0 (enabled) and for every disable // enabled or disabled. It starts at 0 (enabled) and for every disable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment