Title: [113547] trunk
Revision
113547
Author
[email protected]
Date
2012-04-07 08:30:43 -0700 (Sat, 07 Apr 2012)

Log Message

[BlackBerry] Add Battery Status API support
https://bugs.webkit.org/show_bug.cgi?id=82615

Reviewed by George Staikos.

.:

Enable BATTERY_STATUS.

* Source/cmake/OptionsBlackBerry.cmake:

Source/WebKit:

Add BatteryClientBlackBerry.cpp to the build.

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

Add client implementation for Battery API.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::init):  initialize BatteryClient.
* WebCoreSupport/BatteryClientBlackBerry.cpp: Added.
(WebCore):
(WebCore::BatteryClientBlackBerry::BatteryClientBlackBerry):
(WebCore::BatteryClientBlackBerry::setController):
(WebCore::BatteryClientBlackBerry::startUpdating):
(WebCore::BatteryClientBlackBerry::stopUpdating):
(WebCore::BatteryClientBlackBerry::batteryControllerDestroyed):
(WebCore::BatteryClientBlackBerry::onLevelChange):
(WebCore::BatteryClientBlackBerry::onChargingChange):
(WebCore::BatteryClientBlackBerry::onChargingTimeChange):
(WebCore::BatteryClientBlackBerry::onDischargingTimeChange):
* WebCoreSupport/BatteryClientBlackBerry.h: Added.
(WebCore):
(BatteryClientBlackBerry):
(WebCore::BatteryClientBlackBerry::~BatteryClientBlackBerry):

Tools:

Enable BATTERY_STATUS.

* Scripts/build-webkit:

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (113546 => 113547)


--- trunk/ChangeLog	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/ChangeLog	2012-04-07 15:30:43 UTC (rev 113547)
@@ -1,3 +1,14 @@
+2012-04-07  Rob Buis  <[email protected]>
+
+        [BlackBerry] Add Battery Status API support
+        https://bugs.webkit.org/show_bug.cgi?id=82615
+
+        Reviewed by George Staikos.
+
+        Enable BATTERY_STATUS.
+
+        * Source/cmake/OptionsBlackBerry.cmake:
+
 2012-04-06  Martin Robinson  <[email protected]>
 
         Fix the GTK+ debug build.

Modified: trunk/Source/WebKit/ChangeLog (113546 => 113547)


--- trunk/Source/WebKit/ChangeLog	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Source/WebKit/ChangeLog	2012-04-07 15:30:43 UTC (rev 113547)
@@ -1,3 +1,14 @@
+2012-04-07  Rob Buis  <[email protected]>
+
+        [BlackBerry] Add Battery Status API support
+        https://bugs.webkit.org/show_bug.cgi?id=82615
+
+        Reviewed by George Staikos.
+
+        Add BatteryClientBlackBerry.cpp to the build.
+
+        * PlatformBlackBerry.cmake:
+
 2012-04-06  Charles Wei  <[email protected]>
 
         [BlackBerry] Build fix to match the latest WebCore change

Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (113546 => 113547)


--- trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-04-07 15:30:43 UTC (rev 113547)
@@ -37,6 +37,11 @@
     )
 ENDIF ()
 
+IF (ENABLE_BATTERY_STATUS)
+    LIST(APPEND WebKit_INCLUDE_DIRECTORIES ${WEBCORE_DIR}/Modules/battery)
+    LIST(APPEND WebKit_SOURCES blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp)
+ENDIF ()
+
 ADD_DEFINITIONS(-DUSER_PROCESSES)
 
 LIST(APPEND WebKit_SOURCES

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (113546 => 113547)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-04-07 15:30:43 UTC (rev 113547)
@@ -25,6 +25,9 @@
 #include "BackingStoreClient.h"
 #include "BackingStoreCompositingSurface.h"
 #include "BackingStore_p.h"
+#if ENABLE(BATTERY_STATUS)
+#include "BatteryClientBlackBerry.h"
+#endif
 #include "CString.h"
 #include "CachedImage.h"
 #include "Chrome.h"
@@ -450,6 +453,10 @@
     WebCore::provideVibrationTo(m_page, new VibrationClientBlackBerry());
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+    WebCore::provideBatteryTo(m_page, new WebCore::BatteryClientBlackBerry);
+#endif
+
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     WebCore::provideNotification(m_page, NotificationPresenterImpl::instance());
 #endif

Modified: trunk/Source/WebKit/blackberry/ChangeLog (113546 => 113547)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-04-07 15:30:43 UTC (rev 113547)
@@ -1,3 +1,30 @@
+2012-04-07  Rob Buis  <[email protected]>
+
+        [BlackBerry] Add Battery Status API support
+        https://bugs.webkit.org/show_bug.cgi?id=82615
+
+        Reviewed by George Staikos.
+
+        Add client implementation for Battery API.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::init):  initialize BatteryClient.
+        * WebCoreSupport/BatteryClientBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::BatteryClientBlackBerry::BatteryClientBlackBerry):
+        (WebCore::BatteryClientBlackBerry::setController):
+        (WebCore::BatteryClientBlackBerry::startUpdating):
+        (WebCore::BatteryClientBlackBerry::stopUpdating):
+        (WebCore::BatteryClientBlackBerry::batteryControllerDestroyed):
+        (WebCore::BatteryClientBlackBerry::onLevelChange):
+        (WebCore::BatteryClientBlackBerry::onChargingChange):
+        (WebCore::BatteryClientBlackBerry::onChargingTimeChange):
+        (WebCore::BatteryClientBlackBerry::onDischargingTimeChange):
+        * WebCoreSupport/BatteryClientBlackBerry.h: Added.
+        (WebCore):
+        (BatteryClientBlackBerry):
+        (WebCore::BatteryClientBlackBerry::~BatteryClientBlackBerry):
+
 2012-04-06  Benjamin Poulain  <[email protected]>
 
         Get rid of the useless flag PREEMPT_GEOLOCATION_PERMISSION

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp (0 => 113547)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp	2012-04-07 15:30:43 UTC (rev 113547)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "BatteryClientBlackBerry.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryController.h"
+#include <stdio.h>
+
+namespace WebCore {
+
+BatteryClientBlackBerry::BatteryClientBlackBerry()
+    : m_tracker(0)
+    , m_controller(0)
+{
+}
+
+void BatteryClientBlackBerry::setController(BatteryController* controller)
+{
+    m_controller = controller;
+}
+
+void BatteryClientBlackBerry::startUpdating()
+{
+    if (m_tracker)
+        m_tracker->resume();
+    else
+        m_tracker = BlackBerry::Platform::BatteryStatusTracker::create(this);
+}
+
+void BatteryClientBlackBerry::stopUpdating()
+{
+    if (m_tracker)
+        m_tracker->suspend();
+}
+
+void BatteryClientBlackBerry::batteryControllerDestroyed()
+{
+    delete this;
+}
+
+void BatteryClientBlackBerry::onLevelChange(bool charging, double chargingTime, double dischargingTime, double level)
+{
+    if (!m_controller)
+        return;
+
+    m_controller->didChangeBatteryStatus("levelchange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
+}
+
+void BatteryClientBlackBerry::onChargingChange(bool charging, double chargingTime, double dischargingTime, double level)
+{
+    if (!m_controller)
+        return;
+
+    m_controller->didChangeBatteryStatus("chargingchange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
+}
+
+void BatteryClientBlackBerry::onChargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level)
+{
+    if (!m_controller)
+        return;
+
+    m_controller->didChangeBatteryStatus("chargingtimechange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
+}
+
+void BatteryClientBlackBerry::onDischargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level)
+{
+    if (!m_controller)
+        return;
+
+    m_controller->didChangeBatteryStatus("dischargingtimechange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
+}
+
+}
+
+#endif // BATTERY_STATUS

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.h (0 => 113547)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.h	2012-04-07 15:30:43 UTC (rev 113547)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef BatteryClientBlackBerry_h
+#define BatteryClientBlackBerry_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryClient.h"
+
+#include <BlackBerryPlatformBatteryStatusTracker.h>
+#include <BlackBerryPlatformBatteryStatusTrackerListener.h>
+
+namespace WebCore {
+
+class BatteryController;
+class BatteryStatus;
+
+class BatteryClientBlackBerry : public BatteryClient, public BlackBerry::Platform::BatteryStatusTrackerListener {
+public:
+    BatteryClientBlackBerry();
+    ~BatteryClientBlackBerry() { }
+
+    virtual void setController(BatteryController*);
+    virtual void startUpdating();
+    virtual void stopUpdating();
+    virtual void batteryControllerDestroyed();
+
+    void onLevelChange(bool charging, double chargingTime, double dischargingTime, double level);
+    void onChargingChange(bool charging, double chargingTime, double dischargingTime, double level);
+    void onChargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level);
+    void onDischargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level);
+
+private:
+    BlackBerry::Platform::BatteryStatusTracker* m_tracker;
+    BatteryController* m_controller;
+};
+
+}
+
+#endif // BATTERY_STATUS
+#endif // BatteryClientBlackBerry_h

Modified: trunk/Source/cmake/OptionsBlackBerry.cmake (113546 => 113547)


--- trunk/Source/cmake/OptionsBlackBerry.cmake	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Source/cmake/OptionsBlackBerry.cmake	2012-04-07 15:30:43 UTC (rev 113547)
@@ -133,6 +133,7 @@
 ENDIF ()
 
 WEBKIT_FEATURE(ENABLE_ASSEMBLER_WX_EXCLUSIVE "Assembler WX Exclusive" DEFAULT ON)
+WEBKIT_FEATURE(ENABLE_BATTERY_STATUS "Enable battery status api" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_BLOB "Enable blob slice" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_CHANNEL_MESSAGING "Enable channel messaging" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_DATABASE "Enable database" DEFAULT ON)

Modified: trunk/Tools/ChangeLog (113546 => 113547)


--- trunk/Tools/ChangeLog	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Tools/ChangeLog	2012-04-07 15:30:43 UTC (rev 113547)
@@ -1,3 +1,14 @@
+2012-04-07  Rob Buis  <[email protected]>
+
+        [BlackBerry] Add Battery Status API support
+        https://bugs.webkit.org/show_bug.cgi?id=82615
+
+        Reviewed by George Staikos.
+
+        Enable BATTERY_STATUS.
+
+        * Scripts/build-webkit:
+
 2012-04-06  Ami Fischman  <[email protected]>
 
         Subscribe [email protected] to Media-related changes.

Modified: trunk/Tools/Scripts/build-webkit (113546 => 113547)


--- trunk/Tools/Scripts/build-webkit	2012-04-07 14:31:52 UTC (rev 113546)
+++ trunk/Tools/Scripts/build-webkit	2012-04-07 15:30:43 UTC (rev 113547)
@@ -164,7 +164,7 @@
       define => "ENABLE_ANIMATION_API", default => isBlackBerry(), value => \$animationAPISupport },
 
     { option => "battery-status-api", desc => "Toggle battery status API support",
-      define => "ENABLE_BATTERY_STATUS", default => isEfl(), value => \$batterystatusAPISupport },
+      define => "ENABLE_BATTERY_STATUS", default => (isEfl() || isBlackBerry()), value => \$batterystatusAPISupport },
 
     { option => "blob", desc => "Toggle Blob support",
       define => "ENABLE_BLOB", default => (isAppleMacWebKit() || isGtk() || isChromium() || isBlackBerry()), value => \$blobSupport },
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to