Changeset 113613 in webkit


Ignore:
Timestamp:
Apr 9, 2012 1:43:59 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Add Battery Status API support.

Source/WebCore:

Add Battery Status API support to chromium.
https://bugs.webkit.org/show_bug.cgi?id=83284

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2012-04-09
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:

Source/WebKit/chromium:

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

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2012-04-09
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):

LayoutTests:

Add Battery Status API support to chromium.
https://bugs.webkit.org/show_bug.cgi?id=83284

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2012-04-09
Reviewed by Adam Barth.

  • platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt:
  • platform/chromium/test_expectations.txt:
Location:
trunk
Files:
4 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r113611 r113613  
     12012-04-09  Sadrul Habib Chowdhury  <sadrul@chromium.org>
     2
     3        [chromium] Add Battery Status API support.
     4
     5        Add Battery Status API support to chromium.
     6        https://bugs.webkit.org/show_bug.cgi?id=83284
     7
     8        Reviewed by Adam Barth.
     9
     10        * platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt:
     11        * platform/chromium/test_expectations.txt:
     12
    1132012-04-09  SravanKumar Sandela  <ssandela@innominds.com>
    214
  • trunk/LayoutTests/platform/chromium/fast/dom/navigator-detached-no-crash-expected.txt

    r113282 r113613  
    1818navigator.vendor is OK
    1919navigator.vendorSub is OK
     20navigator.webkitBattery is OK
    2021navigator.webkitGamepads is OK
    2122navigator.webkitPointer is OK
     
    3839navigator.vendor is OK
    3940navigator.vendorSub is OK
     41navigator.webkitBattery is OK
    4042navigator.webkitGamepads is OK
    4143navigator.webkitPointer is OK
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r113611 r113613  
    132132// Vibration API is not supported yet in the chromium port.
    133133BUGWK72010 SKIP : fast/dom/navigator-vibration.html = FAIL
    134 
    135 // Battery Status API is not supported yet in the chromium port.
    136 BUGWK62698 SKIP : batterystatus = PASS FAIL
    137134
    138135// Touch Adjustment is not supported yet in the chromium port.
  • trunk/Source/WebCore/ChangeLog

    r113611 r113613  
     12012-04-09  Sadrul Habib Chowdhury  <sadrul@chromium.org>
     2
     3        [chromium] Add Battery Status API support.
     4
     5        Add Battery Status API support to chromium.
     6        https://bugs.webkit.org/show_bug.cgi?id=83284
     7
     8        Reviewed by Adam Barth.
     9
     10        This change is covered by tests in batterystatus/.
     11
     12        * Modules/battery/BatteryController.cpp:
     13        (WebCore::BatteryController::updateBatteryStatus):
     14        (WebCore):
     15        * Modules/battery/BatteryController.h:
     16        (BatteryController):
     17        * Modules/battery/BatteryManager.cpp:
     18        * WebCore.gyp/WebCore.gyp:
     19        * WebCore.gypi:
     20
    1212012-04-09  SravanKumar Sandela  <ssandela@innominds.com>
    222
  • trunk/Source/WebCore/Modules/battery/BatteryController.cpp

    r110991 r113613  
    11/*
    22 *  Copyright (C) 2012 Samsung Electronics
     3 *  Copyright (C) 2012 Google Inc.
    34 *
    45 *  This library is free software; you can redistribute it and/or
     
    6465}
    6566
     67void BatteryController::updateBatteryStatus(PassRefPtr<BatteryStatus> batteryStatus)
     68{
     69    RefPtr<BatteryStatus> status = batteryStatus;
     70    if (m_batteryStatus) {
     71
     72        if (m_batteryStatus->charging() != status->charging())
     73            didChangeBatteryStatus(WebCore::eventNames().chargingchangeEvent, status);
     74        else if (status->charging() && m_batteryStatus->chargingTime() != status->chargingTime())
     75            didChangeBatteryStatus(WebCore::eventNames().chargingtimechangeEvent, status);
     76        else if (!status->charging() && m_batteryStatus->dischargingTime() != status->dischargingTime())
     77            didChangeBatteryStatus(WebCore::eventNames().dischargingtimechangeEvent, status);
     78
     79        if (m_batteryStatus->level() != status->level())
     80            didChangeBatteryStatus(WebCore::eventNames().levelchangeEvent, status);
     81    }
     82
     83    m_batteryStatus = status.release();
     84}
     85
    6686void BatteryController::didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
    6787{
  • trunk/Source/WebCore/Modules/battery/BatteryController.h

    r110991 r113613  
    11/*
    22 *  Copyright (C) 2012 Samsung Electronics
     3 *  Copyright (C) 2012 Google Inc.
    34 *
    45 *  This library is free software; you can redistribute it and/or
     
    3839    void addListener(BatteryManager*);
    3940    void removeListener(BatteryManager*);
     41    void updateBatteryStatus(PassRefPtr<BatteryStatus>);
    4042    void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
    4143
     
    5355    BatteryClient* m_client;
    5456    ListenerVector m_listeners;
     57
     58    RefPtr<BatteryStatus> m_batteryStatus;
    5559};
    5660
  • trunk/Source/WebCore/Modules/battery/BatteryManager.cpp

    r112495 r113613  
    2525#include "BatteryController.h"
    2626#include "BatteryStatus.h"
     27#include "Document.h"
    2728#include "Event.h"
    2829#include "Frame.h"
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r113515 r113613  
    5252      '../',
    5353      '../..',
     54      '../Modules/battery',
    5455      '../Modules/filesystem',
    5556      '../Modules/filesystem/chromium',
  • trunk/Source/WebCore/WebCore.gypi

    r113587 r113613  
    747747        ],
    748748        'webcore_bindings_idl_files': [
     749            'Modules/battery/BatteryManager.idl',
     750            'Modules/battery/NavigatorBattery.idl',
    749751            'Modules/filesystem/DOMFileSystem.idl',
    750752            'Modules/filesystem/DOMFileSystemSync.idl',
     
    13301332        ],
    13311333        'webcore_files': [
     1334            'Modules/battery/BatteryClient.h',
     1335            'Modules/battery/BatteryController.cpp',
     1336            'Modules/battery/BatteryController.h',
     1337            'Modules/battery/BatteryManager.cpp',
     1338            'Modules/battery/BatteryManager.h',
     1339            'Modules/battery/BatteryStatus.cpp',
     1340            'Modules/battery/BatteryStatus.h',
     1341            'Modules/battery/NavigatorBattery.cpp',
     1342            'Modules/battery/NavigatorBattery.h',
    13321343            'Modules/filesystem/DOMFilePath.cpp',
    13331344            'Modules/filesystem/DOMFilePath.h',
  • trunk/Source/WebKit/chromium/ChangeLog

    r113606 r113613  
     12012-04-09  Sadrul Habib Chowdhury  <sadrul@chromium.org>
     2
     3        [chromium] Add Battery Status API support.
     4
     5        The battery-client (BatteryClientChromium) will notify the client (WebBatteryStatusClient) when to start or stop
     6        sending battery status updates. The client, in response will send the notifications to WebViewImpl, which sends
     7        this update information to the WebCore::BatteryClient, and it triggers the appropriate javascript-callbacks.
     8        The spec is at http://www.w3.org/TR/2011/WD-battery-status-20111129/.
     9        https://bugs.webkit.org/show_bug.cgi?id=83284
     10
     11        Reviewed by Adam Barth.
     12
     13        * WebKit.gyp:
     14        * features.gypi:
     15        * public/WebBatteryStatus.h: Added.
     16        (WebKit):
     17        (WebBatteryStatus):
     18        (WebKit::WebBatteryStatus::WebBatteryStatus):
     19        * public/WebBatteryStatusClient.h: Added.
     20        (WebKit):
     21        (WebBatteryStatusClient):
     22        (WebKit::WebBatteryStatusClient::~WebBatteryStatusClient):
     23        * public/WebView.h:
     24        (WebKit):
     25        (WebView):
     26        (WebKit::WebView::updateBatteryStatus):
     27        * public/WebViewClient.h:
     28        (WebKit):
     29        (WebViewClient):
     30        (WebKit::WebViewClient::batteryStatusClient):
     31        * src/BatteryClientImpl.cpp: Added.
     32        (WebKit):
     33        (WebKit::BatteryClientImpl::BatteryClientImpl):
     34        (WebKit::BatteryClientImpl::updateBatteryStatus):
     35        (WebKit::BatteryClientImpl::setController):
     36        (WebKit::BatteryClientImpl::startUpdating):
     37        (WebKit::BatteryClientImpl::stopUpdating):
     38        (WebKit::BatteryClientImpl::batteryControllerDestroyed):
     39        * src/BatteryClientImpl.h: Added.
     40        (WebKit):
     41        (BatteryClientImpl):
     42        (WebKit::BatteryClientImpl::~BatteryClientImpl):
     43        * src/WebViewImpl.cpp:
     44        (WebKit::WebViewImpl::WebViewImpl):
     45        (WebKit):
     46        (WebKit::WebViewImpl::updateBatteryStatus):
     47        * src/WebViewImpl.h:
     48        (WebKit):
     49        (WebViewImpl):
     50
    1512012-04-09  Shawn Singh  <shawnsingh@chromium.org>
    252
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r113218 r113613  
    103103                'public/WebAudioSourceProviderClient.h',
    104104                'public/WebAutofillClient.h',
     105                'public/WebBatteryStatus.h',
     106                'public/WebBatteryStatusClient.h',
    105107                'public/WebBindings.h',
    106108                'public/WebBlob.h',
     
    370372                'src/BackForwardListChromium.cpp',
    371373                'src/BackForwardListChromium.h',
     374                'src/BatteryClientImpl.cpp',
     375                'src/BatteryClientImpl.h',
    372376                'src/BlobRegistryProxy.cpp',
    373377                'src/BlobRegistryProxy.h',
  • trunk/Source/WebKit/chromium/features.gypi

    r113416 r113613  
    3434    'feature_defines': [
    3535      'ENABLE_3D_PLUGIN=1',
     36      'ENABLE_BATTERY_STATUS=1',
    3637      'ENABLE_BLOB=1',
    3738      'ENABLE_BLOB_SLICE=1',
  • trunk/Source/WebKit/chromium/public/WebView.h

    r112984 r113613  
    4242class WebAccessibilityObject;
    4343class WebAutofillClient;
     44class WebBatteryStatus;
    4445class WebDevToolsAgent;
    4546class WebDevToolsAgentClient;
     
    455456    virtual void removePageOverlay(WebPageOverlay*) = 0;
    456457
     458    // Battery status API support -------------------------------------------
     459
     460    // Updates the battery status in the BatteryClient. This also triggers the
     461    // appropriate JS events (e.g. sends a 'levelchange' event to JS if the
     462    // level is changed in this update from the previous update).
     463    virtual void updateBatteryStatus(const WebBatteryStatus&) { }
     464
    457465    // Testing functionality for LayoutTestController -----------------------
    458466
  • trunk/Source/WebKit/chromium/public/WebViewClient.h

    r113164 r113613  
    4949
    5050class WebAccessibilityObject;
     51class WebBatteryStatusClient;
    5152class WebColorChooser;
    5253class WebColorChooserClient;
     
    326327    virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; }
    327328
     329    // Battery Status ------------------------------------------------------
     330
     331    // Access the embedder API for battery status services.
     332    virtual WebBatteryStatusClient* batteryStatusClient() { return 0; }
    328333
    329334    // Zoom ----------------------------------------------------------------
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r113227 r113613  
    3636#include "AutofillPopupMenuClient.h"
    3737#include "BackForwardListChromium.h"
     38#include "BatteryClientImpl.h"
    3839#include "CSSStyleSelector.h"
    3940#include "CSSValueKeywords.h"
     
    386387    , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
    387388    , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
     389#if ENABLE(BATTERY_STATUS)
     390    , m_batteryClient(adoptPtr(new BatteryClientImpl(client ? client->batteryStatusClient() : 0)))
     391#endif
    388392    , m_emulatedTextZoomFactor(1)
    389393#if ENABLE(MEDIA_STREAM)
     
    426430    provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get());
    427431    m_geolocationClientProxy->setController(GeolocationController::from(m_page.get()));
     432
     433#if ENABLE(BATTERY_STATUS)
     434    provideBatteryTo(m_page.get(), m_batteryClient.get());
     435#endif
    428436   
    429437    m_page->setGroupName(pageGroupName);
     
    13751383}
    13761384
     1385#if ENABLE(BATTERY_STATUS)
     1386void WebViewImpl::updateBatteryStatus(const WebBatteryStatus& status)
     1387{
     1388    m_batteryClient->updateBatteryStatus(status);
     1389}
     1390#endif
     1391
    13771392void WebViewImpl::animate(double)
    13781393{
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r113164 r113613  
    8181class AutocompletePopupMenuClient;
    8282class AutofillPopupMenuClient;
     83class BatteryClientImpl;
    8384class ContextMenuClientImpl;
    8485class DeviceOrientationClientProxy;
     
    257258    virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */);
    258259    virtual void removePageOverlay(WebPageOverlay*);
     260#if ENABLE(BATTERY_STATUS)
     261    virtual void updateBatteryStatus(const WebBatteryStatus&);
     262#endif
    259263    virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&);
    260264
     
    749753    OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
    750754    OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
     755#if ENABLE(BATTERY_STATUS)
     756    OwnPtr<BatteryClientImpl> m_batteryClient;
     757#endif
    751758
    752759    float m_emulatedTextZoomFactor;
Note: See TracChangeset for help on using the changeset viewer.