Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 268673015: Support screen.lockOrientation() / screen.unlockOrientation() when running layout tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 static blink::WebScreenOrientationLockType g_test_current_screen_lock =
149 blink::WebScreenOrientationLockDefault;
150 static blink::WebScreenOrientationType g_test_device_screen_orientation =
151 blink::WebScreenOrientationPortraitPrimary;
152 static blink::WebScreenOrientationType g_test_current_screen_orientation =
153 blink::WebScreenOrientationPortraitPrimary;
148 static blink::WebScreenOrientationListener* 154 static blink::WebScreenOrientationListener*
149 g_test_screen_orientation_listener = NULL; 155 g_test_screen_orientation_listener = NULL;
150 156
151 //------------------------------------------------------------------------------ 157 //------------------------------------------------------------------------------
152 158
153 class RendererWebKitPlatformSupportImpl::MimeRegistry 159 class RendererWebKitPlatformSupportImpl::MimeRegistry
154 : public SimpleWebMimeRegistryImpl { 160 : public SimpleWebMimeRegistryImpl {
155 public: 161 public:
156 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( 162 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
157 const blink::WebString& mime_type, 163 const blink::WebString& mime_type,
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1137 }
1132 1138
1133 if (!screen_orientation_dispatcher_) { 1139 if (!screen_orientation_dispatcher_) {
1134 screen_orientation_dispatcher_.reset( 1140 screen_orientation_dispatcher_.reset(
1135 new ScreenOrientationDispatcher(RenderThread::Get())); 1141 new ScreenOrientationDispatcher(RenderThread::Get()));
1136 } 1142 }
1137 1143
1138 screen_orientation_dispatcher_->setListener(listener); 1144 screen_orientation_dispatcher_->setListener(listener);
1139 } 1145 }
1140 1146
1147 namespace {
1148
1149 bool isScreenOrientationAllowedByTestingLock(blink::WebScreenOrientationType
jochen (gone - plz use gerrit) 2014/05/06 15:59:01 that doesn't look correctly wrapped, did you use c
Inactive 2014/05/06 16:26:22 I am not familiar with the Chromium-side coding st
Inactive 2014/05/06 16:56:45 Done.
1150 orientation)
1151 {
1152 if (g_test_current_screen_lock == blink::WebScreenOrientationLockDefault ||
1153 g_test_current_screen_lock == blink::WebScreenOrientationLockAny)
1154 return true;
1155
1156 switch (orientation) {
1157 case blink::WebScreenOrientationPortraitPrimary:
1158 return g_test_current_screen_lock ==
1159 blink::WebScreenOrientationLockPortraitPrimary
1160 || g_test_current_screen_lock ==
1161 blink::WebScreenOrientationLockPortrait;
1162 case blink::WebScreenOrientationPortraitSecondary:
1163 return g_test_current_screen_lock ==
1164 blink::WebScreenOrientationLockPortraitSecondary
1165 || g_test_current_screen_lock ==
1166 blink::WebScreenOrientationLockPortrait;
1167 case blink::WebScreenOrientationLandscapePrimary:
1168 return g_test_current_screen_lock ==
1169 blink::WebScreenOrientationLockLandscapePrimary
1170 || g_test_current_screen_lock ==
1171 blink::WebScreenOrientationLockLandscape;
1172 case blink::WebScreenOrientationLandscapeSecondary:
1173 return g_test_current_screen_lock ==
1174 blink::WebScreenOrientationLockLandscapeSecondary
1175 || g_test_current_screen_lock ==
1176 blink::WebScreenOrientationLockLandscape;
1177 default:
1178 return false;
1179 }
1180 }
1181
1182 blink::WebScreenOrientationType suitableScreenOrientationForTestingLock()
1183 {
1184 switch(g_test_current_screen_lock) {
1185 case blink::WebScreenOrientationLockPortraitSecondary:
1186 return blink::WebScreenOrientationPortraitSecondary;
1187 case blink::WebScreenOrientationLockLandscapePrimary:
1188 case blink::WebScreenOrientationLockLandscape:
1189 return blink::WebScreenOrientationLandscapePrimary;
1190 case blink::WebScreenOrientationLockLandscapeSecondary:
1191 return blink::WebScreenOrientationLandscapePrimary;
1192 default:
1193 return blink::WebScreenOrientationPortraitPrimary;
1194 }
1195 }
1196
1197 void updateScreenOrientationForTesting(blink::WebScreenOrientationType
1198 orientation)
1199 {
1200 if (orientation == g_test_current_screen_orientation)
1201 return;
1202 g_test_current_screen_orientation = orientation;
1203 if (g_test_screen_orientation_listener)
1204 g_test_screen_orientation_listener->didChangeScreenOrientation(orientation);
1205 }
1206
1207 } // namespace
1208
1141 void RendererWebKitPlatformSupportImpl::lockOrientation( 1209 void RendererWebKitPlatformSupportImpl::lockOrientation(
1142 blink::WebScreenOrientationLockType orientation) { 1210 blink::WebScreenOrientationLockType orientation) {
1143 if (RenderThreadImpl::current() && 1211 if (RenderThreadImpl::current() &&
1144 RenderThreadImpl::current()->layout_test_mode()) { 1212 RenderThreadImpl::current()->layout_test_mode()) {
1213 g_test_current_screen_lock = orientation;
1214 if (!isScreenOrientationAllowedByTestingLock(
1215 g_test_current_screen_orientation)) {
1216 g_test_current_screen_orientation =
1217 suitableScreenOrientationForTestingLock();
1218 if (g_test_screen_orientation_listener) {
1219 g_test_screen_orientation_listener->didChangeScreenOrientation(
1220 g_test_current_screen_orientation);
1221 }
1222 }
1145 return; 1223 return;
1146 } 1224 }
1147 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation)); 1225 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation));
1148 } 1226 }
1149 1227
1150 void RendererWebKitPlatformSupportImpl::unlockOrientation() { 1228 void RendererWebKitPlatformSupportImpl::unlockOrientation() {
1151 if (RenderThreadImpl::current() && 1229 if (RenderThreadImpl::current() &&
1152 RenderThreadImpl::current()->layout_test_mode()) { 1230 RenderThreadImpl::current()->layout_test_mode()) {
1231 bool should_update_current_screen_orientation =
1232 !isScreenOrientationAllowedByTestingLock(
1233 g_test_device_screen_orientation);
1234 g_test_current_screen_lock = blink::WebScreenOrientationLockDefault;
1235 if (should_update_current_screen_orientation)
1236 updateScreenOrientationForTesting(g_test_device_screen_orientation);
1153 return; 1237 return;
1154 } 1238 }
1155 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock); 1239 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock);
1156 } 1240 }
1157 1241
1158 // static 1242 // static
1159 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( 1243 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
1160 blink::WebScreenOrientationType orientation) { 1244 blink::WebScreenOrientationType orientation) {
1161 if (!g_test_screen_orientation_listener) 1245 g_test_device_screen_orientation = orientation;
1246 if (!isScreenOrientationAllowedByTestingLock(orientation))
1162 return; 1247 return;
1163 g_test_screen_orientation_listener->didChangeScreenOrientation(orientation); 1248 updateScreenOrientationForTesting(g_test_device_screen_orientation);
1164 } 1249 }
1165 1250
1166 //------------------------------------------------------------------------------ 1251 //------------------------------------------------------------------------------
1167 1252
1168 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( 1253 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota(
1169 const blink::WebURL& storage_partition, 1254 const blink::WebURL& storage_partition,
1170 blink::WebStorageQuotaType type, 1255 blink::WebStorageQuotaType type,
1171 blink::WebStorageQuotaCallbacks callbacks) { 1256 blink::WebStorageQuotaCallbacks callbacks) {
1172 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1257 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1173 return; 1258 return;
1174 QuotaDispatcher::ThreadSpecificInstance( 1259 QuotaDispatcher::ThreadSpecificInstance(
1175 thread_safe_sender_.get(), 1260 thread_safe_sender_.get(),
1176 quota_message_filter_.get())->QueryStorageUsageAndQuota( 1261 quota_message_filter_.get())->QueryStorageUsageAndQuota(
1177 storage_partition, 1262 storage_partition,
1178 static_cast<quota::StorageType>(type), 1263 static_cast<quota::StorageType>(type),
1179 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1264 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1180 } 1265 }
1181 1266
1182 } // namespace content 1267 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698