| 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/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 namespace content { | 138 namespace content { |
| 139 | 139 |
| 140 static bool g_sandbox_enabled = true; | 140 static bool g_sandbox_enabled = true; |
| 141 static blink::WebGamepadListener* web_gamepad_listener = NULL; | 141 static blink::WebGamepadListener* web_gamepad_listener = NULL; |
| 142 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = | 142 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
| 143 LAZY_INSTANCE_INITIALIZER; | 143 LAZY_INSTANCE_INITIALIZER; |
| 144 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 144 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
| 145 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 145 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
| 146 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 146 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
| 147 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 147 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
| 148 base::LazyInstance<blink::WebScreenOrientationType>::Leaky | 148 static blink::WebScreenOrientationListener* |
| 149 g_test_screen_orientation_value = LAZY_INSTANCE_INITIALIZER; | 149 g_test_screen_orientation_listener = NULL; |
| 150 | 150 |
| 151 //------------------------------------------------------------------------------ | 151 //------------------------------------------------------------------------------ |
| 152 | 152 |
| 153 class RendererWebKitPlatformSupportImpl::MimeRegistry | 153 class RendererWebKitPlatformSupportImpl::MimeRegistry |
| 154 : public SimpleWebMimeRegistryImpl { | 154 : public SimpleWebMimeRegistryImpl { |
| 155 public: | 155 public: |
| 156 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 156 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
| 157 const blink::WebString& mime_type, | 157 const blink::WebString& mime_type, |
| 158 const blink::WebString& codecs, | 158 const blink::WebString& codecs, |
| 159 const blink::WebString& key_system); | 159 const blink::WebString& key_system); |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 void RendererWebKitPlatformSupportImpl::cancelVibration() { | 1114 void RendererWebKitPlatformSupportImpl::cancelVibration() { |
| 1115 RenderThread::Get()->Send(new ViewHostMsg_CancelVibration()); | 1115 RenderThread::Get()->Send(new ViewHostMsg_CancelVibration()); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 //------------------------------------------------------------------------------ | 1118 //------------------------------------------------------------------------------ |
| 1119 | 1119 |
| 1120 void RendererWebKitPlatformSupportImpl::setScreenOrientationListener( | 1120 void RendererWebKitPlatformSupportImpl::setScreenOrientationListener( |
| 1121 blink::WebScreenOrientationListener* listener) { | 1121 blink::WebScreenOrientationListener* listener) { |
| 1122 if (!(g_test_screen_orientation_value == 0)) { | 1122 if (RenderThreadImpl::current() && |
| 1123 if (!listener) | 1123 RenderThreadImpl::current()->layout_test_mode()) { |
| 1124 return; | 1124 // If we are in test mode, we want to fully disable the screen orientation |
| 1125 | 1125 // backend in order to let Blink get tested properly, That means that screen |
| 1126 // When testing, we only pretend that the screen orientation is now set to | 1126 // orientation updates have to be done manually instead of from signals sent |
| 1127 // g_test_screen_orientation_value. | 1127 // by the browser process. |
| 1128 base::MessageLoopProxy::current()->PostTask( | 1128 g_test_screen_orientation_listener = listener; |
| 1129 FROM_HERE, | |
| 1130 base::Bind( | |
| 1131 &blink::WebScreenOrientationListener::didChangeScreenOrientation, | |
| 1132 base::Unretained(listener), | |
| 1133 g_test_screen_orientation_value.Get())); | |
| 1134 return; | 1129 return; |
| 1135 } | 1130 } |
| 1136 | 1131 |
| 1137 if (!screen_orientation_dispatcher_) { | 1132 if (!screen_orientation_dispatcher_) { |
| 1138 screen_orientation_dispatcher_.reset( | 1133 screen_orientation_dispatcher_.reset( |
| 1139 new ScreenOrientationDispatcher(RenderThread::Get())); | 1134 new ScreenOrientationDispatcher(RenderThread::Get())); |
| 1140 } | 1135 } |
| 1141 | 1136 |
| 1142 screen_orientation_dispatcher_->setListener(listener); | 1137 screen_orientation_dispatcher_->setListener(listener); |
| 1143 } | 1138 } |
| 1144 | 1139 |
| 1145 void RendererWebKitPlatformSupportImpl::lockOrientation( | 1140 void RendererWebKitPlatformSupportImpl::lockOrientation( |
| 1146 blink::WebScreenOrientationLockType orientation) { | 1141 blink::WebScreenOrientationLockType orientation) { |
| 1147 // No-op if we are currently using mock values. | 1142 if (RenderThreadImpl::current() && |
| 1148 if (!(g_test_screen_orientation_value == 0)) | 1143 RenderThreadImpl::current()->layout_test_mode()) { |
| 1149 return; | 1144 return; |
| 1145 } |
| 1150 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation)); | 1146 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation)); |
| 1151 } | 1147 } |
| 1152 | 1148 |
| 1153 void RendererWebKitPlatformSupportImpl::unlockOrientation() { | 1149 void RendererWebKitPlatformSupportImpl::unlockOrientation() { |
| 1154 // No-op if we are currently using mock values. | 1150 if (RenderThreadImpl::current() && |
| 1155 if (!(g_test_screen_orientation_value == 0)) | 1151 RenderThreadImpl::current()->layout_test_mode()) { |
| 1156 return; | 1152 return; |
| 1153 } |
| 1157 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock); | 1154 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock); |
| 1158 } | 1155 } |
| 1159 | 1156 |
| 1160 // static | 1157 // static |
| 1161 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( | 1158 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( |
| 1162 blink::WebScreenOrientationType orientation) { | 1159 blink::WebScreenOrientationType orientation) { |
| 1163 g_test_screen_orientation_value.Get() = orientation; | 1160 if (!g_test_screen_orientation_listener) |
| 1161 return; |
| 1162 g_test_screen_orientation_listener->didChangeScreenOrientation(orientation); |
| 1164 } | 1163 } |
| 1165 | 1164 |
| 1166 //------------------------------------------------------------------------------ | 1165 //------------------------------------------------------------------------------ |
| 1167 | 1166 |
| 1168 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( | 1167 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( |
| 1169 const blink::WebURL& storage_partition, | 1168 const blink::WebURL& storage_partition, |
| 1170 blink::WebStorageQuotaType type, | 1169 blink::WebStorageQuotaType type, |
| 1171 blink::WebStorageQuotaCallbacks callbacks) { | 1170 blink::WebStorageQuotaCallbacks callbacks) { |
| 1172 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) | 1171 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) |
| 1173 return; | 1172 return; |
| 1174 QuotaDispatcher::ThreadSpecificInstance( | 1173 QuotaDispatcher::ThreadSpecificInstance( |
| 1175 thread_safe_sender_.get(), | 1174 thread_safe_sender_.get(), |
| 1176 quota_message_filter_.get())->QueryStorageUsageAndQuota( | 1175 quota_message_filter_.get())->QueryStorageUsageAndQuota( |
| 1177 storage_partition, | 1176 storage_partition, |
| 1178 static_cast<quota::StorageType>(type), | 1177 static_cast<quota::StorageType>(type), |
| 1179 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 1178 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
| 1180 } | 1179 } |
| 1181 | 1180 |
| 1182 } // namespace content | 1181 } // namespace content |
| OLD | NEW |