[WK2] Add support for Battery Status API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2012 23:31:49 +0000 (23:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2012 23:31:49 +0000 (23:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89558

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-07-03
Reviewed by Anders Carlsson.

Add support for Battery Status API to WebKit2.

* CMakeLists.txt:
* DerivedSources.pri:
* GNUmakefile.am:
* GNUmakefile.list.am:
* Platform/CoreIPC/MessageID.h:
* Shared/API/c/WKBase.h:
* Shared/APIObject.h:
* Shared/WebBatteryStatus.cpp: Added.
(WebKit):
(WebKit::WebBatteryStatus::WebBatteryStatus):
(WebKit::WebBatteryStatus::~WebBatteryStatus):
(WebKit::WebBatteryStatus::Data::encode):
(WebKit::WebBatteryStatus::Data::decode):
* Shared/WebBatteryStatus.h: Added.
(WebKit):
(WebBatteryStatus):
(Data):
(WebKit::WebBatteryStatus::create):
(WebKit::WebBatteryStatus::isCharging):
(WebKit::WebBatteryStatus::chargingTime):
(WebKit::WebBatteryStatus::dischargingTime):
(WebKit::WebBatteryStatus::level):
(WebKit::WebBatteryStatus::data):
(WebKit::WebBatteryStatus::type):
* Target.pri:
* UIProcess/API/C/WKAPICast.h:
(WebKit):
* UIProcess/API/C/WKBatteryManager.cpp: Added.
(WKBatteryManagerGetTypeID):
* UIProcess/API/C/WKBatteryManager.h: Added.
* UIProcess/WebBatteryManagerProxy.cpp: Added.
(WebKit):
(WebKit::WebBatteryManagerProxy::create):
(WebKit::WebBatteryManagerProxy::WebBatteryManagerProxy):
(WebKit::WebBatteryManagerProxy::~WebBatteryManagerProxy):
(WebKit::WebBatteryManagerProxy::invalidate):
(WebKit::WebBatteryManagerProxy::initializeProvider):
(WebKit::WebBatteryManagerProxy::didReceiveMessage):
(WebKit::WebBatteryManagerProxy::startUpdating):
(WebKit::WebBatteryManagerProxy::stopUpdating):
(WebKit::WebBatteryManagerProxy::providerDidChangeBatteryStatus):
(WebKit::WebBatteryManagerProxy::providerUpdateBatteryStatus):
* UIProcess/WebBatteryManagerProxy.h: Added.
(CoreIPC):
(WebKit):
(WebBatteryManagerProxy):
(WebKit::WebBatteryManagerProxy::clearContext):
(WebKit::WebBatteryManagerProxy::type):
* UIProcess/WebBatteryManagerProxy.messages.in: Added.
* UIProcess/WebBatteryProvider.cpp: Added.
(WebKit):
(WebKit::WebBatteryProvider::startUpdating):
(WebKit::WebBatteryProvider::stopUpdating):
* UIProcess/WebBatteryProvider.h: Added.
(WebKit):
(WebBatteryProvider):
* WebKit2.pri:
* WebProcess/Battery/WebBatteryManager.cpp: Added.
(WebKit):
(WebKit::WebBatteryManager::WebBatteryManager):
(WebKit::WebBatteryManager::~WebBatteryManager):
(WebKit::WebBatteryManager::didReceiveMessage):
(WebKit::WebBatteryManager::registerWebPage):
(WebKit::WebBatteryManager::unregisterWebPage):
(WebKit::WebBatteryManager::didChangeBatteryStatus):
(WebKit::WebBatteryManager::updateBatteryStatus):
* WebProcess/Battery/WebBatteryManager.h: Added.
(CoreIPC):
(WebKit):
(WebBatteryManager):
* WebProcess/Battery/WebBatteryManager.messages.in: Added.
* WebProcess/WebCoreSupport/WebBatteryClient.cpp: Added.
(WebKit):
(WebKit::WebBatteryClient::startUpdating):
(WebKit::WebBatteryClient::stopUpdating):
(WebKit::WebBatteryClient::batteryControllerDestroyed):
* WebProcess/WebCoreSupport/WebBatteryClient.h: Added.
(WebKit):
(WebBatteryClient):
(WebKit::WebBatteryClient::WebBatteryClient):
(WebKit::WebBatteryClient::~WebBatteryClient):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::didReceiveMessage):
* WebProcess/WebProcess.h:
(WebProcess):
(WebKit::WebProcess::batteryManager):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121808 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.pri
Source/WebKit2/GNUmakefile.am
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Platform/CoreIPC/MessageID.h
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/Shared/APIObject.h
Source/WebKit2/Shared/WebBatteryStatus.cpp [new file with mode: 0644]
Source/WebKit2/Shared/WebBatteryStatus.h [new file with mode: 0644]
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKBatteryManager.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKBatteryManager.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebBatteryManagerProxy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebBatteryManagerProxy.messages.in [new file with mode: 0644]
Source/WebKit2/UIProcess/WebBatteryProvider.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebBatteryProvider.h [new file with mode: 0644]
Source/WebKit2/WebKit2.pri
Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/Battery/WebBatteryManager.h [new file with mode: 0644]
Source/WebKit2/WebProcess/Battery/WebBatteryManager.messages.in [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h

index f3959fd..00e9e54 100644 (file)
@@ -22,6 +22,7 @@ SET(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/WebProcess"
     "${WEBKIT2_DIR}/WebProcess/ApplicationCache"
     "${WEBKIT2_DIR}/WebProcess/Authentication"
+    "${WEBKIT2_DIR}/WebProcess/Battery"
     "${WEBKIT2_DIR}/WebProcess/Cookies"
     "${WEBKIT2_DIR}/WebProcess/Downloads"
     "${WEBKIT2_DIR}/WebProcess/FullScreen"
@@ -137,6 +138,7 @@ SET(WebKit2_SOURCES
     Shared/UpdateInfo.cpp
     Shared/VisitedLinkTable.cpp
     Shared/WebBackForwardListItem.cpp
+    Shared/WebBatteryStatus.cpp
     Shared/WebConnection.cpp
     Shared/WebConnectionClient.cpp
     Shared/WebContextMenuItem.cpp
@@ -214,6 +216,8 @@ SET(WebKit2_SOURCES
     UIProcess/VisitedLinkProvider.cpp
     UIProcess/WebApplicationCacheManagerProxy.cpp
     UIProcess/WebBackForwardList.cpp
+    UIProcess/WebBatteryManagerProxy.cpp
+    UIProcess/WebBatteryProvider.cpp
     UIProcess/WebConnectionToWebProcess.cpp
     UIProcess/WebContext.cpp
     UIProcess/WebContextConnectionClient.cpp
@@ -264,6 +268,7 @@ SET(WebKit2_SOURCES
     UIProcess/API/C/WKAuthenticationDecisionListener.cpp
     UIProcess/API/C/WKBackForwardList.cpp
     UIProcess/API/C/WKBackForwardListItem.cpp
+    UIProcess/API/C/WKBatteryManager.cpp
     UIProcess/API/C/WKContext.cpp
     UIProcess/API/C/WKCookieManager.cpp
     UIProcess/API/C/WKCredential.cpp
@@ -329,6 +334,8 @@ SET(WebKit2_SOURCES
 
     WebProcess/Authentication/AuthenticationManager.cpp
 
+    WebProcess/Battery/WebBatteryManager.cpp
+
     WebProcess/Cookies/WebCookieManager.cpp
 
     WebProcess/Downloads/Download.cpp
@@ -402,6 +409,7 @@ SET(WebKit2_SOURCES
 
     WebProcess/ResourceCache/WebResourceCacheManager.cpp
 
+    WebProcess/WebCoreSupport/WebBatteryClient.cpp
     WebProcess/WebCoreSupport/WebChromeClient.cpp
     WebProcess/WebCoreSupport/WebColorChooser.cpp
     WebProcess/WebCoreSupport/WebContextMenuClient.cpp
@@ -448,6 +456,7 @@ SET(WebKit2_MESSAGES_IN_FILES
     UIProcess/DrawingAreaProxy.messages.in
     UIProcess/LayerTreeCoordinatorProxy.messages.in
     UIProcess/WebApplicationCacheManagerProxy.messages.in
+    UIProcess/WebBatteryManagerProxy.messages.in
     UIProcess/WebContext.messages.in
     UIProcess/WebCookieManagerProxy.messages.in
     UIProcess/WebDatabaseManagerProxy.messages.in
@@ -473,6 +482,8 @@ SET(WebKit2_MESSAGES_IN_FILES
 
     WebProcess/Authentication/AuthenticationManager.messages.in
 
+    WebProcess/Battery/WebBatteryManager.messages.in
+
     WebProcess/Cookies/WebCookieManager.messages.in
 
     WebProcess/FullScreen/WebFullScreenManager.messages.in
index 8789c4c..0309ee1 100644 (file)
@@ -1,3 +1,100 @@
+2012-07-03  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2] Add support for Battery Status API
+        https://bugs.webkit.org/show_bug.cgi?id=89558
+
+        Reviewed by Anders Carlsson.
+
+        Add support for Battery Status API to WebKit2.
+
+        * CMakeLists.txt:
+        * DerivedSources.pri:
+        * GNUmakefile.am:
+        * GNUmakefile.list.am:
+        * Platform/CoreIPC/MessageID.h:
+        * Shared/API/c/WKBase.h:
+        * Shared/APIObject.h:
+        * Shared/WebBatteryStatus.cpp: Added.
+        (WebKit):
+        (WebKit::WebBatteryStatus::WebBatteryStatus):
+        (WebKit::WebBatteryStatus::~WebBatteryStatus):
+        (WebKit::WebBatteryStatus::Data::encode):
+        (WebKit::WebBatteryStatus::Data::decode):
+        * Shared/WebBatteryStatus.h: Added.
+        (WebKit):
+        (WebBatteryStatus):
+        (Data):
+        (WebKit::WebBatteryStatus::create):
+        (WebKit::WebBatteryStatus::isCharging):
+        (WebKit::WebBatteryStatus::chargingTime):
+        (WebKit::WebBatteryStatus::dischargingTime):
+        (WebKit::WebBatteryStatus::level):
+        (WebKit::WebBatteryStatus::data):
+        (WebKit::WebBatteryStatus::type):
+        * Target.pri:
+        * UIProcess/API/C/WKAPICast.h:
+        (WebKit):
+        * UIProcess/API/C/WKBatteryManager.cpp: Added.
+        (WKBatteryManagerGetTypeID):
+        * UIProcess/API/C/WKBatteryManager.h: Added.
+        * UIProcess/WebBatteryManagerProxy.cpp: Added.
+        (WebKit):
+        (WebKit::WebBatteryManagerProxy::create):
+        (WebKit::WebBatteryManagerProxy::WebBatteryManagerProxy):
+        (WebKit::WebBatteryManagerProxy::~WebBatteryManagerProxy):
+        (WebKit::WebBatteryManagerProxy::invalidate):
+        (WebKit::WebBatteryManagerProxy::initializeProvider):
+        (WebKit::WebBatteryManagerProxy::didReceiveMessage):
+        (WebKit::WebBatteryManagerProxy::startUpdating):
+        (WebKit::WebBatteryManagerProxy::stopUpdating):
+        (WebKit::WebBatteryManagerProxy::providerDidChangeBatteryStatus):
+        (WebKit::WebBatteryManagerProxy::providerUpdateBatteryStatus):
+        * UIProcess/WebBatteryManagerProxy.h: Added.
+        (CoreIPC):
+        (WebKit):
+        (WebBatteryManagerProxy):
+        (WebKit::WebBatteryManagerProxy::clearContext):
+        (WebKit::WebBatteryManagerProxy::type):
+        * UIProcess/WebBatteryManagerProxy.messages.in: Added.
+        * UIProcess/WebBatteryProvider.cpp: Added.
+        (WebKit):
+        (WebKit::WebBatteryProvider::startUpdating):
+        (WebKit::WebBatteryProvider::stopUpdating):
+        * UIProcess/WebBatteryProvider.h: Added.
+        (WebKit):
+        (WebBatteryProvider):
+        * WebKit2.pri:
+        * WebProcess/Battery/WebBatteryManager.cpp: Added.
+        (WebKit):
+        (WebKit::WebBatteryManager::WebBatteryManager):
+        (WebKit::WebBatteryManager::~WebBatteryManager):
+        (WebKit::WebBatteryManager::didReceiveMessage):
+        (WebKit::WebBatteryManager::registerWebPage):
+        (WebKit::WebBatteryManager::unregisterWebPage):
+        (WebKit::WebBatteryManager::didChangeBatteryStatus):
+        (WebKit::WebBatteryManager::updateBatteryStatus):
+        * WebProcess/Battery/WebBatteryManager.h: Added.
+        (CoreIPC):
+        (WebKit):
+        (WebBatteryManager):
+        * WebProcess/Battery/WebBatteryManager.messages.in: Added.
+        * WebProcess/WebCoreSupport/WebBatteryClient.cpp: Added.
+        (WebKit):
+        (WebKit::WebBatteryClient::startUpdating):
+        (WebKit::WebBatteryClient::stopUpdating):
+        (WebKit::WebBatteryClient::batteryControllerDestroyed):
+        * WebProcess/WebCoreSupport/WebBatteryClient.h: Added.
+        (WebKit):
+        (WebBatteryClient):
+        (WebKit::WebBatteryClient::WebBatteryClient):
+        (WebKit::WebBatteryClient::~WebBatteryClient):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        (WebKit::WebProcess::didReceiveMessage):
+        * WebProcess/WebProcess.h:
+        (WebProcess):
+        (WebKit::WebProcess::batteryManager):
+
 2012-07-03  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         [Qt] Make use of .qmake.cache for caching features
index ab42707..9bc016d 100644 (file)
@@ -38,6 +38,7 @@ VPATH = \
     PluginProcess \
     WebProcess/ApplicationCache \
     WebProcess/Authentication \
+    WebProcess/Battery \
     WebProcess/Cookies \
     WebProcess/FullScreen \
     WebProcess/Geolocation \
@@ -69,6 +70,8 @@ MESSAGE_RECEIVERS = \
     PluginProxy.messages.in \
     WebApplicationCacheManager.messages.in \
     WebApplicationCacheManagerProxy.messages.in \
+    WebBatteryManager.messages.in \
+    WebBatteryManagerProxy.messages.in \
     WebContext.messages.in \
     WebCookieManager.messages.in \
     WebCookieManagerProxy.messages.in \
index 15a69f9..1682305 100644 (file)
@@ -59,6 +59,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_CPP
        -I$(srcdir)/Source/WebKit2/WebProcess \
        -I$(srcdir)/Source/WebKit2/WebProcess/ApplicationCache \
        -I$(srcdir)/Source/WebKit2/WebProcess/Authentication \
+       -I$(srcdir)/Source/WebKit2/WebProcess/Battery \
        -I$(srcdir)/Source/WebKit2/WebProcess/Cookies \
        -I$(srcdir)/Source/WebKit2/WebProcess/Downloads \
        -I$(srcdir)/Source/WebKit2/WebProcess/FullScreen \
@@ -211,6 +212,7 @@ vpath %.messages.in = \
        $(WebKit2)/WebProcess \
        $(WebKit2)/WebProcess/ApplicationCache \
        $(WebKit2)/WebProcess/Authentication \
+       $(WebKit2)/WebProcess/Battery \
        $(WebKit2)/WebProcess/Cookies \
        $(WebKit2)/WebProcess/FullScreen \
        $(WebKit2)/WebProcess/Geolocation \
@@ -513,6 +515,7 @@ EXTRA_DIST += \
        $(shell ls $(WebKit2)/WebProcess/*.in) \
        $(shell ls $(WebKit2)/WebProcess/ApplicationCache/*.in) \
        $(shell ls $(WebKit2)/WebProcess/Authentication/*.in) \
+       $(shell ls $(WebKit2)/WebProcess/Battery/*.in) \
        $(shell ls $(WebKit2)/WebProcess/Cookies/*.in) \
        $(shell ls $(WebKit2)/WebProcess/FullScreen/*.in) \
        $(shell ls $(WebKit2)/WebProcess/Geolocation/*.in) \
index 6e77d72..0f20190 100644 (file)
@@ -47,6 +47,7 @@ webkit2_h_api += \
        $(WebKit2)/UIProcess/API/C/WKAuthenticationDecisionListener.h \
        $(WebKit2)/UIProcess/API/C/WKBackForwardList.h \
        $(WebKit2)/UIProcess/API/C/WKBackForwardListItem.h \
+       $(WebKit2)/UIProcess/API/C/WKBatteryManager.h \
        $(WebKit2)/UIProcess/API/C/WKContext.h \
        $(WebKit2)/UIProcess/API/C/WKContextPrivate.h \
        $(WebKit2)/UIProcess/API/C/WKCookieManager.h \
@@ -152,6 +153,10 @@ webkit2_built_sources += \
        DerivedSources/WebKit2/WebApplicationCacheManagerMessages.h \
        DerivedSources/WebKit2/WebApplicationCacheManagerProxyMessageReceiver.cpp \
        DerivedSources/WebKit2/WebApplicationCacheManagerProxyMessages.h \
+       DerivedSources/WebKit2/WebBatteryManagerMessageReceiver.cpp \
+       DerivedSources/WebKit2/WebBatteryManagerMessages.h \
+       DerivedSources/WebKit2/WebBatteryManagerProxyMessageReceiver.cpp \
+       DerivedSources/WebKit2/WebBatteryManagerProxyMessages.h \
        DerivedSources/WebKit2/WebContextMessageReceiver.cpp \
        DerivedSources/WebKit2/WebContextMessages.h \
        DerivedSources/WebKit2/WebCookieManagerMessageReceiver.cpp \
@@ -421,6 +426,8 @@ webkit2_sources += \
        Source/WebKit2/Shared/VisitedLinkTable.h \
        Source/WebKit2/Shared/WebBackForwardListItem.cpp \
        Source/WebKit2/Shared/WebBackForwardListItem.h \
+       Source/WebKit2/Shared/WebBatteryStatus.cpp \
+       Source/WebKit2/Shared/WebBatteryStatus.h \
        Source/WebKit2/Shared/WebCertificateInfo.h \
        Source/WebKit2/Shared/WebConnection.cpp \
        Source/WebKit2/Shared/WebConnection.h \
@@ -505,6 +512,8 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/API/C/WKBackForwardList.h \
        Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp \
        Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h \
+       Source/WebKit2/UIProcess/API/C/WKBatteryManager.cpp \
+       Source/WebKit2/UIProcess/API/C/WKBatteryManager.h \
        Source/WebKit2/UIProcess/API/C/WKContext.cpp \
        Source/WebKit2/UIProcess/API/C/WKContext.h \
        Source/WebKit2/UIProcess/API/C/WKContextPrivate.h \
@@ -774,6 +783,10 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp \
        Source/WebKit2/UIProcess/WebBackForwardList.cpp \
        Source/WebKit2/UIProcess/WebBackForwardList.h \
+       Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp \
+       Source/WebKit2/UIProcess/WebBatteryManagerProxy.h \
+       Source/WebKit2/UIProcess/WebBatteryProvider.cpp \
+       Source/WebKit2/UIProcess/WebBatteryProvider.h \
        Source/WebKit2/UIProcess/WebColorChooserProxy.h \
        Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp \
        Source/WebKit2/UIProcess/WebConnectionToWebProcess.h \
@@ -868,6 +881,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp \
        Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp \
        Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h \
+       Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp \
+       Source/WebKit2/WebProcess/Battery/WebBatteryManager.h \
        Source/WebKit2/WebProcess/Cookies/WebCookieManager.h \
        Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp \
        Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp \
@@ -1016,6 +1031,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h \
+       Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp \
+       Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebColorChooser.cpp \
index d923a1b..3638138 100644 (file)
@@ -40,6 +40,7 @@ enum MessageClass {
     MessageClassInjectedBundle,
     MessageClassLayerTreeCoordinator,
     MessageClassWebApplicationCacheManager,
+    MessageClassWebBatteryManagerProxy,
     MessageClassWebCookieManager,
     MessageClassWebDatabaseManager,
     MessageClassWebFullScreenManager,
@@ -62,6 +63,7 @@ enum MessageClass {
     MessageClassDrawingAreaProxy,
     MessageClassLayerTreeCoordinatorProxy,
     MessageClassWebApplicationCacheManagerProxy,
+    MessageClassWebBatteryManager,
     MessageClassWebContext,
     MessageClassWebContextLegacy,
     MessageClassWebCookieManagerProxy,
index 8b7e81f..36e2ddd 100644 (file)
@@ -86,6 +86,8 @@ typedef const struct OpaqueWKAuthenticationChallenge* WKAuthenticationChallengeR
 typedef const struct OpaqueWKAuthenticationDecisionListener* WKAuthenticationDecisionListenerRef;
 typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef;
 typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef;
+typedef const struct OpaqueWKBatteryManager* WKBatteryManagerRef;
+typedef const struct OpaqueWKBatteryStatus* WKBatteryStatusRef;
 typedef const struct OpaqueWKResourceCacheManager* WKResourceCacheManagerRef;
 typedef const struct OpaqueWKContext* WKContextRef;
 typedef const struct OpaqueWKCookieManager* WKCookieManagerRef;
index ead74f0..830fee8 100644 (file)
@@ -72,6 +72,8 @@ public:
         TypeApplicationCacheManager,
         TypeBackForwardList,
         TypeBackForwardListItem,
+        TypeBatteryManager,
+        TypeBatteryStatus,
         TypeCacheManager,
         TypeContext,
         TypeCookieManager,
diff --git a/Source/WebKit2/Shared/WebBatteryStatus.cpp b/Source/WebKit2/Shared/WebBatteryStatus.cpp
new file mode 100644 (file)
index 0000000..c8d806d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+ */
+
+#include "config.h"
+#include "WebBatteryStatus.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "ArgumentCoders.h"
+#include "Arguments.h"
+
+namespace WebKit {
+
+WebBatteryStatus::WebBatteryStatus(bool isCharging, double chargingTime, double dischargingTime, double level)
+{
+    m_data.isCharging = isCharging;
+    m_data.chargingTime = chargingTime;
+    m_data.dischargingTime = dischargingTime;
+    m_data.level = level;
+}
+
+WebBatteryStatus::~WebBatteryStatus()
+{
+}
+
+void WebBatteryStatus::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(CoreIPC::In(isCharging, chargingTime, dischargingTime, level));
+}
+
+bool WebBatteryStatus::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& data)
+{
+    return decoder->decode(CoreIPC::Out(data.isCharging, data.chargingTime, data.dischargingTime, data.level));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
diff --git a/Source/WebKit2/Shared/WebBatteryStatus.h b/Source/WebKit2/Shared/WebBatteryStatus.h
new file mode 100644 (file)
index 0000000..fd1d793
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "APIObject.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class WebBatteryStatus : public APIObject {
+public:
+    static const Type APIType = TypeBatteryStatus;
+
+    struct Data {
+        void encode(CoreIPC::ArgumentEncoder*) const;
+        static bool decode(CoreIPC::ArgumentDecoder*, Data&);
+
+        bool isCharging;
+        double chargingTime;
+        double dischargingTime;
+        double level;
+    };
+
+    static PassRefPtr<WebBatteryStatus> create(bool isCharging, double chargingTime, double dischargingTime, double level)
+    {
+        return adoptRef(new WebBatteryStatus(isCharging, chargingTime, dischargingTime, level));
+    }
+
+    virtual ~WebBatteryStatus();
+    double isCharging() const { return m_data.isCharging; }
+    double chargingTime() const { return m_data.chargingTime; }
+    double dischargingTime() const { return m_data.dischargingTime; }
+    double level() const { return m_data.level; }
+
+    const Data& data() const { return m_data; }
+
+private:
+    WebBatteryStatus(bool isCharging, double chargingTime, double dischargingTime, double level);
+
+    virtual Type type() const { return APIType; }
+
+    Data m_data;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // WebBatteryStatus_h
index 6c2dcb5..ee41947 100644 (file)
@@ -97,6 +97,7 @@ HEADERS += \
     Shared/VisitedLinkTable.h \
     Shared/WebCoreArgumentCoders.h \
     Shared/WebBackForwardListItem.h \
+    Shared/WebBatteryStatus.h \
     Shared/WebCertificateInfo.h \
     Shared/WebConnection.h \
     Shared/WebConnectionClient.h \
@@ -145,6 +146,7 @@ HEADERS += \
     UIProcess/API/C/WKAuthenticationDecisionListener.h \
     UIProcess/API/C/WKBackForwardList.h \
     UIProcess/API/C/WKBackForwardListItem.h \
+    UIProcess/API/C/WKBatteryManager.h \
     UIProcess/API/C/WKContext.h \
     UIProcess/API/C/WKContextPrivate.h \
     UIProcess/API/C/WKCredential.h \
@@ -231,6 +233,8 @@ HEADERS += \
     UIProcess/VisitedLinkProvider.h \
     UIProcess/WebApplicationCacheManagerProxy.h \
     UIProcess/WebBackForwardList.h \
+    UIProcess/WebBatteryManagerProxy.h \
+    UIProcess/WebBatteryProvider.h \
     UIProcess/WebColorChooserProxy.h \
     UIProcess/WebConnectionToWebProcess.h \
     UIProcess/WebContext.h \
@@ -297,6 +301,7 @@ HEADERS += \
     UIProcess/texmap/LayerBackingStore.h \
     WebProcess/ApplicationCache/WebApplicationCacheManager.h \
     WebProcess/Authentication/AuthenticationManager.h \
+    WebProcess/Battery/WebBatteryManager.h \
     WebProcess/Cookies/WebCookieManager.h \
     WebProcess/Downloads/Download.h \
     WebProcess/Downloads/DownloadManager.h \
@@ -347,6 +352,7 @@ HEADERS += \
     WebProcess/Plugins/PluginProxy.h \
     WebProcess/Plugins/PluginProcessConnection.h \
     WebProcess/Plugins/PluginProcessConnectionManager.h \
+    WebProcess/WebCoreSupport/WebBatteryClient.h \
     WebProcess/WebCoreSupport/WebChromeClient.h \
     WebProcess/WebCoreSupport/WebColorChooser.h \
     WebProcess/WebCoreSupport/WebContextMenuClient.h \
@@ -462,6 +468,7 @@ SOURCES += \
     Shared/UpdateInfo.cpp \
     Shared/VisitedLinkTable.cpp \
     Shared/WebBackForwardListItem.cpp \
+    Shared/WebBatteryStatus.cpp \
     Shared/WebConnection.cpp \
     Shared/WebConnectionClient.cpp \
     Shared/WebContextMenuItem.cpp \
@@ -509,6 +516,7 @@ SOURCES += \
     UIProcess/API/C/WKAuthenticationDecisionListener.cpp \
     UIProcess/API/C/WKBackForwardList.cpp \
     UIProcess/API/C/WKBackForwardListItem.cpp \
+    UIProcess/API/C/WKBatteryManager.cpp \
     UIProcess/API/C/WKContext.cpp \
     UIProcess/API/C/WKCredential.cpp \
     UIProcess/API/C/WKDatabaseManager.cpp \
@@ -585,6 +593,8 @@ SOURCES += \
     UIProcess/VisitedLinkProvider.cpp \
     UIProcess/WebApplicationCacheManagerProxy.cpp \
     UIProcess/WebBackForwardList.cpp \
+    UIProcess/WebBatteryManagerProxy.cpp \
+    UIProcess/WebBatteryProvider.cpp \
     UIProcess/WebConnectionToWebProcess.cpp \
     UIProcess/WebContext.cpp \
     UIProcess/WebContextConnectionClient.cpp \
@@ -654,6 +664,7 @@ SOURCES += \
     UIProcess/texmap/LayerBackingStore.cpp \
     WebProcess/ApplicationCache/WebApplicationCacheManager.cpp \
     WebProcess/Authentication/AuthenticationManager.cpp \
+    WebProcess/Battery/WebBatteryManager.cpp \
     WebProcess/Cookies/WebCookieManager.cpp \
     WebProcess/Cookies/qt/WebCookieManagerQt.cpp \
     WebProcess/Downloads/Download.cpp \
@@ -717,6 +728,7 @@ SOURCES += \
     WebProcess/Plugins/PluginProxy.cpp \
     WebProcess/Plugins/PluginProcessConnection.cpp \
     WebProcess/Plugins/PluginProcessConnectionManager.cpp \
+    WebProcess/WebCoreSupport/WebBatteryClient.cpp \
     WebProcess/WebCoreSupport/WebChromeClient.cpp \
     WebProcess/WebCoreSupport/WebColorChooser.cpp \
     WebProcess/WebCoreSupport/WebContextMenuClient.cpp \
index 816f8f1..1ece9e6 100644 (file)
@@ -56,6 +56,8 @@ class NotificationPermissionRequest;
 class WebApplicationCacheManagerProxy;
 class WebBackForwardList;
 class WebBackForwardListItem;
+class WebBatteryManagerProxy;
+class WebBatteryStatus;
 class WebResourceCacheManagerProxy;
 class WebContext;
 class WebCookieManagerProxy;
@@ -94,6 +96,8 @@ WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
 WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener)
 WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
 WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
+WK_ADD_API_MAPPING(WKBatteryManagerRef, WebBatteryManagerProxy)
+WK_ADD_API_MAPPING(WKBatteryStatusRef, WebBatteryStatus)
 WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy)
 WK_ADD_API_MAPPING(WKContextRef, WebContext)
 WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
diff --git a/Source/WebKit2/UIProcess/API/C/WKBatteryManager.cpp b/Source/WebKit2/UIProcess/API/C/WKBatteryManager.cpp
new file mode 100644 (file)
index 0000000..b7fd503
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+ */
+
+#include "config.h"
+#include "WKBatteryManager.h"
+
+#include "WKAPICast.h"
+
+#if ENABLE(BATTERY_STATUS)
+#include "WebBatteryManagerProxy.h"
+#endif
+
+using namespace WebKit;
+
+WKTypeID WKBatteryManagerGetTypeID()
+{
+#if ENABLE(BATTERY_STATUS)
+    return toAPI(WebBatteryManagerProxy::APIType);
+#else
+    return 0;
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKBatteryManager.h b/Source/WebKit2/UIProcess/API/C/WKBatteryManager.h
new file mode 100644 (file)
index 0000000..91e27f9
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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 WKBatteryManager_h
+#define WKBatteryManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Provider.
+typedef void (*WKBatteryProviderStartUpdatingCallback)(WKBatteryManagerRef batteryManager, const void* clientInfo);
+typedef void (*WKBatteryProviderStopUpdatingCallback)(WKBatteryManagerRef batteryManager, const void* clientInfo);
+
+struct WKBatteryProvider {
+    int                                                                 version;
+    const void *                                                        clientInfo;
+    WKBatteryProviderStartUpdatingCallback                              startUpdating;
+    WKBatteryProviderStopUpdatingCallback                               stopUpdating;
+};
+typedef struct WKBatteryProvider WKBatteryProvider;
+
+enum { kWKBatteryProviderCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKBatteryManagerGetTypeID();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKBatteryManager_h */
diff --git a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp
new file mode 100644 (file)
index 0000000..c3897e8
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+ */
+
+#include "config.h"
+#include "WebBatteryManagerProxy.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "WebBatteryManagerMessages.h"
+#include "WebContext.h"
+
+namespace WebKit {
+
+PassRefPtr<WebBatteryManagerProxy> WebBatteryManagerProxy::create(WebContext* context)
+{
+    return adoptRef(new WebBatteryManagerProxy(context));
+}
+
+WebBatteryManagerProxy::WebBatteryManagerProxy(WebContext* context)
+    : m_isUpdating(false)
+    , m_context(context)
+{
+}
+
+WebBatteryManagerProxy::~WebBatteryManagerProxy()
+{
+}
+
+void WebBatteryManagerProxy::invalidate()
+{
+    stopUpdating();
+}
+
+void WebBatteryManagerProxy::initializeProvider(const WKBatteryProvider* provider)
+{
+    m_provider.initialize(provider);
+}
+
+void WebBatteryManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+    didReceiveWebBatteryManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebBatteryManagerProxy::startUpdating()
+{
+    if (m_isUpdating)
+        return;
+
+    m_provider.startUpdating(this);
+    m_isUpdating = true;
+}
+
+void WebBatteryManagerProxy::stopUpdating()
+{
+    if (!m_isUpdating)
+        return;
+
+    m_provider.stopUpdating(this);
+    m_isUpdating = false;
+}
+
+void WebBatteryManagerProxy::providerDidChangeBatteryStatus(const WTF::AtomicString& eventType, WebBatteryStatus* status)
+{
+    if (!m_context)
+        return;
+
+    m_context->sendToAllProcesses(Messages::WebBatteryManager::DidChangeBatteryStatus(eventType, status->data()));
+}
+
+void WebBatteryManagerProxy::providerUpdateBatteryStatus(WebBatteryStatus* status)
+{
+    if (!m_context)
+        return;
+
+    m_context->sendToAllProcesses(Messages::WebBatteryManager::UpdateBatteryStatus(status->data()));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
diff --git a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.h b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.h
new file mode 100644 (file)
index 0000000..9fa5bdc
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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 WebBatteryManagerProxy_h
+#define WebBatteryManagerProxy_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "APIObject.h"
+#include "MessageID.h"
+#include "WebBatteryProvider.h"
+#include <wtf/Forward.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebBatteryStatus;
+
+class WebBatteryManagerProxy : public APIObject {
+public:
+    static const Type APIType = TypeBatteryManager;
+
+    static PassRefPtr<WebBatteryManagerProxy> create(WebContext*);
+    virtual ~WebBatteryManagerProxy();
+
+    void invalidate();
+    void clearContext() { m_context = 0; }
+
+    void initializeProvider(const WKBatteryProvider*);
+
+    void providerDidChangeBatteryStatus(const WTF::AtomicString&, WebBatteryStatus*);
+    void providerUpdateBatteryStatus(WebBatteryStatus*);
+
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+private:
+    explicit WebBatteryManagerProxy(WebContext*);
+
+    virtual Type type() const { return APIType; }
+
+    // Implemented in generated WebBatteryManagerProxyMessageReceiver.cpp
+    void didReceiveWebBatteryManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+    void startUpdating();
+    void stopUpdating();
+
+    bool m_isUpdating;
+
+    WebContext* m_context;
+    WebBatteryProvider m_provider;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // WebBatteryManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.messages.in
new file mode 100644 (file)
index 0000000..3faefa1
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+
+#if ENABLE(BATTERY_STATUS)
+
+messages -> WebBatteryManagerProxy {
+    StartUpdating();
+    StopUpdating();
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/WebBatteryProvider.cpp b/Source/WebKit2/UIProcess/WebBatteryProvider.cpp
new file mode 100644 (file)
index 0000000..8284160
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+ */
+
+#include "config.h"
+#include "WebBatteryProvider.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "WKAPICast.h"
+#include "WebBatteryManagerProxy.h"
+
+namespace WebKit {
+
+void WebBatteryProvider::startUpdating(WebBatteryManagerProxy* batteryManager)
+{
+    if (!m_client.startUpdating)
+        return;
+
+    m_client.startUpdating(toAPI(batteryManager), m_client.clientInfo);
+}
+
+void WebBatteryProvider::stopUpdating(WebBatteryManagerProxy* batteryManager)
+{
+    if (!m_client.stopUpdating)
+        return;
+
+    m_client.stopUpdating(toAPI(batteryManager), m_client.clientInfo);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
diff --git a/Source/WebKit2/UIProcess/WebBatteryProvider.h b/Source/WebKit2/UIProcess/WebBatteryProvider.h
new file mode 100644 (file)
index 0000000..f599068
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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 WebBatteryProvider_h
+#define WebBatteryProvider_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "APIClient.h"
+#include "WKBatteryManager.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebBatteryManagerProxy;
+
+class WebBatteryProvider : public APIClient<WKBatteryProvider, kWKBatteryProviderCurrentVersion> {
+public:
+    void startUpdating(WebBatteryManagerProxy*);
+    void stopUpdating(WebBatteryManagerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // WebBatteryProvider_h
index 7573452..fd3d2f2 100644 (file)
@@ -37,6 +37,7 @@ INCLUDEPATH += \
     $$SOURCE_DIR/WebProcess \
     $$SOURCE_DIR/WebProcess/ApplicationCache \
     $$SOURCE_DIR/WebProcess/Authentication \
+    $$SOURCE_DIR/WebProcess/Battery \
     $$SOURCE_DIR/WebProcess/Cookies \
     $$SOURCE_DIR/WebProcess/Cookies/qt \
     $$SOURCE_DIR/WebProcess/Downloads \
diff --git a/Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp b/Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp
new file mode 100644 (file)
index 0000000..04dec86
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+ */
+
+#include "config.h"
+#include "WebBatteryManager.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "WebBatteryManagerProxyMessages.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <WebCore/BatteryController.h>
+#include <WebCore/BatteryStatus.h>
+#include <WebCore/Page.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebBatteryManager::WebBatteryManager(WebProcess* process)
+    : m_process(process)
+{
+}
+
+WebBatteryManager::~WebBatteryManager()
+{
+}
+
+void WebBatteryManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+    didReceiveWebBatteryManagerMessage(connection, messageID, arguments);
+}
+
+void WebBatteryManager::registerWebPage(WebPage* page)
+{
+    bool wasEmpty = m_pageSet.isEmpty();
+
+    m_pageSet.add(page);
+
+    if (wasEmpty)
+        m_process->connection()->send(Messages::WebBatteryManagerProxy::StartUpdating(), 0);
+}
+
+void WebBatteryManager::unregisterWebPage(WebPage* page)
+{
+    m_pageSet.remove(page);
+
+    if (m_pageSet.isEmpty())
+        m_process->connection()->send(Messages::WebBatteryManagerProxy::StopUpdating(), 0);
+}
+
+void WebBatteryManager::didChangeBatteryStatus(const WTF::AtomicString& eventType, const WebBatteryStatus::Data& data)
+{
+    RefPtr<BatteryStatus> status = BatteryStatus::create(data.isCharging, data.chargingTime, data.dischargingTime, data.level);
+
+    HashSet<WebPage*>::const_iterator it = m_pageSet.begin();
+    HashSet<WebPage*>::const_iterator end = m_pageSet.end();
+    for (; it != end; ++it) {
+        WebPage* page = *it;
+        if (page->corePage())
+            BatteryController::from(page->corePage())->didChangeBatteryStatus(eventType, status.get());
+    }
+}
+
+void WebBatteryManager::updateBatteryStatus(const WebBatteryStatus::Data& data)
+{
+    RefPtr<BatteryStatus> status = BatteryStatus::create(data.isCharging, data.chargingTime, data.dischargingTime, data.level);
+
+    HashSet<WebPage*>::const_iterator it = m_pageSet.begin();
+    HashSet<WebPage*>::const_iterator end = m_pageSet.end();
+    for (; it != end; ++it) {
+        WebPage* page = *it;
+        if (page->corePage())
+            BatteryController::from(page->corePage())->updateBatteryStatus(status.get());
+    }
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
diff --git a/Source/WebKit2/WebProcess/Battery/WebBatteryManager.h b/Source/WebKit2/WebProcess/Battery/WebBatteryManager.h
new file mode 100644 (file)
index 0000000..509718d
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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 WebBatteryManager_h
+#define WebBatteryManager_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "MessageID.h"
+#include "WebBatteryStatus.h"
+#include "WebCoreArgumentCoders.h"
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/text/AtomicString.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+}
+
+namespace WebKit {
+
+class WebPage;
+class WebProcess;
+
+class WebBatteryManager {
+    WTF_MAKE_NONCOPYABLE(WebBatteryManager);
+
+public:
+    explicit WebBatteryManager(WebProcess*);
+    ~WebBatteryManager();
+
+    void registerWebPage(WebPage*);
+    void unregisterWebPage(WebPage*);
+
+    void didChangeBatteryStatus(const WTF::AtomicString& eventType, const WebBatteryStatus::Data&);
+    void updateBatteryStatus(const WebBatteryStatus::Data&);
+
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+private:
+    // Implemented in generated WebBatteryManagerMessageReceiver.cpp
+    void didReceiveWebBatteryManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+    WebProcess* m_process;
+    HashSet<WebPage*> m_pageSet;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // WebBatteryManager_h
diff --git a/Source/WebKit2/WebProcess/Battery/WebBatteryManager.messages.in b/Source/WebKit2/WebProcess/Battery/WebBatteryManager.messages.in
new file mode 100644 (file)
index 0000000..37e73ef
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+
+#if ENABLE(BATTERY_STATUS)
+
+messages -> WebBatteryManager {
+    DidChangeBatteryStatus(AtomicString eventType, WebKit::WebBatteryStatus::Data status);
+    UpdateBatteryStatus(WebKit::WebBatteryStatus::Data status);
+}
+
+#endif
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp
new file mode 100644 (file)
index 0000000..91033fa
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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.
+ */
+
+#include "config.h"
+#include "WebBatteryClient.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "WebBatteryManager.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebBatteryClient::startUpdating()
+{
+    WebProcess::shared().batteryManager().registerWebPage(m_page);
+}
+
+void WebBatteryClient::stopUpdating()
+{
+    WebProcess::shared().batteryManager().unregisterWebPage(m_page);
+}
+
+void WebBatteryClient::batteryControllerDestroyed()
+{
+    WebProcess::shared().batteryManager().unregisterWebPage(m_page);
+    delete this;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h
new file mode 100644 (file)
index 0000000..b260c62
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 INC. 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 INC. 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 WebBatteryClient_h
+#define WebBatteryClient_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include <WebCore/BatteryClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebBatteryClient : public WebCore::BatteryClient {
+public:
+    WebBatteryClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+
+    virtual ~WebBatteryClient() { }
+
+private:
+    virtual void startUpdating() OVERRIDE;
+    virtual void stopUpdating() OVERRIDE;
+    virtual void batteryControllerDestroyed() OVERRIDE;
+
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // WebBatteryClient_h
index 9f29aef..d2f7b54 100644 (file)
@@ -145,6 +145,9 @@ WebProcess::WebProcess()
 #endif
     , m_textCheckerState()
     , m_geolocationManager(this)
+#if ENABLE(BATTERY_STATUS)
+    , m_batteryManager(this)
+#endif
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     , m_notificationManager(this)
 #endif
@@ -633,6 +636,13 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
         return;
     }
 
+#if ENABLE(BATTERY_STATUS)
+    if (messageID.is<CoreIPC::MessageClassWebBatteryManager>()) {
+        m_batteryManager.didReceiveMessage(connection, messageID, arguments);
+        return;
+    }
+#endif
+
     if (messageID.is<CoreIPC::MessageClassWebIconDatabaseProxy>()) {
         m_iconDatabaseProxy.didReceiveMessage(connection, messageID, arguments);
         return;
index 986ce36..cc0a7f9 100644 (file)
@@ -57,6 +57,10 @@ class QNetworkAccessManager;
 #include <dispatch/dispatch.h>
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+#include "WebBatteryManager.h"
+#endif
+
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
 #include "WebNotificationManager.h"
 #endif
@@ -142,6 +146,10 @@ public:
 
     // Geolocation
     WebGeolocationManager& geolocationManager() { return m_geolocationManager; }
+
+#if ENABLE(BATTERY_STATUS)
+    WebBatteryManager& batteryManager() { return m_batteryManager; }
+#endif
     
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     WebNotificationManager& notificationManager() { return m_notificationManager; }
@@ -286,6 +294,9 @@ private:
 
     TextCheckerState m_textCheckerState;
     WebGeolocationManager m_geolocationManager;
+#if ENABLE(BATTERY_STATUS)
+    WebBatteryManager m_batteryManager;
+#endif
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     WebNotificationManager m_notificationManager;
 #endif