Commit 7a6988ee authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Update RendererWebPlatformSupportImpl to use {start,stop}Listening().

It doesn't do anything fancy but allows Blink to stop supporting the
previous API.

BUG=400158

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288060 0039d316-1c4b-4281-b951-d872f2087c98
parent 95539f00
...@@ -888,12 +888,6 @@ void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { ...@@ -888,12 +888,6 @@ void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
gamepad_provider_->SampleGamepads(gamepads); gamepad_provider_->SampleGamepads(gamepads);
} }
void RendererWebKitPlatformSupportImpl::setGamepadListener(
blink::WebGamepadListener* listener) {
DCHECK(gamepad_provider_);
gamepad_provider_->SetGamepadListener(listener);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
WebRTCPeerConnectionHandler* WebRTCPeerConnectionHandler*
...@@ -1021,24 +1015,6 @@ blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( ...@@ -1021,24 +1015,6 @@ blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::setDeviceLightListener(
blink::WebDeviceLightListener* listener) {
if (g_test_device_light_data < 0) {
if (!device_light_event_pump_) {
device_light_event_pump_.reset(new DeviceLightEventPump);
device_light_event_pump_->Attach(RenderThreadImpl::current());
}
device_light_event_pump_->SetListener(listener);
} else if (listener) {
// Testing mode: just echo the test data to the listener.
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(&blink::WebDeviceLightListener::didChangeDeviceLight,
base::Unretained(listener),
g_test_device_light_data));
}
}
// static // static
void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting( void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting(
double data) { double data) {
...@@ -1047,7 +1023,92 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting( ...@@ -1047,7 +1023,92 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::setDeviceMotionListener( // static
void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
const blink::WebDeviceMotionData& data) {
g_test_device_motion_data.Get() = data;
}
//------------------------------------------------------------------------------
// static
void RendererWebKitPlatformSupportImpl::SetMockDeviceOrientationDataForTesting(
const blink::WebDeviceOrientationData& data) {
g_test_device_orientation_data.Get() = data;
}
//------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::vibrate(unsigned int milliseconds) {
RenderThread::Get()->Send(
new ViewHostMsg_Vibrate(base::checked_cast<int64>(milliseconds)));
}
void RendererWebKitPlatformSupportImpl::cancelVibration() {
RenderThread::Get()->Send(new ViewHostMsg_CancelVibration());
}
//------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::startListening(
blink::WebPlatformEventType type,
blink::WebPlatformEventListener* listener) {
switch (type) {
case blink::WebPlatformEventDeviceMotion:
SetDeviceMotionListener(
static_cast<blink::WebDeviceMotionListener*>(listener));
break;
case blink::WebPlatformEventDeviceOrientation:
SetDeviceOrientationListener(
static_cast<blink::WebDeviceOrientationListener*>(listener));
break;
case blink::WebPlatformEventDeviceLight:
SetDeviceLightListener(
static_cast<blink::WebDeviceLightListener*>(listener));
break;
case blink::WebPlatformEventBattery:
SetBatteryStatusListener(
static_cast<blink::WebBatteryStatusListener*>(listener));
break;
case blink::WebPlatformEventGamepad:
SetGamepadListener(
static_cast<blink::WebGamepadListener*>(listener));
break;
default:
// A default statement is required to prevent compilation errors when Blink
// adds a new type.
VLOG(1) << "RendererWebKitPlatformSupportImpl::startListening() with "
"unknown type.";
}
}
void RendererWebKitPlatformSupportImpl::stopListening(
blink::WebPlatformEventType type) {
switch (type) {
case blink::WebPlatformEventDeviceMotion:
SetDeviceMotionListener(0);
break;
case blink::WebPlatformEventDeviceOrientation:
SetDeviceOrientationListener(0);
break;
case blink::WebPlatformEventDeviceLight:
SetDeviceLightListener(0);
break;
case blink::WebPlatformEventBattery:
SetBatteryStatusListener(0);
break;
case blink::WebPlatformEventGamepad:
SetGamepadListener(0);
break;
default:
// A default statement is required to prevent compilation errors when Blink
// adds a new type.
VLOG(1) << "RendererWebKitPlatformSupportImpl::stopListening() with "
"unknown type.";
}
}
void RendererWebKitPlatformSupportImpl::SetDeviceMotionListener(
blink::WebDeviceMotionListener* listener) { blink::WebDeviceMotionListener* listener) {
if (g_test_device_motion_data == 0) { if (g_test_device_motion_data == 0) {
if (!device_motion_event_pump_) { if (!device_motion_event_pump_) {
...@@ -1065,15 +1126,7 @@ void RendererWebKitPlatformSupportImpl::setDeviceMotionListener( ...@@ -1065,15 +1126,7 @@ void RendererWebKitPlatformSupportImpl::setDeviceMotionListener(
} }
} }
// static void RendererWebKitPlatformSupportImpl::SetDeviceOrientationListener(
void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
const blink::WebDeviceMotionData& data) {
g_test_device_motion_data.Get() = data;
}
//------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener(
blink::WebDeviceOrientationListener* listener) { blink::WebDeviceOrientationListener* listener) {
if (g_test_device_orientation_data == 0) { if (g_test_device_orientation_data == 0) {
if (!device_orientation_event_pump_) { if (!device_orientation_event_pump_) {
...@@ -1092,21 +1145,46 @@ void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener( ...@@ -1092,21 +1145,46 @@ void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener(
} }
} }
// static void RendererWebKitPlatformSupportImpl::SetDeviceLightListener(
void RendererWebKitPlatformSupportImpl::SetMockDeviceOrientationDataForTesting( blink::WebDeviceLightListener* listener) {
const blink::WebDeviceOrientationData& data) { if (g_test_device_light_data < 0) {
g_test_device_orientation_data.Get() = data; if (!device_light_event_pump_) {
device_light_event_pump_.reset(new DeviceLightEventPump);
device_light_event_pump_->Attach(RenderThreadImpl::current());
}
device_light_event_pump_->SetListener(listener);
} else if (listener) {
// Testing mode: just echo the test data to the listener.
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(&blink::WebDeviceLightListener::didChangeDeviceLight,
base::Unretained(listener),
g_test_device_light_data));
}
} }
//------------------------------------------------------------------------------ void RendererWebKitPlatformSupportImpl::SetGamepadListener(
blink::WebGamepadListener* listener) {
void RendererWebKitPlatformSupportImpl::vibrate(unsigned int milliseconds) { DCHECK(gamepad_provider_);
RenderThread::Get()->Send( gamepad_provider_->SetGamepadListener(listener);
new ViewHostMsg_Vibrate(base::checked_cast<int64>(milliseconds)));
} }
void RendererWebKitPlatformSupportImpl::cancelVibration() { void RendererWebKitPlatformSupportImpl::SetBatteryStatusListener(
RenderThread::Get()->Send(new ViewHostMsg_CancelVibration()); blink::WebBatteryStatusListener* listener) {
if (RenderThreadImpl::current() &&
RenderThreadImpl::current()->layout_test_mode()) {
// If we are in test mode, we want to use a fake battery status dispatcher,
// which does not communicate with the browser process. Battery status
// changes are signalled by invoking MockBatteryStatusChangedForTesting().
g_test_battery_status_dispatcher.Get().SetListener(listener);
return;
}
if (!battery_status_dispatcher_) {
battery_status_dispatcher_.reset(
new BatteryStatusDispatcher(RenderThreadImpl::current()));
}
battery_status_dispatcher_->SetListener(listener);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -1127,24 +1205,6 @@ void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( ...@@ -1127,24 +1205,6 @@ void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::setBatteryStatusListener(
blink::WebBatteryStatusListener* listener) {
if (RenderThreadImpl::current() &&
RenderThreadImpl::current()->layout_test_mode()) {
// If we are in test mode, we want to use a fake battery status dispatcher,
// which does not communicate with the browser process. Battery status
// changes are signalled by invoking MockBatteryStatusChangedForTesting().
g_test_battery_status_dispatcher.Get().SetListener(listener);
return;
}
if (!battery_status_dispatcher_) {
battery_status_dispatcher_.reset(
new BatteryStatusDispatcher(RenderThreadImpl::current()));
}
battery_status_dispatcher_->SetListener(listener);
}
// static // static
void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting(
const blink::WebBatteryStatus& status) { const blink::WebBatteryStatus& status) {
......
...@@ -120,7 +120,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl ...@@ -120,7 +120,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
virtual blink::WebBlobRegistry* blobRegistry(); virtual blink::WebBlobRegistry* blobRegistry();
virtual void sampleGamepads(blink::WebGamepads&); virtual void sampleGamepads(blink::WebGamepads&);
virtual void setGamepadListener(blink::WebGamepadListener*);
virtual blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler( virtual blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
blink::WebRTCPeerConnectionHandlerClient* client); blink::WebRTCPeerConnectionHandlerClient* client);
virtual blink::WebMediaStreamCenter* createMediaStreamCenter( virtual blink::WebMediaStreamCenter* createMediaStreamCenter(
...@@ -137,19 +136,15 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl ...@@ -137,19 +136,15 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
virtual blink::WebCompositorSupport* compositorSupport(); virtual blink::WebCompositorSupport* compositorSupport();
virtual blink::WebString convertIDNToUnicode( virtual blink::WebString convertIDNToUnicode(
const blink::WebString& host, const blink::WebString& languages); const blink::WebString& host, const blink::WebString& languages);
virtual void setDeviceLightListener(blink::WebDeviceLightListener* listener); virtual void startListening(blink::WebPlatformEventType,
virtual void setDeviceMotionListener( blink::WebPlatformEventListener*);
blink::WebDeviceMotionListener* listener); virtual void stopListening(blink::WebPlatformEventType);
virtual void setDeviceOrientationListener(
blink::WebDeviceOrientationListener* listener);
virtual void queryStorageUsageAndQuota( virtual void queryStorageUsageAndQuota(
const blink::WebURL& storage_partition, const blink::WebURL& storage_partition,
blink::WebStorageQuotaType, blink::WebStorageQuotaType,
blink::WebStorageQuotaCallbacks); blink::WebStorageQuotaCallbacks);
virtual void vibrate(unsigned int milliseconds); virtual void vibrate(unsigned int milliseconds);
virtual void cancelVibration(); virtual void cancelVibration();
virtual void setBatteryStatusListener(
blink::WebBatteryStatusListener* listener);
void set_gamepad_provider(RendererGamepadProvider* provider) { void set_gamepad_provider(RendererGamepadProvider* provider) {
gamepad_provider_ = provider; gamepad_provider_ = provider;
...@@ -185,6 +180,15 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl ...@@ -185,6 +180,15 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
private: private:
bool CheckPreparsedJsCachingEnabled() const; bool CheckPreparsedJsCachingEnabled() const;
// Implement those methods internally so startListening() and stopListening()
// are being used and Blink can change its interface.
void SetDeviceMotionListener(blink::WebDeviceMotionListener*);
void SetDeviceOrientationListener(blink::WebDeviceOrientationListener*);
void SetDeviceLightListener(blink::WebDeviceLightListener*);
void SetBatteryStatusListener(blink::WebBatteryStatusListener*);
void SetGamepadListener(blink::WebGamepadListener*);
scoped_ptr<RendererClipboardClient> clipboard_client_; scoped_ptr<RendererClipboardClient> clipboard_client_;
scoped_ptr<WebClipboardImpl> clipboard_; scoped_ptr<WebClipboardImpl> clipboard_;
......
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