Source/WebKit2/ChangeLog

 12013-11-05 José Dapena Paz <jdapena@igalia.com> and Zan Dobersek <zdobersek@igalia.com>
 2
 3 [GTK][WK2] Add the WebKitBatteryProvider class
 4 https://bugs.webkit.org/show_bug.cgi?id=115720
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This patch adds the WebKitBatteryProvider class which sets up a BatteryProviderUPower instance,
 9 controlling the provider's activity when instrumented to do so by the WebBatteryManagerProxy
 10 and relaying the battery status updates from the battery provider to the battery manager.
 11
 12 * GNUmakefile.list.am: Add the build targets for the new source files.
 13 * UIProcess/API/gtk/WebKitBatteryProvider.cpp: Added.
 14 (toBatteryProvider): A helper inline method that casts the client info to the battery provider instance.
 15 (startUpdatingCallback): Relays the instruction to the WebKitBattery instance.
 16 (stopUpdatingCallback): Ditto.
 17 (WebKitBatteryProvider::create):
 18 (WebKitBatteryProvider::WebKitBatteryProvider): Set up a WKBatteryProvider and set it to the passed-in battery manager.
 19 (WebKitBatteryProvider::~WebKitBatteryProvider): Force the BatteryProviderUPower to stop updating.
 20 (WebKitBatteryProvider::startUpdating): Relays the instruction to the BatteryProviderUPower instance.
 21 (WebKitBatteryProvider::stopUpdating): Ditto.
 22 (WebKitBatteryProvider::notifyBatteryStatusUnavailable): Update the battery manager with the new status that
 23 has the default values that are to be used when the implementation cannot determine the battery status (as per
 24 the Battery Status API specification).
 25 (WebKitBatteryProvider::notifyBatteryStatusUpdated): Update the battery status.
 26 * UIProcess/API/gtk/WebKitBatteryProvider.h: Added.
 27 (WebKitBatteryProvider): Define the WebKitBatteryProvider reference-counted interface that also inherits from the
 28 BatteryProviderUPowerClient interface.
 29 * UIProcess/API/gtk/WebKitWebContext.cpp:
 30 (_WebKitWebContextPrivate): Add a WebKitBatteryProvider member variable to the struct.
 31 (createDefaultWebContext): Create a new battery provider when initializing the default web context.
 32
1332013-11-05 Anders Carlsson <andersca@apple.com>
234
335 Begin work on decoding invocations

Source/WebKit2/GNUmakefile.list.am

@@webkit2_sources += \
684684 Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h \
685685 Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp \
686686 Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h \
 687 Source/WebKit2/UIProcess/API/gtk/WebKitBatteryProvider.cpp \
 688 Source/WebKit2/UIProcess/API/gtk/WebKitBatteryProvider.h \
687689 Source/WebKit2/UIProcess/API/gtk/WebKitCertificateInfo.cpp \
688690 Source/WebKit2/UIProcess/API/gtk/WebKitCertificateInfo.h \
689691 Source/WebKit2/UIProcess/API/gtk/WebKitCertificateInfoPrivate.h \

Source/WebKit2/UIProcess/API/gtk/WebKitBatteryProvider.cpp

 1/*
 2 * Copyright (C) 2013 Igalia S.L.
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#include "config.h"
 21#include "WebKitBatteryProvider.h"
 22
 23#if ENABLE(BATTERY_STATUS)
 24
 25#include "WebBatteryManagerProxy.h"
 26#include "WebBatteryStatus.h"
 27#include <limits>
 28
 29using namespace WebKit;
 30
 31static inline WebKitBatteryProvider* toBatteryProvider(const void* clientInfo)
 32{
 33 return static_cast<WebKitBatteryProvider*>(const_cast<void*>(clientInfo));
 34}
 35
 36static void startUpdatingCallback(WKBatteryManagerRef batteryManager, const void* clientInfo)
 37{
 38 toBatteryProvider(clientInfo)->startUpdating();
 39}
 40
 41static void stopUpdatingCallback(WKBatteryManagerRef batteryManager, const void* clientInfo)
 42{
 43 toBatteryProvider(clientInfo)->stopUpdating();
 44}
 45
 46PassRefPtr<WebKitBatteryProvider> WebKitBatteryProvider::create(WebBatteryManagerProxy* batteryManager)
 47{
 48 return adoptRef(new WebKitBatteryProvider(batteryManager));
 49}
 50
 51WebKitBatteryProvider::WebKitBatteryProvider(WebBatteryManagerProxy* batteryManager)
 52 : m_batteryManager(batteryManager)
 53 , m_provider(this)
 54{
 55 ASSERT(batteryManager);
 56
 57 WKBatteryProvider wkBatteryProvider = {
 58 kWKBatteryProviderCurrentVersion,
 59 this, // clientInfo
 60 startUpdatingCallback,
 61 stopUpdatingCallback
 62 };
 63 WKBatteryManagerSetProvider(toAPI(batteryManager), &wkBatteryProvider);
 64}
 65
 66WebKitBatteryProvider::~WebKitBatteryProvider()
 67{
 68 m_provider.stopUpdating();
 69}
 70
 71void WebKitBatteryProvider::startUpdating()
 72{
 73 m_provider.startUpdating();
 74}
 75
 76void WebKitBatteryProvider::stopUpdating()
 77{
 78 m_provider.stopUpdating();
 79}
 80
 81void WebKitBatteryProvider::updateBatteryStatus(WebCore::BatteryProviderUPowerStatus status, double timeRemaining, double level)
 82{
 83 RefPtr<WebBatteryStatus> batteryStatus;
 84
 85 switch (status) {
 86 case WebCore::NotAvailable:
 87 // When an implementation cannot report battery status, the default values should be used.
 88 batteryStatus = WebBatteryStatus::create(true, std::numeric_limits<double>::infinity(),
 89 std::numeric_limits<double>::infinity(), 1.0);
 90 break;
 91 case WebCore::Charging:
 92 batteryStatus = WebBatteryStatus::create(true, timeRemaining, 0, level);
 93 break;
 94 case WebCore::Discharging:
 95 batteryStatus = WebBatteryStatus::create(false, 0, timeRemaining, level);
 96 break;
 97 default:
 98 ASSERT_NOT_REACHED();
 99 }
 100
 101 m_batteryManager->providerUpdateBatteryStatus(batteryStatus.get());
 102}
 103
 104#endif // ENABLE(BATTERY_STATUS)

Source/WebKit2/UIProcess/API/gtk/WebKitBatteryProvider.h

 1/*
 2 * Copyright (C) 2013 Igalia S.L.
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#ifndef WebKitBatteryProvider_h
 21#define WebKitBatteryProvider_h
 22
 23#if ENABLE(BATTERY_STATUS)
 24
 25#include "WebKitPrivate.h"
 26#include <WebCore/BatteryProviderUPowerClient.h>
 27#include <WebCore/BatteryProviderUPower.h>
 28#include <wtf/PassRefPtr.h>
 29#include <wtf/RefCounted.h>
 30
 31namespace WebKit {
 32
 33class WebKitBatteryProvider : public RefCounted<WebKitBatteryProvider>, public WebCore::BatteryProviderUPowerClient {
 34public:
 35 static PassRefPtr<WebKitBatteryProvider> create(WebBatteryManagerProxy*);
 36 virtual ~WebKitBatteryProvider();
 37
 38 void startUpdating();
 39 void stopUpdating();
 40
 41private:
 42 WebKitBatteryProvider(WebBatteryManagerProxy*);
 43
 44 // WebCore::BatteryProviderUPowerClient
 45 virtual void updateBatteryStatus(WebCore::BatteryProviderUPowerStatus, double timeRemaining, double level);
 46
 47 RefPtr<WebBatteryManagerProxy> m_batteryManager;
 48 WebCore::BatteryProviderUPower m_provider;
 49};
 50
 51}
 52
 53#endif // ENABLE(BATTERY_STATUS)
 54
 55#endif // WebKitBatteryProvider_h

Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

2020#include "config.h"
2121#include "WebKitWebContext.h"
2222
 23#include "WebBatteryManagerProxy.h"
2324#include "WebCertificateInfo.h"
2425#include "WebCookieManagerProxy.h"
2526#include "WebGeolocationManagerProxy.h"
 27#include "WebKitBatteryProvider.h"
2628#include "WebKitCertificateInfoPrivate.h"
2729#include "WebKitCookieManagerPrivate.h"
2830#include "WebKitDownloadClient.h"

@@struct _WebKitWebContextPrivate {
139141#if ENABLE(GEOLOCATION)
140142 RefPtr<WebKitGeolocationProvider> geolocationProvider;
141143#endif
 144#if ENABLE(BATTERY_STATUS)
 145 RefPtr<WebKitBatteryProvider> batteryProvider;
 146#endif
142147#if ENABLE(SPELLCHECK)
143148 OwnPtr<WebKitTextChecker> textChecker;
144149#endif

@@static gpointer createDefaultWebContext(gpointer)
208213#if ENABLE(GEOLOCATION)
209214 priv->geolocationProvider = WebKitGeolocationProvider::create(priv->context->supplement<WebGeolocationManagerProxy>());
210215#endif
 216#if ENABLE(BATTERY_STATUS)
 217 priv->batteryProvider = WebKitBatteryProvider::create(priv->context->supplement<WebBatteryManagerProxy>());
 218#endif
211219#if ENABLE(SPELLCHECK)
212220 priv->textChecker = WebKitTextChecker::create();
213221#endif

Tools/ChangeLog

 12013-11-05 José Dapena Paz <jdapena@igalia.com> and Zan Dobersek <zdobersek@igalia.com>
 2
 3 [GTK][WK2] Add the WebKitBatteryProvider class
 4 https://bugs.webkit.org/show_bug.cgi?id=115720
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * gtk/generate-gtkdoc:
 9 (get_webkit2_options): Ignore the WebKitBatteryProvider source files when generating the documentation.
 10
1112013-11-05 Benjamin Poulain <benjamin@webkit.org>
212
313 [WK2] Add a WebKit2 API for Geolocation's highAccuracy

Tools/gtk/generate-gtkdoc

@@def get_webkit2_options():
103103 'ignored_files': glob.glob(src_path('*Private.h')) + \
104104 glob.glob(injected_bundle_src_path('*Private.h')) + \
105105 glob.glob(src_path('*Client*')) + \
 106 glob.glob(src_path('WebKitAuthenticationDialog.*')) + \
 107 glob.glob(src_path('WebKitBatteryProvider.*')) + \
106108 glob.glob(src_path('WebKitGeolocationProvider.*')) + \
107109 glob.glob(src_path('WebKitTextChecker.*')) + \
108  glob.glob(src_path('WebKitAuthenticationDialog.*')) + \
109110 glob.glob(src_path('WebKitWebViewBaseAccessible.*')) + \
110111 glob.glob(src_path('WebViewBaseInputMethodFilter.*')) + \
111112 glob.glob(derived_sources_path('webkit2gtk', 'webkit2', 'WebKitMarshal.*')) + \