#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "content/common/mime_registry_messages.h"
+#include "content/common/screen_orientation_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/renderer/content_renderer_client.h"
-#include "content/renderer/device_orientation/device_motion_event_pump.h"
-#include "content/renderer/device_orientation/device_orientation_event_pump.h"
+#include "content/renderer/device_sensors/device_motion_event_pump.h"
+#include "content/renderer/device_sensors/device_orientation_event_pump.h"
#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
#include "content/renderer/gamepad_shared_memory_reader.h"
#include "content/renderer/media/audio_decoder.h"
#include "content/renderer/media/webcontentdecryptionmodule_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/renderer_clipboard_client.h"
+#include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
#include "content/renderer/webclipboard_impl.h"
-#include "content/renderer/webcrypto/webcrypto_impl.h"
#include "content/renderer/webgraphicscontext3d_provider_impl.h"
#include "content/renderer/webpublicsuffixlist_impl.h"
#include "gpu/config/gpu_info.h"
#include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
#include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h"
#include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
+#include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebVector.h"
#include "ui/gfx/color_profile.h"
#include "webkit/common/gpu/context_provider_web_context.h"
#include "webkit/common/quota/quota_types.h"
-#if defined(OS_WIN)
-#include "content/common/child_process_messages.h"
-#include "third_party/WebKit/public/platform/win/WebSandboxSupport.h"
+#if defined(OS_ANDROID)
+#include "content/renderer/android/synchronous_compositor_factory.h"
+#include "content/renderer/media/android/audio_decoder_android.h"
#endif
#if defined(OS_MACOSX)
#include "content/common/mac/font_descriptor.h"
#include "content/common/mac/font_loader.h"
+#include "content/renderer/webscrollbarbehavior_impl_mac.h"
#include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h"
#endif
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
#include <map>
#include <string>
#include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h"
#include "third_party/icu/source/common/unicode/utf16.h"
#endif
+#endif
-#if defined(OS_POSIX)
-#include "base/file_descriptor_posix.h"
+#if defined(OS_WIN)
+#include "content/common/child_process_messages.h"
+#include "third_party/WebKit/public/platform/win/WebSandboxSupport.h"
#endif
-#if defined(OS_ANDROID)
-#include "content/renderer/media/android/audio_decoder_android.h"
+#if defined(USE_AURA)
+#include "content/renderer/webscrollbarbehavior_impl_gtkoraura.h"
+#elif !defined(OS_MACOSX)
+#include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
+#define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior
#endif
using blink::Platform;
using blink::WebDatabaseObserver;
using blink::WebFileInfo;
using blink::WebFileSystem;
+using blink::WebGamepad;
using blink::WebGamepads;
using blink::WebIDBFactory;
using blink::WebMIDIAccessor;
namespace content {
static bool g_sandbox_enabled = true;
+static blink::WebGamepadListener* web_gamepad_listener = NULL;
base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<blink::WebDeviceMotionData>::Leaky
g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
+static blink::WebScreenOrientationListener*
+ g_test_screen_orientation_listener = NULL;
//------------------------------------------------------------------------------
const blink::WebString& key_system);
virtual bool supportsMediaSourceMIMEType(const blink::WebString& mime_type,
const blink::WebString& codecs);
+ virtual bool supportsEncryptedMediaMIMEType(const WebString& key_system,
+ const WebString& mime_type,
+ const WebString& codecs) OVERRIDE;
virtual blink::WebString mimeTypeForExtension(
const blink::WebString& file_extension);
virtual blink::WebString mimeTypeFromFile(
mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry),
sudden_termination_disables_(0),
plugin_refresh_allowed_(true),
- child_thread_loop_(base::MessageLoopProxy::current()) {
+ child_thread_loop_(base::MessageLoopProxy::current()),
+ web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) {
if (g_sandbox_enabled && sandboxEnabled()) {
sandbox_support_.reset(
new RendererWebKitPlatformSupportImpl::SandboxSupport);
GetContentClient()->renderer()->OverrideThemeEngine();
if (theme_engine)
return theme_engine;
- return WebKitPlatformSupportImpl::themeEngine();
+ return BlinkPlatformImpl::themeEngine();
}
bool RendererWebKitPlatformSupportImpl::sandboxEnabled() {
return GetContentClient()->renderer()->IsLinkVisited(link_hash);
}
-blink::WebMessagePortChannel*
-RendererWebKitPlatformSupportImpl::createMessagePortChannel() {
- return new WebMessagePortChannelImpl(child_thread_loop_.get());
+void RendererWebKitPlatformSupportImpl::createMessageChannel(
+ blink::WebMessagePortChannel** channel1,
+ blink::WebMessagePortChannel** channel2) {
+ WebMessagePortChannelImpl::CreatePair(
+ child_thread_loop_.get(), channel1, channel2);
}
blink::WebPrescientNetworking*
if (!key_system.isEmpty()) {
// Check whether the key system is supported with the mime_type and codecs.
+ // Chromium only supports ASCII parameters.
+ if (!base::IsStringASCII(key_system))
+ return IsNotSupported;
+
+ std::string key_system_ascii =
+ GetUnprefixedKeySystemName(base::UTF16ToASCII(key_system));
std::vector<std::string> strict_codecs;
bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii);
net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, strip_suffix);
if (!IsSupportedKeySystemWithMediaMimeType(
- mime_type_ascii, strict_codecs, ToASCIIOrEmpty(key_system)))
+ mime_type_ascii, strict_codecs, key_system_ascii)) {
return IsNotSupported;
+ }
// Continue processing the mime_type and codecs.
}
// Check list of strict codecs to see if it is supported.
if (net::IsStrictMediaMimeType(mime_type_ascii)) {
- // We support the container, but no codecs were specified.
- if (codecs.isNull())
- return MayBeSupported;
-
// Check if the codecs are a perfect match.
std::vector<std::string> strict_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
- if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs))
- return IsNotSupported;
+ if (net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs))
+ return IsSupported;
+
+ // We support the container, but no codecs were specified.
+ if (codecs.isNull())
+ return MayBeSupported;
- // Good to go!
- return IsSupported;
+ return IsNotSupported;
}
// If we don't recognize the codec, it's possible we support it.
mime_type_ascii, parsed_codec_ids);
}
+bool
+RendererWebKitPlatformSupportImpl::MimeRegistry::supportsEncryptedMediaMIMEType(
+ const WebString& key_system,
+ const WebString& mime_type,
+ const WebString& codecs) {
+ // Chromium only supports ASCII parameters.
+ if (!base::IsStringASCII(key_system) || !base::IsStringASCII(mime_type) ||
+ !base::IsStringASCII(codecs)) {
+ return false;
+ }
+
+ if (key_system.isEmpty())
+ return false;
+
+ const std::string mime_type_ascii = base::UTF16ToASCII(mime_type);
+
+ std::vector<std::string> codec_vector;
+ bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii);
+ net::ParseCodecString(base::UTF16ToASCII(codecs), &codec_vector,
+ strip_suffix);
+
+ return IsSupportedKeySystemWithMediaMimeType(
+ mime_type_ascii, codec_vector, base::UTF16ToASCII(key_system));
+}
+
WebString
RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension(
const WebString& file_extension) {
}
bool RendererWebKitPlatformSupportImpl::isThreadedCompositingEnabled() {
- return !!RenderThreadImpl::current()->compositor_message_loop_proxy().get();
+ RenderThreadImpl* thread = RenderThreadImpl::current();
+ // thread can be NULL in tests.
+ return thread && thread->compositor_message_loop_proxy().get();
}
double RendererWebKitPlatformSupportImpl::audioHardwareSampleRate() {
return web_database_observer_impl_.get();
}
-// TODO(crogers): remove deprecated API as soon as WebKit calls new API.
-WebAudioDevice*
-RendererWebKitPlatformSupportImpl::createAudioDevice(
- size_t buffer_size,
- unsigned channels,
- double sample_rate,
- WebAudioDevice::RenderCallback* callback) {
- return createAudioDevice(
- buffer_size, 0, channels, sample_rate, callback, "default");
-}
-
-// TODO(crogers): remove deprecated API as soon as WebKit calls new API.
-WebAudioDevice*
-RendererWebKitPlatformSupportImpl::createAudioDevice(
- size_t buffer_size,
- unsigned input_channels,
- unsigned channels,
- double sample_rate,
- WebAudioDevice::RenderCallback* callback) {
- return createAudioDevice(
- buffer_size, input_channels, channels, sample_rate, callback, "default");
-}
-
WebAudioDevice*
RendererWebKitPlatformSupportImpl::createAudioDevice(
size_t buffer_size,
#if defined(OS_ANDROID)
bool RendererWebKitPlatformSupportImpl::loadAudioResource(
blink::WebAudioBus* destination_bus, const char* audio_file_data,
- size_t data_size, double sample_rate) {
+ size_t data_size) {
return DecodeAudioFileData(destination_bus,
audio_file_data,
data_size,
- sample_rate,
thread_safe_sender_);
}
#else
bool RendererWebKitPlatformSupportImpl::loadAudioResource(
blink::WebAudioBus* destination_bus, const char* audio_file_data,
- size_t data_size, double sample_rate) {
+ size_t data_size) {
return DecodeAudioFileData(
- destination_bus, audio_file_data, data_size, sample_rate);
+ destination_bus, audio_file_data, data_size);
}
#endif // defined(OS_ANDROID)
//------------------------------------------------------------------------------
-blink::WebContentDecryptionModule*
-RendererWebKitPlatformSupportImpl::createContentDecryptionModule(
- const blink::WebString& key_system) {
- return WebContentDecryptionModuleImpl::Create(key_system);
-}
-
-//------------------------------------------------------------------------------
-
blink::WebMIDIAccessor*
RendererWebKitPlatformSupportImpl::createMIDIAccessor(
blink::WebMIDIAccessorClient* client) {
#if defined(OS_WIN)
// On Windows screen color profile is only available in the browser.
std::vector<char> profile;
- RenderThread::Get()->Send(
+ // This Send() can be called from any impl-side thread. Use a thread
+ // safe send to avoid crashing trying to access RenderThread::Get(),
+ // which is not accessible from arbitrary threads.
+ thread_safe_sender_->Send(
new ViewHostMsg_GetMonitorColorProfile(&profile));
*to_profile = profile;
#else
- // On other platforms color profile can be obtained directly.
+ // On other platforms, the primary monitor color profile can be read
+ // directly.
gfx::ColorProfile profile;
*to_profile = profile.profile();
#endif
//------------------------------------------------------------------------------
+blink::WebScrollbarBehavior*
+ RendererWebKitPlatformSupportImpl::scrollbarBehavior() {
+ return web_scrollbar_behavior_.get();
+}
+
+//------------------------------------------------------------------------------
+
WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() {
// blob_registry_ can be NULL when running some tests.
return blob_registry_.get();
void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
if (g_test_gamepads == 0) {
- RenderThreadImpl::current()->SampleGamepads(&gamepads);
+ RenderThreadImpl::current()->gamepad_shared_memory_reader()->
+ SampleGamepads(gamepads);
} else {
gamepads = g_test_gamepads.Get();
}
}
-blink::WebString RendererWebKitPlatformSupportImpl::userAgent(
- const blink::WebURL& url) {
- return WebKitPlatformSupportImpl::userAgent(url);
+void RendererWebKitPlatformSupportImpl::setGamepadListener(
+ blink::WebGamepadListener* listener) {
+ web_gamepad_listener = listener;
+ RenderThreadImpl::current()->gamepad_shared_memory_reader()->
+ SetGamepadListener(listener);
}
//------------------------------------------------------------------------------
g_test_gamepads.Get() = pads;
}
+// static
+void RendererWebKitPlatformSupportImpl::MockGamepadConnected(
+ int index,
+ const WebGamepad& pad) {
+ if (web_gamepad_listener)
+ web_gamepad_listener->didConnectGamepad(index, pad);
+}
+
+// static
+void RendererWebKitPlatformSupportImpl::MockGamepadDisconnected(
+ int index,
+ const WebGamepad& pad) {
+ if (web_gamepad_listener)
+ web_gamepad_listener->didDisconnectGamepad(index, pad);
+}
+
//------------------------------------------------------------------------------
blink::WebSpeechSynthesizer*
blink::WebGraphicsContext3D*
RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) {
+ return createOffscreenGraphicsContext3D(attributes, NULL);
+}
+
+blink::WebGraphicsContext3D*
+RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ blink::WebGraphicsContext3D* share_context) {
if (!RenderThreadImpl::current())
return NULL;
+#if defined(OS_ANDROID)
+ if (SynchronousCompositorFactory* factory =
+ SynchronousCompositorFactory::GetInstance()) {
+ return factory->CreateOffscreenGraphicsContext3D(attributes);
+ }
+#endif
+
scoped_refptr<GpuChannelHost> gpu_channel_host(
RenderThreadImpl::current()->EstablishGpuChannelSync(
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
limits.command_buffer_size = buffer_size_kb * 1024;
}
}
-
+ bool lose_context_when_out_of_memory = false;
return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gpu_channel_host.get(),
attributes,
+ lose_context_when_out_of_memory,
GURL(attributes.topDocumentURL),
- limits);
+ limits,
+ static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context));
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-blink::WebCrypto* RendererWebKitPlatformSupportImpl::crypto() {
- if (!web_crypto_)
- web_crypto_.reset(new WebCryptoImpl());
- return web_crypto_.get();
-
-}
-
-//------------------------------------------------------------------------------
-
void RendererWebKitPlatformSupportImpl::vibrate(unsigned int milliseconds) {
RenderThread::Get()->Send(
new ViewHostMsg_Vibrate(base::checked_cast<int64>(milliseconds)));
//------------------------------------------------------------------------------
+void RendererWebKitPlatformSupportImpl::setScreenOrientationListener(
+ blink::WebScreenOrientationListener* listener) {
+ if (RenderThreadImpl::current() &&
+ RenderThreadImpl::current()->layout_test_mode()) {
+ // If we are in test mode, we want to fully disable the screen orientation
+ // backend in order to let Blink get tested properly, That means that screen
+ // orientation updates have to be done manually instead of from signals sent
+ // by the browser process.
+ g_test_screen_orientation_listener = listener;
+ return;
+ }
+
+ if (!screen_orientation_dispatcher_) {
+ screen_orientation_dispatcher_.reset(
+ new ScreenOrientationDispatcher(RenderThread::Get()));
+ }
+
+ screen_orientation_dispatcher_->setListener(listener);
+}
+
+void RendererWebKitPlatformSupportImpl::lockOrientation(
+ blink::WebScreenOrientationLockType orientation) {
+ if (RenderThreadImpl::current() &&
+ RenderThreadImpl::current()->layout_test_mode()) {
+ return;
+ }
+ RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation));
+}
+
+void RendererWebKitPlatformSupportImpl::unlockOrientation() {
+ if (RenderThreadImpl::current() &&
+ RenderThreadImpl::current()->layout_test_mode()) {
+ return;
+ }
+ RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock);
+}
+
+// static
+void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
+ blink::WebScreenOrientationType orientation) {
+ if (!g_test_screen_orientation_listener)
+ return;
+ g_test_screen_orientation_listener->didChangeScreenOrientation(orientation);
+}
+
+//------------------------------------------------------------------------------
+
void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota(
const blink::WebURL& storage_partition,
blink::WebStorageQuotaType type,