Diff
Modified: trunk/LayoutTests/ChangeLog (113612 => 113613)
--- trunk/LayoutTests/ChangeLog 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/LayoutTests/ChangeLog 2012-04-09 20:43:59 UTC (rev 113613)
@@ -1,3 +1,15 @@
+2012-04-09 Sadrul Habib Chowdhury <[email protected]>
+
+ [chromium] Add Battery Status API support.
+
+ Add Battery Status API support to chromium.
+ https://bugs.webkit.org/show_bug.cgi?id=83284
+
+ Reviewed by Adam Barth.
+
+ * platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt:
+ * platform/chromium/test_expectations.txt:
+
2012-04-09 SravanKumar Sandela <[email protected]>
Unnecessary scroll bar after changing the dimensions of a DIV
Modified: trunk/LayoutTests/platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt (113612 => 113613)
--- trunk/LayoutTests/platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/LayoutTests/platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt 2012-04-09 20:43:59 UTC (rev 113613)
@@ -17,6 +17,7 @@
navigator.userAgent is OK
navigator.vendor is OK
navigator.vendorSub is OK
+navigator.webkitBattery is OK
navigator.webkitGamepads is OK
navigator.webkitPointer is OK
navigator.webkitStartActivity() threw err TypeError: Not enough arguments
@@ -37,6 +38,7 @@
navigator.userAgent is OK
navigator.vendor is OK
navigator.vendorSub is OK
+navigator.webkitBattery is OK
navigator.webkitGamepads is OK
navigator.webkitPointer is OK
navigator.webkitStartActivity() threw err TypeError: Not enough arguments
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (113612 => 113613)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-04-09 20:43:59 UTC (rev 113613)
@@ -132,9 +132,6 @@
// Vibration API is not supported yet in the chromium port.
BUGWK72010 SKIP : fast/dom/navigator-vibration.html = FAIL
-// Battery Status API is not supported yet in the chromium port.
-BUGWK62698 SKIP : batterystatus = PASS FAIL
-
// Touch Adjustment is not supported yet in the chromium port.
BUGWK78801 SKIP : touchadjustment/ = FAIL
Modified: trunk/Source/WebCore/ChangeLog (113612 => 113613)
--- trunk/Source/WebCore/ChangeLog 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebCore/ChangeLog 2012-04-09 20:43:59 UTC (rev 113613)
@@ -1,3 +1,23 @@
+2012-04-09 Sadrul Habib Chowdhury <[email protected]>
+
+ [chromium] Add Battery Status API support.
+
+ Add Battery Status API support to chromium.
+ https://bugs.webkit.org/show_bug.cgi?id=83284
+
+ Reviewed by Adam Barth.
+
+ This change is covered by tests in batterystatus/.
+
+ * Modules/battery/BatteryController.cpp:
+ (WebCore::BatteryController::updateBatteryStatus):
+ (WebCore):
+ * Modules/battery/BatteryController.h:
+ (BatteryController):
+ * Modules/battery/BatteryManager.cpp:
+ * WebCore.gyp/WebCore.gyp:
+ * WebCore.gypi:
+
2012-04-09 SravanKumar Sandela <[email protected]>
Unnecessary scroll bar after changing the dimensions of a DIV
Modified: trunk/Source/WebCore/Modules/battery/BatteryController.cpp (113612 => 113613)
--- trunk/Source/WebCore/Modules/battery/BatteryController.cpp 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebCore/Modules/battery/BatteryController.cpp 2012-04-09 20:43:59 UTC (rev 113613)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Samsung Electronics
+ * Copyright (C) 2012 Google Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -63,6 +64,25 @@
m_client->stopUpdating();
}
+void BatteryController::updateBatteryStatus(PassRefPtr<BatteryStatus> batteryStatus)
+{
+ RefPtr<BatteryStatus> status = batteryStatus;
+ if (m_batteryStatus) {
+
+ if (m_batteryStatus->charging() != status->charging())
+ didChangeBatteryStatus(WebCore::eventNames().chargingchangeEvent, status);
+ else if (status->charging() && m_batteryStatus->chargingTime() != status->chargingTime())
+ didChangeBatteryStatus(WebCore::eventNames().chargingtimechangeEvent, status);
+ else if (!status->charging() && m_batteryStatus->dischargingTime() != status->dischargingTime())
+ didChangeBatteryStatus(WebCore::eventNames().dischargingtimechangeEvent, status);
+
+ if (m_batteryStatus->level() != status->level())
+ didChangeBatteryStatus(WebCore::eventNames().levelchangeEvent, status);
+ }
+
+ m_batteryStatus = status.release();
+}
+
void BatteryController::didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
{
RefPtr<Event> event = Event::create(eventType, false, false);
Modified: trunk/Source/WebCore/Modules/battery/BatteryController.h (113612 => 113613)
--- trunk/Source/WebCore/Modules/battery/BatteryController.h 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebCore/Modules/battery/BatteryController.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Samsung Electronics
+ * Copyright (C) 2012 Google Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -37,6 +38,7 @@
void addListener(BatteryManager*);
void removeListener(BatteryManager*);
+ void updateBatteryStatus(PassRefPtr<BatteryStatus>);
void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
BatteryClient* client() const { return m_client; }
@@ -52,6 +54,8 @@
BatteryClient* m_client;
ListenerVector m_listeners;
+
+ RefPtr<BatteryStatus> m_batteryStatus;
};
}
Modified: trunk/Source/WebCore/Modules/battery/BatteryManager.cpp (113612 => 113613)
--- trunk/Source/WebCore/Modules/battery/BatteryManager.cpp 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebCore/Modules/battery/BatteryManager.cpp 2012-04-09 20:43:59 UTC (rev 113613)
@@ -24,6 +24,7 @@
#include "BatteryController.h"
#include "BatteryStatus.h"
+#include "Document.h"
#include "Event.h"
#include "Frame.h"
#include "Navigator.h"
Modified: trunk/Source/WebCore/WebCore.gyp/WebCore.gyp (113612 => 113613)
--- trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2012-04-09 20:43:59 UTC (rev 113613)
@@ -51,6 +51,7 @@
'webcore_include_dirs': [
'../',
'../..',
+ '../Modules/battery',
'../Modules/filesystem',
'../Modules/filesystem/chromium',
'../Modules/gamepad',
Modified: trunk/Source/WebCore/WebCore.gypi (113612 => 113613)
--- trunk/Source/WebCore/WebCore.gypi 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebCore/WebCore.gypi 2012-04-09 20:43:59 UTC (rev 113613)
@@ -746,6 +746,8 @@
'svg/properties/SVGTransformListPropertyTearOff.h',
],
'webcore_bindings_idl_files': [
+ 'Modules/battery/BatteryManager.idl',
+ 'Modules/battery/NavigatorBattery.idl',
'Modules/filesystem/DOMFileSystem.idl',
'Modules/filesystem/DOMFileSystemSync.idl',
'Modules/filesystem/DOMWindowFileSystem.idl',
@@ -1329,6 +1331,15 @@
'svg/SVGZoomEvent.idl',
],
'webcore_files': [
+ 'Modules/battery/BatteryClient.h',
+ 'Modules/battery/BatteryController.cpp',
+ 'Modules/battery/BatteryController.h',
+ 'Modules/battery/BatteryManager.cpp',
+ 'Modules/battery/BatteryManager.h',
+ 'Modules/battery/BatteryStatus.cpp',
+ 'Modules/battery/BatteryStatus.h',
+ 'Modules/battery/NavigatorBattery.cpp',
+ 'Modules/battery/NavigatorBattery.h',
'Modules/filesystem/DOMFilePath.cpp',
'Modules/filesystem/DOMFilePath.h',
'Modules/filesystem/DOMFileSystem.cpp',
Modified: trunk/Source/WebKit/chromium/ChangeLog (113612 => 113613)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-04-09 20:43:59 UTC (rev 113613)
@@ -1,3 +1,53 @@
+2012-04-09 Sadrul Habib Chowdhury <[email protected]>
+
+ [chromium] Add Battery Status API support.
+
+ The battery-client (BatteryClientChromium) will notify the client (WebBatteryStatusClient) when to start or stop
+ sending battery status updates. The client, in response will send the notifications to WebViewImpl, which sends
+ this update information to the WebCore::BatteryClient, and it triggers the appropriate _javascript_-callbacks.
+ The spec is at http://www.w3.org/TR/2011/WD-battery-status-20111129/.
+ https://bugs.webkit.org/show_bug.cgi?id=83284
+
+ Reviewed by Adam Barth.
+
+ * WebKit.gyp:
+ * features.gypi:
+ * public/WebBatteryStatus.h: Added.
+ (WebKit):
+ (WebBatteryStatus):
+ (WebKit::WebBatteryStatus::WebBatteryStatus):
+ * public/WebBatteryStatusClient.h: Added.
+ (WebKit):
+ (WebBatteryStatusClient):
+ (WebKit::WebBatteryStatusClient::~WebBatteryStatusClient):
+ * public/WebView.h:
+ (WebKit):
+ (WebView):
+ (WebKit::WebView::updateBatteryStatus):
+ * public/WebViewClient.h:
+ (WebKit):
+ (WebViewClient):
+ (WebKit::WebViewClient::batteryStatusClient):
+ * src/BatteryClientImpl.cpp: Added.
+ (WebKit):
+ (WebKit::BatteryClientImpl::BatteryClientImpl):
+ (WebKit::BatteryClientImpl::updateBatteryStatus):
+ (WebKit::BatteryClientImpl::setController):
+ (WebKit::BatteryClientImpl::startUpdating):
+ (WebKit::BatteryClientImpl::stopUpdating):
+ (WebKit::BatteryClientImpl::batteryControllerDestroyed):
+ * src/BatteryClientImpl.h: Added.
+ (WebKit):
+ (BatteryClientImpl):
+ (WebKit::BatteryClientImpl::~BatteryClientImpl):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::WebViewImpl):
+ (WebKit):
+ (WebKit::WebViewImpl::updateBatteryStatus):
+ * src/WebViewImpl.h:
+ (WebKit):
+ (WebViewImpl):
+
2012-04-09 Shawn Singh <[email protected]>
[chromium] Fix layer sorting perspective w if w becomes negative
Modified: trunk/Source/WebKit/chromium/WebKit.gyp (113612 => 113613)
--- trunk/Source/WebKit/chromium/WebKit.gyp 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/WebKit.gyp 2012-04-09 20:43:59 UTC (rev 113613)
@@ -102,6 +102,8 @@
'public/WebAudioSourceProvider.h',
'public/WebAudioSourceProviderClient.h',
'public/WebAutofillClient.h',
+ 'public/WebBatteryStatus.h',
+ 'public/WebBatteryStatusClient.h',
'public/WebBindings.h',
'public/WebBlob.h',
'public/WebCache.h',
@@ -369,6 +371,8 @@
'src/AutofillPopupMenuClient.h',
'src/BackForwardListChromium.cpp',
'src/BackForwardListChromium.h',
+ 'src/BatteryClientImpl.cpp',
+ 'src/BatteryClientImpl.h',
'src/BlobRegistryProxy.cpp',
'src/BlobRegistryProxy.h',
'src/CCThreadImpl.cpp',
Modified: trunk/Source/WebKit/chromium/features.gypi (113612 => 113613)
--- trunk/Source/WebKit/chromium/features.gypi 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/features.gypi 2012-04-09 20:43:59 UTC (rev 113613)
@@ -33,6 +33,7 @@
'variables': {
'feature_defines': [
'ENABLE_3D_PLUGIN=1',
+ 'ENABLE_BATTERY_STATUS=1',
'ENABLE_BLOB=1',
'ENABLE_BLOB_SLICE=1',
'ENABLE_CHANNEL_MESSAGING=1',
Added: trunk/Source/WebKit/chromium/public/WebBatteryStatus.h (0 => 113613)
--- trunk/Source/WebKit/chromium/public/WebBatteryStatus.h (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebBatteryStatus.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebBatteryStatus_h
+#define WebBatteryStatus_h
+
+#include "platform/WebCommon.h"
+
+namespace WebKit {
+
+class WebBatteryStatus {
+public:
+ WebBatteryStatus()
+ : charging(true)
+ , chargingTime(0.0)
+ , dischargingTime(0.0)
+ , level(0.0)
+ {
+ }
+
+ bool charging;
+ double chargingTime;
+ double dischargingTime;
+ double level;
+};
+
+} // namespace WebKit
+
+#endif // WebBatteryStatus_h
Added: trunk/Source/WebKit/chromium/public/WebBatteryStatusClient.h (0 => 113613)
--- trunk/Source/WebKit/chromium/public/WebBatteryStatusClient.h (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebBatteryStatusClient.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebBatteryStatusClient_h
+#define WebBatteryStatusClient_h
+
+namespace WebKit {
+
+class WebBatteryStatusClient {
+public:
+ virtual ~WebBatteryStatusClient() { }
+
+ virtual void startUpdating() = 0;
+ virtual void stopUpdating() = 0;
+};
+
+} // namespace WebKit
+
+#endif // WebBatteryStatusClient_h
Modified: trunk/Source/WebKit/chromium/public/WebView.h (113612 => 113613)
--- trunk/Source/WebKit/chromium/public/WebView.h 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/public/WebView.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -41,6 +41,7 @@
class WebAccessibilityObject;
class WebAutofillClient;
+class WebBatteryStatus;
class WebDevToolsAgent;
class WebDevToolsAgentClient;
class WebDragData;
@@ -454,6 +455,13 @@
virtual void addPageOverlay(WebPageOverlay*, int /*z-order*/) = 0;
virtual void removePageOverlay(WebPageOverlay*) = 0;
+ // Battery status API support -------------------------------------------
+
+ // Updates the battery status in the BatteryClient. This also triggers the
+ // appropriate JS events (e.g. sends a 'levelchange' event to JS if the
+ // level is changed in this update from the previous update).
+ virtual void updateBatteryStatus(const WebBatteryStatus&) { }
+
// Testing functionality for LayoutTestController -----------------------
// Simulates a compositor lost context.
Modified: trunk/Source/WebKit/chromium/public/WebViewClient.h (113612 => 113613)
--- trunk/Source/WebKit/chromium/public/WebViewClient.h 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/public/WebViewClient.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -48,6 +48,7 @@
namespace WebKit {
class WebAccessibilityObject;
+class WebBatteryStatusClient;
class WebColorChooser;
class WebColorChooserClient;
class WebDeviceOrientationClient;
@@ -325,7 +326,11 @@
// Access the embedder API for device orientation services.
virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; }
+ // Battery Status ------------------------------------------------------
+ // Access the embedder API for battery status services.
+ virtual WebBatteryStatusClient* batteryStatusClient() { return 0; }
+
// Zoom ----------------------------------------------------------------
// Informs the browser that the zoom levels for this frame have changed from
Added: trunk/Source/WebKit/chromium/src/BatteryClientImpl.cpp (0 => 113613)
--- trunk/Source/WebKit/chromium/src/BatteryClientImpl.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/src/BatteryClientImpl.cpp 2012-04-09 20:43:59 UTC (rev 113613)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BatteryClientImpl.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryController.h"
+#include "BatteryStatus.h"
+#include "EventNames.h"
+#include "WebBatteryStatusClient.h"
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+BatteryClientImpl::BatteryClientImpl(WebBatteryStatusClient* client)
+ : m_client(client)
+ , m_controller(0)
+{
+}
+
+void BatteryClientImpl::updateBatteryStatus(const WebBatteryStatus& batteryStatus)
+{
+ if (m_controller) {
+ RefPtr<WebCore::BatteryStatus> status = WebCore::BatteryStatus::create(batteryStatus.charging, batteryStatus.chargingTime, batteryStatus.dischargingTime, batteryStatus.level);
+ m_controller->updateBatteryStatus(status);
+ }
+}
+
+void BatteryClientImpl::setController(WebCore::BatteryController* controller)
+{
+ m_controller = controller;
+}
+
+void BatteryClientImpl::startUpdating()
+{
+ if (m_client)
+ m_client->startUpdating();
+}
+
+void BatteryClientImpl::stopUpdating()
+{
+ if (m_client)
+ m_client->stopUpdating();
+}
+
+void BatteryClientImpl::batteryControllerDestroyed()
+{
+ m_controller = 0;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
Added: trunk/Source/WebKit/chromium/src/BatteryClientImpl.h (0 => 113613)
--- trunk/Source/WebKit/chromium/src/BatteryClientImpl.h (rev 0)
+++ trunk/Source/WebKit/chromium/src/BatteryClientImpl.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BatteryClientImpl_h
+#define BatteryClientImpl_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryClient.h"
+#include "WebBatteryStatus.h"
+
+namespace WebKit {
+
+class WebBatteryStatusClient;
+
+class BatteryClientImpl : public WebCore::BatteryClient {
+public:
+ explicit BatteryClientImpl(WebBatteryStatusClient*);
+ virtual ~BatteryClientImpl() { }
+
+ void updateBatteryStatus(const WebBatteryStatus&);
+
+ // WebCore::BatteryClient methods:
+ virtual void setController(WebCore::BatteryController*) OVERRIDE;
+ virtual void startUpdating() OVERRIDE;
+ virtual void stopUpdating() OVERRIDE;
+ virtual void batteryControllerDestroyed() OVERRIDE;
+
+private:
+ WebBatteryStatusClient* m_client;
+ WebCore::BatteryController* m_controller;
+};
+
+} // namespce WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // BatteryClientImpl_h
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (113612 => 113613)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-04-09 20:43:59 UTC (rev 113613)
@@ -35,6 +35,7 @@
#include "ActivePlatformGestureAnimation.h"
#include "AutofillPopupMenuClient.h"
#include "BackForwardListChromium.h"
+#include "BatteryClientImpl.h"
#include "CSSStyleSelector.h"
#include "CSSValueKeywords.h"
#include "Chrome.h"
@@ -385,6 +386,9 @@
#endif
, m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
, m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
+#if ENABLE(BATTERY_STATUS)
+ , m_batteryClient(adoptPtr(new BatteryClientImpl(client ? client->batteryStatusClient() : 0)))
+#endif
, m_emulatedTextZoomFactor(1)
#if ENABLE(MEDIA_STREAM)
, m_userMediaClientImpl(this)
@@ -425,6 +429,10 @@
provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get());
m_geolocationClientProxy->setController(GeolocationController::from(m_page.get()));
+
+#if ENABLE(BATTERY_STATUS)
+ provideBatteryTo(m_page.get(), m_batteryClient.get());
+#endif
m_page->setGroupName(pageGroupName);
@@ -1374,6 +1382,13 @@
InspectorInstrumentation::didCancelFrame(m_page.get());
}
+#if ENABLE(BATTERY_STATUS)
+void WebViewImpl::updateBatteryStatus(const WebBatteryStatus& status)
+{
+ m_batteryClient->updateBatteryStatus(status);
+}
+#endif
+
void WebViewImpl::animate(double)
{
#if ENABLE(REQUEST_ANIMATION_FRAME)
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (113612 => 113613)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-04-09 20:31:32 UTC (rev 113612)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-04-09 20:43:59 UTC (rev 113613)
@@ -80,6 +80,7 @@
namespace WebKit {
class AutocompletePopupMenuClient;
class AutofillPopupMenuClient;
+class BatteryClientImpl;
class ContextMenuClientImpl;
class DeviceOrientationClientProxy;
class DragScrollTimer;
@@ -256,6 +257,9 @@
virtual void performCustomContextMenuAction(unsigned action);
virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */);
virtual void removePageOverlay(WebPageOverlay*);
+#if ENABLE(BATTERY_STATUS)
+ virtual void updateBatteryStatus(const WebBatteryStatus&);
+#endif
virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&);
// WebLayerTreeViewClient
@@ -748,6 +752,9 @@
OwnPtr<WebGraphicsContext3D> m_temporaryOnscreenGraphicsContext3D;
OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
+#if ENABLE(BATTERY_STATUS)
+ OwnPtr<BatteryClientImpl> m_batteryClient;
+#endif
float m_emulatedTextZoomFactor;