Support the Network Information API
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Apr 2012 15:09:25 +0000 (15:09 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Apr 2012 15:09:25 +0000 (15:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73528

Reviewed by Adam Barth.

.:

Add network information API feature.

* Source/cmake/OptionsEfl.cmake: Add NETWORK_INFO feature.
* Source/cmakeconfig.h.cmake: Add NETWORK_INFO feature.

Source/WebCore:

Network Information APIs is to provide an interface for Web Applications to access
the underlying network information of device. In Web Application case, they need to know
what current network interface it uses. Because, it is important to know current network
information(bandwidth, metered) in mobile domain. Thus, Web Application can let user know
whether current network information via this new functionality. In addition, in streaming
service case, Web Application can control content resolution according to kind of network.

http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/index.html

Tests: networkinformation/add-listener-from-callback.html
       networkinformation/basic-all-types-of-events.html
       networkinformation/basic-operation.html
       networkinformation/event-after-navigation.html
       networkinformation/multiple-frames.html
       networkinformation/updates.html
       networkinformation/window-property.html

* CMakeLists.txt:
* Modules/networkinfo/NavigatorNetworkInfoConnection.cpp: Added.
(WebCore):
(WebCore::NavigatorNetworkInfoConnection::NavigatorNetworkInfoConnection):
(WebCore::NavigatorNetworkInfoConnection::~NavigatorNetworkInfoConnection):
(WebCore::NavigatorNetworkInfoConnection::from):
(WebCore::NavigatorNetworkInfoConnection::webkitConnection):
* Modules/networkinfo/NavigatorNetworkInfoConnection.h: Added.
(WebCore):
(NavigatorNetworkInfoConnection):
* Modules/networkinfo/NavigatorNetworkInfoConnection.idl: Added.
* Modules/networkinfo/NetworkInfo.cpp: Added.
(WebCore):
(WebCore::NetworkInfo::NetworkInfo):
* Modules/networkinfo/NetworkInfo.h: Added.
(WebCore):
(NetworkInfo):
(WebCore::NetworkInfo::create):
(WebCore::NetworkInfo::bandwidth):
(WebCore::NetworkInfo::metered):
* Modules/networkinfo/NetworkInfoClient.h: Added.
(WebCore):
(NetworkInfoClient):
(WebCore::NetworkInfoClient::~NetworkInfoClient):
* Modules/networkinfo/NetworkInfoConnection.cpp: Added.
(WebCore):
(WebCore::NetworkInfoConnection::create):
(WebCore::NetworkInfoConnection::NetworkInfoConnection):
(WebCore::NetworkInfoConnection::~NetworkInfoConnection):
(WebCore::NetworkInfoConnection::bandwidth):
(WebCore::NetworkInfoConnection::metered):
(WebCore::NetworkInfoConnection::didChangeNetworkInformation):
(WebCore::NetworkInfoConnection::addEventListener):
(WebCore::NetworkInfoConnection::removeEventListener):
(WebCore::NetworkInfoConnection::eventTargetData):
(WebCore::NetworkInfoConnection::ensureEventTargetData):
(WebCore::NetworkInfoConnection::interfaceName):
(WebCore::NetworkInfoConnection::suspend):
(WebCore::NetworkInfoConnection::resume):
(WebCore::NetworkInfoConnection::stop):
* Modules/networkinfo/NetworkInfoConnection.h: Added.
(WebCore):
(NetworkInfoConnection):
(WebCore::NetworkInfoConnection::scriptExecutionContext):
(WebCore::NetworkInfoConnection::canSuspend):
(WebCore::NetworkInfoConnection::refEventTarget):
(WebCore::NetworkInfoConnection::derefEventTarget):
* Modules/networkinfo/NetworkInfoConnection.idl: Added.
* Modules/networkinfo/NetworkInfoController.cpp: Added.
(WebCore):
(WebCore::NetworkInfoController::NetworkInfoController):
(WebCore::NetworkInfoController::~NetworkInfoController):
(WebCore::NetworkInfoController::create):
(WebCore::NetworkInfoController::addListener):
(WebCore::NetworkInfoController::removeListener):
(WebCore::NetworkInfoController::didChangeNetworkInformation):
(WebCore::NetworkInfoController::isActive):
(WebCore::NetworkInfoController::supplementName):
(WebCore::provideNetworkInfoTo):
* Modules/networkinfo/NetworkInfoController.h: Added.
(WebCore):
(NetworkInfoController):
(WebCore::NetworkInfoController::client):
(WebCore::NetworkInfoController::from):
* dom/EventNames.h:
(WebCore):
* dom/EventTargetFactory.in:
* testing/Internals.cpp:
(WebCore::Internals::setNetworkInformation):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit:

* PlatformEfl.cmake: Add dummy NetworkInfoClientEfl.cpp files in order to support network information API.

Source/WebKit/efl:

Add NetworkInfoClientEfl to support network information API. However,
functions are not implemented yet.

* WebCoreSupport/NetworkInfoClientEfl.cpp: Added.
(WebCore::NetworkInfoClientEfl::NetworkInfoClientEfl):
(WebCore):
(WebCore::NetworkInfoClientEfl::~NetworkInfoClientEfl):
(WebCore::NetworkInfoClientEfl::startUpdating):
(WebCore::NetworkInfoClientEfl::stopUpdating):
(WebCore::NetworkInfoClientEfl::bandwidth):
(WebCore::NetworkInfoClientEfl::metered):
* WebCoreSupport/NetworkInfoClientEfl.h: Added.
(NetworkInfoClientEfl):
* ewk/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_ewk_view_priv_new):

Tools:

Add network information API feature to build script.

* Scripts/build-webkit:

LayoutTests:

Add new test cases for network information API specification.
And also, skip this test cases for other ports.

* networkinformation/add-listener-from-callback-expected.txt: Added.
* networkinformation/add-listener-from-callback.html: Added.
* networkinformation/basic-all-types-of-events-expected.txt: Added.
* networkinformation/basic-all-types-of-events.html: Added.
* networkinformation/basic-operation-expected.txt: Added.
* networkinformation/basic-operation.html: Added.
* networkinformation/event-after-navigation-expected.txt: Added.
* networkinformation/event-after-navigation.html: Added.
* networkinformation/multiple-frames-expected.txt: Added.
* networkinformation/multiple-frames.html: Added.
* networkinformation/resources/event-after-navigation-new.html: Added.
* networkinformation/script-tests/add-listener-from-callback.js: Added.
(checkNetworkInformation):
(firstListener):
(secondListener):
(maybeFinishTest):
* networkinformation/script-tests/basic-all-types-of-events.js: Added.
(checkNetworkInformation):
* networkinformation/script-tests/basic-operation.js: Added.
* networkinformation/script-tests/event-after-navigation.js: Added.
* networkinformation/script-tests/multiple-frames.js: Added.
(checkNetworkInformation):
(checkChildNetworkInformation):
(mainFrameListener):
(childFrameListener):
(maybeFinishTest):
* networkinformation/script-tests/updates.js: Added.
(checkNetworkInformation):
(setNetworkInformation):
(firstListener):
(updateListener):
* networkinformation/script-tests/window-property.js: Added.
(hasOnConnectionProperty):
* networkinformation/updates-expected.txt: Added.
* networkinformation/updates.html: Added.
* networkinformation/window-property-expected.txt: Added.
* networkinformation/window-property.html: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/wincairo/Skipped:

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

57 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/networkinformation/add-listener-from-callback-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/add-listener-from-callback.html [new file with mode: 0644]
LayoutTests/networkinformation/basic-all-types-of-events-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/basic-all-types-of-events.html [new file with mode: 0644]
LayoutTests/networkinformation/basic-operation-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/basic-operation.html [new file with mode: 0644]
LayoutTests/networkinformation/event-after-navigation-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/event-after-navigation.html [new file with mode: 0644]
LayoutTests/networkinformation/multiple-frames-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/multiple-frames.html [new file with mode: 0644]
LayoutTests/networkinformation/resources/event-after-navigation-new.html [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/add-listener-from-callback.js [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/basic-all-types-of-events.js [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/basic-operation.js [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/event-after-navigation.js [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/multiple-frames.js [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/updates.js [new file with mode: 0644]
LayoutTests/networkinformation/script-tests/window-property.js [new file with mode: 0644]
LayoutTests/networkinformation/updates-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/updates.html [new file with mode: 0644]
LayoutTests/networkinformation/window-property-expected.txt [new file with mode: 0644]
LayoutTests/networkinformation/window-property.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/wincairo/Skipped
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.cpp [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.h [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.idl [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfo.cpp [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfo.h [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfoClient.h [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfoConnection.idl [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfoController.cpp [new file with mode: 0644]
Source/WebCore/Modules/networkinfo/NetworkInfoController.h [new file with mode: 0644]
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventTargetFactory.in
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/PlatformEfl.cmake
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/NetworkInfoClientEfl.cpp [new file with mode: 0644]
Source/WebKit/efl/WebCoreSupport/NetworkInfoClientEfl.h [new file with mode: 0644]
Source/WebKit/efl/ewk/ewk_view.cpp
Source/cmake/OptionsEfl.cmake
Source/cmakeconfig.h.cmake
Tools/ChangeLog
Tools/Scripts/build-webkit

index d70d067..cd1307a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Support the Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=73528
+
+        Reviewed by Adam Barth.
+
+        Add network information API feature.
+
+        * Source/cmake/OptionsEfl.cmake: Add NETWORK_INFO feature.
+        * Source/cmakeconfig.h.cmake: Add NETWORK_INFO feature.
+
 2012-03-31  Jonathan Dong  <jonathan.dong@torchmobile.com.cn>
 
         [BlackBerry] http authenticate dialog popup only once no matter authentication pass or fail
index be6a6b2..19f7328 100644 (file)
@@ -1,3 +1,55 @@
+2012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Support the Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=73528
+
+        Reviewed by Adam Barth.
+
+        Add new test cases for network information API specification.
+        And also, skip this test cases for other ports.
+
+        * networkinformation/add-listener-from-callback-expected.txt: Added.
+        * networkinformation/add-listener-from-callback.html: Added.
+        * networkinformation/basic-all-types-of-events-expected.txt: Added.
+        * networkinformation/basic-all-types-of-events.html: Added.
+        * networkinformation/basic-operation-expected.txt: Added.
+        * networkinformation/basic-operation.html: Added.
+        * networkinformation/event-after-navigation-expected.txt: Added.
+        * networkinformation/event-after-navigation.html: Added.
+        * networkinformation/multiple-frames-expected.txt: Added.
+        * networkinformation/multiple-frames.html: Added.
+        * networkinformation/resources/event-after-navigation-new.html: Added.
+        * networkinformation/script-tests/add-listener-from-callback.js: Added.
+        (checkNetworkInformation):
+        (firstListener):
+        (secondListener):
+        (maybeFinishTest):
+        * networkinformation/script-tests/basic-all-types-of-events.js: Added.
+        (checkNetworkInformation):
+        * networkinformation/script-tests/basic-operation.js: Added.
+        * networkinformation/script-tests/event-after-navigation.js: Added.
+        * networkinformation/script-tests/multiple-frames.js: Added.
+        (checkNetworkInformation):
+        (checkChildNetworkInformation):
+        (mainFrameListener):
+        (childFrameListener):
+        (maybeFinishTest):
+        * networkinformation/script-tests/updates.js: Added.
+        (checkNetworkInformation):
+        (setNetworkInformation):
+        (firstListener):
+        (updateListener):
+        * networkinformation/script-tests/window-property.js: Added.
+        (hasOnConnectionProperty):
+        * networkinformation/updates-expected.txt: Added.
+        * networkinformation/updates.html: Added.
+        * networkinformation/window-property-expected.txt: Added.
+        * networkinformation/window-property.html: Added.
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/wincairo/Skipped:
+
 2012-04-01  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Enable animVal support for SVGAnimatedEnumeration
diff --git a/LayoutTests/networkinformation/add-listener-from-callback-expected.txt b/LayoutTests/networkinformation/add-listener-from-callback-expected.txt
new file mode 100644 (file)
index 0000000..ad2fde7
--- /dev/null
@@ -0,0 +1,15 @@
+Tests that adding a new event listener from a callback works as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/networkinformation/add-listener-from-callback.html b/LayoutTests/networkinformation/add-listener-from-callback.html
new file mode 100644 (file)
index 0000000..d4b2291
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/add-listener-from-callback.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/networkinformation/basic-all-types-of-events-expected.txt b/LayoutTests/networkinformation/basic-all-types-of-events-expected.txt
new file mode 100644 (file)
index 0000000..c823708
--- /dev/null
@@ -0,0 +1,12 @@
+Tests the basic operation of all NetworkInfo events.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitnetworkinfochange event is raised
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/networkinformation/basic-all-types-of-events.html b/LayoutTests/networkinformation/basic-all-types-of-events.html
new file mode 100644 (file)
index 0000000..7fee4e0
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/basic-all-types-of-events.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/networkinformation/basic-operation-expected.txt b/LayoutTests/networkinformation/basic-operation-expected.txt
new file mode 100644 (file)
index 0000000..e3a0790
--- /dev/null
@@ -0,0 +1,11 @@
+Tests the basic operation of NetworkInfo.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/networkinformation/basic-operation.html b/LayoutTests/networkinformation/basic-operation.html
new file mode 100644 (file)
index 0000000..e2d4474
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/basic-operation.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/networkinformation/event-after-navigation-expected.txt b/LayoutTests/networkinformation/event-after-navigation-expected.txt
new file mode 100644 (file)
index 0000000..8e6bc39
--- /dev/null
@@ -0,0 +1,3 @@
+Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.
+
+SUCCESS
diff --git a/LayoutTests/networkinformation/event-after-navigation.html b/LayoutTests/networkinformation/event-after-navigation.html
new file mode 100644 (file)
index 0000000..96b0c5e
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/event-after-navigation.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/networkinformation/multiple-frames-expected.txt b/LayoutTests/networkinformation/multiple-frames-expected.txt
new file mode 100644 (file)
index 0000000..6a122f9
--- /dev/null
@@ -0,0 +1,13 @@
+Tests using NetworkInfo from multiple frames.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/networkinformation/multiple-frames.html b/LayoutTests/networkinformation/multiple-frames.html
new file mode 100644 (file)
index 0000000..386b0a2
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/multiple-frames.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/networkinformation/resources/event-after-navigation-new.html b/LayoutTests/networkinformation/resources/event-after-navigation-new.html
new file mode 100644 (file)
index 0000000..60a7217
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+  <head>
+  </head>
+  <body>
+    Tests for a crash where an event is fired after the page has been navigated
+    away when the original page is in the page cache.<br><br>
+    SUCCESS
+    <script>
+        internals.setNetworkInformation(document, 'webkitnetworkinfochange', 100, true);
+        layoutTestController.notifyDone();
+    </script>
+  </body>
+</html>
diff --git a/LayoutTests/networkinformation/script-tests/add-listener-from-callback.js b/LayoutTests/networkinformation/script-tests/add-listener-from-callback.js
new file mode 100644 (file)
index 0000000..365fc79
--- /dev/null
@@ -0,0 +1,41 @@
+description('Tests that adding a new event listener from a callback works as expected.');
+
+var bandwidth = 10;
+var metered = false;
+
+var connection = navigator.webkitConnection;
+
+function checkNetworkInformation() {
+    shouldBe('connection.bandwidth', 'bandwidth');
+    shouldBe('connection.metered', 'metered');
+}
+
+var firstListenerEvents = 0;
+function firstListener() {
+    checkNetworkInformation();
+    if (++firstListenerEvents == 1) {
+        connection.addEventListener('webkitnetworkinfochange', secondListener);
+        internals.setNetworkInformation(document, 'webkitnetworkinfochange', bandwidth, metered);
+    }
+    else if (firstListenerEvents > 2)
+        testFailed('Too many events for first listener.');
+    maybeFinishTest();
+}
+
+var secondListenerEvents = 0;
+function secondListener() {
+    checkNetworkInformation();
+    if (++secondListenerEvents > 1)
+        testFailed('Too many events for second listener.');
+    maybeFinishTest();
+}
+
+function maybeFinishTest() {
+    if (firstListenerEvents == 2 && secondListenerEvents == 1)
+        finishJSTest();
+}
+
+connection.addEventListener('webkitnetworkinfochange', firstListener);
+internals.setNetworkInformation(document, 'webkitnetworkinfochange', bandwidth, metered);
+
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/networkinformation/script-tests/basic-all-types-of-events.js b/LayoutTests/networkinformation/script-tests/basic-all-types-of-events.js
new file mode 100644 (file)
index 0000000..fe0e768
--- /dev/null
@@ -0,0 +1,20 @@
+description('Tests the basic operation of all NetworkInfo events.');
+
+var bandwidth = 10;
+var metered = false;
+
+var connection = navigator.webkitConnection;
+
+function checkNetworkInformation() {
+    shouldBe('connection.bandwidth', 'bandwidth');
+    shouldBe('connection.metered', 'metered');
+}
+
+connection.addEventListener('webkitnetworkinfochange', function() {
+    debug('webkitnetworkinfochange event is raised');
+    checkNetworkInformation();
+    finishJSTest();
+});
+
+internals.setNetworkInformation(document, 'webkitnetworkinfochange', bandwidth, metered);
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/networkinformation/script-tests/basic-operation.js b/LayoutTests/networkinformation/script-tests/basic-operation.js
new file mode 100644 (file)
index 0000000..44cfc61
--- /dev/null
@@ -0,0 +1,16 @@
+description('Tests the basic operation of NetworkInfo.');
+
+var bandwidth = 10;
+var metered = false;
+
+var connection = navigator.webkitConnection;
+
+connection.addEventListener('webkitnetworkinfochange', function() {
+    shouldBe('connection.bandwidth', 'bandwidth');
+    shouldBe('connection.metered', 'metered');
+    finishJSTest();
+});
+
+internals.setNetworkInformation(document, 'webkitnetworkinfochange', bandwidth, metered);
+
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/networkinformation/script-tests/event-after-navigation.js b/LayoutTests/networkinformation/script-tests/event-after-navigation.js
new file mode 100644 (file)
index 0000000..b9fc8d6
--- /dev/null
@@ -0,0 +1,13 @@
+description('Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.');
+
+if (window.layoutTestController)
+    layoutTestController.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
+else
+    debug('This test can not be run without the LayoutTestController');
+
+document.body.onload = function() {
+    navigator.webkitConnection.addEventListener('webkitnetworkinfochange', function() { } );
+    window.location = "resources/event-after-navigation-new.html";
+}
+
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/networkinformation/script-tests/multiple-frames.js b/LayoutTests/networkinformation/script-tests/multiple-frames.js
new file mode 100644 (file)
index 0000000..a437c2e
--- /dev/null
@@ -0,0 +1,45 @@
+description('Tests using NetworkInfo from multiple frames.');
+
+var bandwidth = 10;
+var metered = false;
+
+var connection = navigator.webkitConnection;
+
+function checkNetworkInformation() {
+    shouldBe('connection.bandwidth', 'bandwidth');
+    shouldBe('connection.metered', 'metered');
+}
+
+function checkChildNetworkInformation() {
+    shouldBe('connection.bandwidth', 'bandwidth');
+    shouldBe('connection.metered', 'metered');
+}
+
+var hasMainFrameEventFired = false;
+function mainFrameListener() {
+    hasMainFrameEventFired = true;
+    maybeFinishTest();
+}
+
+var hasChildFrameEventFired = false;
+function childFrameListener() {
+    hasChildFrameEventFired = true;
+    maybeFinishTest();
+}
+
+function maybeFinishTest() {
+    if (hasMainFrameEventFired && hasChildFrameEventFired) {
+        checkNetworkInformation();
+        checkChildNetworkInformation();
+        finishJSTest();
+    }
+}
+
+var childFrame = document.createElement('iframe');
+document.body.appendChild(childFrame);
+var childConnection = childFrame.contentWindow.navigator.webkitConnection
+childConnection.addEventListener('webkitnetworkinfochange', childFrameListener);
+connection.addEventListener('webkitnetworkinfochange', mainFrameListener);
+
+internals.setNetworkInformation(document, 'webkitnetworkinfochange', bandwidth, metered);
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/networkinformation/script-tests/updates.js b/LayoutTests/networkinformation/script-tests/updates.js
new file mode 100644 (file)
index 0000000..e6cad6c
--- /dev/null
@@ -0,0 +1,34 @@
+description('Tests that updates to the connection event causes new events to fire.');
+
+var bandwidth = 10;
+var metered = false;
+
+var connection = navigator.webkitConnection;
+
+function checkNetworkInformation() {
+    shouldBe('connection.bandwidth', 'bandwidth');
+    shouldBe('connection.metered', 'metered');
+}
+
+function setNetworkInformation() {
+    internals.setNetworkInformation(document, 'webkitnetworkinfochange', bandwidth, metered);
+}
+
+function firstListener() {
+    checkNetworkInformation();
+    connection.removeEventListener('webkitnetworkinfochange', firstListener);
+    connection.addEventListener('webkitnetworkinfochange', updateListener);
+  
+    bandwidth = 5;
+    metered = true;
+    setNetworkInformation();
+}
+
+function updateListener(event) {
+    checkNetworkInformation(event);
+    finishJSTest();
+}
+
+connection.addEventListener('webkitnetworkinfochange', firstListener);
+setNetworkInformation();
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/networkinformation/script-tests/window-property.js b/LayoutTests/networkinformation/script-tests/window-property.js
new file mode 100644 (file)
index 0000000..4169988
--- /dev/null
@@ -0,0 +1,17 @@
+description('Tests that the window.navigator.connection properties are present.');
+
+function hasOnConnectionProperty()
+{
+    var result = 0;
+    for (var property in navigator.webkitConnection) {
+        if (property == 'onwebkitnetworkinfochange')
+            result += 1;
+    }
+    if (result == 1)
+        return true;
+    return false;
+}
+
+shouldBeTrue("typeof navigator.webkitConnection == 'object'");
+shouldBeTrue("hasOnConnectionProperty()");
+shouldBeTrue("navigator.webkitConnection.hasOwnProperty('onwebkitnetworkinfochange')");
diff --git a/LayoutTests/networkinformation/updates-expected.txt b/LayoutTests/networkinformation/updates-expected.txt
new file mode 100644 (file)
index 0000000..993d75c
--- /dev/null
@@ -0,0 +1,13 @@
+Tests that updates to the connection event causes new events to fire.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS connection.bandwidth is bandwidth
+PASS connection.metered is metered
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/networkinformation/updates.html b/LayoutTests/networkinformation/updates.html
new file mode 100644 (file)
index 0000000..e733ad1
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/updates.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/networkinformation/window-property-expected.txt b/LayoutTests/networkinformation/window-property-expected.txt
new file mode 100644 (file)
index 0000000..b1bc67b
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that the window.navigator.connection properties are present.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof navigator.webkitConnection == 'object' is true
+PASS hasOnConnectionProperty() is true
+PASS navigator.webkitConnection.hasOwnProperty('onwebkitnetworkinfochange') is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/networkinformation/window-property.html b/LayoutTests/networkinformation/window-property.html
new file mode 100644 (file)
index 0000000..e9088f2
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/window-property.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index a32c48e..3558bd5 100644 (file)
@@ -140,6 +140,9 @@ BUGWK62698 SKIP : batterystatus = PASS FAIL
 // Touch Adjustment is not supported yet in the chromium port.
 BUGWK78801 SKIP : touchadjustment/ = FAIL
 
+// Network Information API is not supported yet in the chromium port.
+BUGWK73528 SKIP : networkinformation = PASS FAIL
+
 // -----------------------------------------------------------------
 // WONTFIX TESTS
 // -----------------------------------------------------------------
index 7d571ae..e24a0d4 100644 (file)
@@ -435,6 +435,9 @@ pointer-lock/
 #Battery Status API support not yet. http://webkit.org/b/62698
 batterystatus
 
+#Network Information API support not yet. http://webkit.org/b/73528
+networkinformation
+
 ###############################################################################
 # TESTS FAILING
 ###############################################################################
index 0b16f5b..5e30fac 100644 (file)
@@ -584,6 +584,9 @@ canvas/philip/tests/2d.shadow.image.transparent.2.html
 # Needs BatteryClient implementation.
 batterystatus/
 
+#Network Information is not supported yet. http://webkit.org/b/73528
+networkinformation
+
 # https://bugs.webkit.org/show_bug.cgi?id=43022
 tables/mozilla_expected_failures/bugs/bug85016.html
 
index b85e9f3..800002c 100644 (file)
@@ -383,6 +383,9 @@ fast/dom/navigator-vibration.html
 #Battery Status API is not implemented.
 batterystatus
 
+# Network Information API is not supported yet. http://webkit.org/b/73528
+networkinformation
+
 # =========================================================================== #
 #       Drag and Drop Support in DRT.                                         #
 # =========================================================================== #
index 2715ae2..6d1b709 100644 (file)
@@ -2074,3 +2074,6 @@ fast/dom/navigator-vibration.html
 
 #Battery Status API is not implemented.
 batterystatus
+
+# Network Information API is not supported yet. http://webkit.org/b/73528
+networkinformation
index d07fc13..c712e66 100644 (file)
@@ -1627,6 +1627,24 @@ IF (ENABLE_NETSCAPE_PLUGIN_API)
     )
 ENDIF ()
 
+IF (ENABLE_NETWORK_INFO)
+    LIST(APPEND WebCore_INCLUDE_DIRECTORIES
+         ${WEBCORE_DIR}/Modules/networkinfo
+    )
+
+    LIST(APPEND WebCore_SOURCES
+        Modules/networkinfo/NavigatorNetworkInfoConnection.cpp
+        Modules/networkinfo/NetworkInfo.cpp
+        Modules/networkinfo/NetworkInfoConnection.cpp
+        Modules/networkinfo/NetworkInfoController.cpp
+    )
+    LIST(APPEND WebCore_IDL_FILES
+        Modules/networkinfo/NavigatorNetworkInfoConnection.idl
+        Modules/networkinfo/NetworkInfoConnection.idl
+    )
+ENDIF ()
+
 IF (ENABLE_NOTIFICATIONS)
     LIST(APPEND WebCore_SOURCES
         notifications/DOMWindowNotifications.cpp
index 737ff59..ed28772 100644 (file)
@@ -1,3 +1,101 @@
+2012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Support the Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=73528
+
+        Reviewed by Adam Barth.
+
+        Network Information APIs is to provide an interface for Web Applications to access
+        the underlying network information of device. In Web Application case, they need to know
+        what current network interface it uses. Because, it is important to know current network
+        information(bandwidth, metered) in mobile domain. Thus, Web Application can let user know
+        whether current network information via this new functionality. In addition, in streaming
+        service case, Web Application can control content resolution according to kind of network.
+
+        http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/index.html
+
+        Tests: networkinformation/add-listener-from-callback.html
+               networkinformation/basic-all-types-of-events.html
+               networkinformation/basic-operation.html
+               networkinformation/event-after-navigation.html
+               networkinformation/multiple-frames.html
+               networkinformation/updates.html
+               networkinformation/window-property.html
+
+        * CMakeLists.txt:
+        * Modules/networkinfo/NavigatorNetworkInfoConnection.cpp: Added.
+        (WebCore):
+        (WebCore::NavigatorNetworkInfoConnection::NavigatorNetworkInfoConnection):
+        (WebCore::NavigatorNetworkInfoConnection::~NavigatorNetworkInfoConnection):
+        (WebCore::NavigatorNetworkInfoConnection::from):
+        (WebCore::NavigatorNetworkInfoConnection::webkitConnection):
+        * Modules/networkinfo/NavigatorNetworkInfoConnection.h: Added.
+        (WebCore):
+        (NavigatorNetworkInfoConnection):
+        * Modules/networkinfo/NavigatorNetworkInfoConnection.idl: Added.
+        * Modules/networkinfo/NetworkInfo.cpp: Added.
+        (WebCore):
+        (WebCore::NetworkInfo::NetworkInfo):
+        * Modules/networkinfo/NetworkInfo.h: Added.
+        (WebCore):
+        (NetworkInfo):
+        (WebCore::NetworkInfo::create):
+        (WebCore::NetworkInfo::bandwidth):
+        (WebCore::NetworkInfo::metered):
+        * Modules/networkinfo/NetworkInfoClient.h: Added.
+        (WebCore):
+        (NetworkInfoClient):
+        (WebCore::NetworkInfoClient::~NetworkInfoClient):
+        * Modules/networkinfo/NetworkInfoConnection.cpp: Added.
+        (WebCore):
+        (WebCore::NetworkInfoConnection::create):
+        (WebCore::NetworkInfoConnection::NetworkInfoConnection):
+        (WebCore::NetworkInfoConnection::~NetworkInfoConnection):
+        (WebCore::NetworkInfoConnection::bandwidth):
+        (WebCore::NetworkInfoConnection::metered):
+        (WebCore::NetworkInfoConnection::didChangeNetworkInformation):
+        (WebCore::NetworkInfoConnection::addEventListener):
+        (WebCore::NetworkInfoConnection::removeEventListener):
+        (WebCore::NetworkInfoConnection::eventTargetData):
+        (WebCore::NetworkInfoConnection::ensureEventTargetData):
+        (WebCore::NetworkInfoConnection::interfaceName):
+        (WebCore::NetworkInfoConnection::suspend):
+        (WebCore::NetworkInfoConnection::resume):
+        (WebCore::NetworkInfoConnection::stop):
+        * Modules/networkinfo/NetworkInfoConnection.h: Added.
+        (WebCore):
+        (NetworkInfoConnection):
+        (WebCore::NetworkInfoConnection::scriptExecutionContext):
+        (WebCore::NetworkInfoConnection::canSuspend):
+        (WebCore::NetworkInfoConnection::refEventTarget):
+        (WebCore::NetworkInfoConnection::derefEventTarget):
+        * Modules/networkinfo/NetworkInfoConnection.idl: Added.
+        * Modules/networkinfo/NetworkInfoController.cpp: Added.
+        (WebCore):
+        (WebCore::NetworkInfoController::NetworkInfoController):
+        (WebCore::NetworkInfoController::~NetworkInfoController):
+        (WebCore::NetworkInfoController::create):
+        (WebCore::NetworkInfoController::addListener):
+        (WebCore::NetworkInfoController::removeListener):
+        (WebCore::NetworkInfoController::didChangeNetworkInformation):
+        (WebCore::NetworkInfoController::isActive):
+        (WebCore::NetworkInfoController::supplementName):
+        (WebCore::provideNetworkInfoTo):
+        * Modules/networkinfo/NetworkInfoController.h: Added.
+        (WebCore):
+        (NetworkInfoController):
+        (WebCore::NetworkInfoController::client):
+        (WebCore::NetworkInfoController::from):
+        * dom/EventNames.h:
+        (WebCore):
+        * dom/EventTargetFactory.in:
+        * testing/Internals.cpp:
+        (WebCore::Internals::setNetworkInformation):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-04-01  Leo Yang  <leo.yang@torchmobile.com.cn>
 
         [BlackBerry] Use GraphicsContext::fillPath() and strokePath instead of drawPath() in RenderThemeBlackBerry
diff --git a/Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.cpp b/Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.cpp
new file mode 100644 (file)
index 0000000..c226d74
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 "NavigatorNetworkInfoConnection.h"
+
+#if ENABLE(NETWORK_INFO)
+
+#include "Frame.h"
+#include "Navigator.h"
+#include "NetworkInfoController.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+NavigatorNetworkInfoConnection::NavigatorNetworkInfoConnection()
+{
+}
+
+NavigatorNetworkInfoConnection::~NavigatorNetworkInfoConnection()
+{
+}
+
+NavigatorNetworkInfoConnection* NavigatorNetworkInfoConnection::from(Navigator* navigator)
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("NavigatorNetworkInfoConnection"));
+    NavigatorNetworkInfoConnection* supplement = static_cast<NavigatorNetworkInfoConnection*>(Supplement<Navigator>::from(navigator, name));
+    if (!supplement) {
+        supplement = new NavigatorNetworkInfoConnection();
+        provideTo(navigator, name, adoptPtr(supplement));
+    }
+    return supplement;
+}
+
+NetworkInfoConnection* NavigatorNetworkInfoConnection::webkitConnection(Navigator* navigator)
+{
+    if (!navigator->frame())
+        return 0;
+
+    NavigatorNetworkInfoConnection* navigatorConnection = NavigatorNetworkInfoConnection::from(navigator);
+    if (!navigatorConnection->m_connection)
+        navigatorConnection->m_connection = NetworkInfoConnection::create(navigator);
+    return navigatorConnection->m_connection.get();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(NETWORK_INFO)
diff --git a/Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.h b/Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.h
new file mode 100644 (file)
index 0000000..8f227ce
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 NavigatorNetworkInfoConnection_h
+#define NavigatorNetworkInfoConnection_h
+
+#if ENABLE(NETWORK_INFO)
+
+#include "NetworkInfoConnection.h"
+#include "Supplementable.h"
+
+namespace WebCore {
+
+class Navigator;
+
+class NavigatorNetworkInfoConnection : public Supplement<Navigator> {
+public:
+    virtual ~NavigatorNetworkInfoConnection();
+
+    static NavigatorNetworkInfoConnection* from(Navigator*);
+    static NetworkInfoConnection* webkitConnection(Navigator*);
+
+private:
+    NavigatorNetworkInfoConnection();
+
+    RefPtr<NetworkInfoConnection> m_connection;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(NETWORK_INFO)
+
+#endif // NavigatorNetworkInfoConnection_h
diff --git a/Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.idl b/Source/WebCore/Modules/networkinfo/NavigatorNetworkInfoConnection.idl
new file mode 100644 (file)
index 0000000..f61d0f3
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+module window {
+
+    interface [
+        Conditional=NETWORK_INFO,
+        Supplemental=Navigator
+    ] NavigatorNetworkInfoConnection {
+        readonly attribute NetworkInfoConnection webkitConnection;
+    };
+
+}
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfo.cpp b/Source/WebCore/Modules/networkinfo/NetworkInfo.cpp
new file mode 100644 (file)
index 0000000..a627a19
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NetworkInfo.h"
+
+#if ENABLE(NETWORK_INFO)
+namespace WebCore {
+
+NetworkInfo::NetworkInfo(long bandwidth, bool metered)
+    : m_bandwidth(bandwidth)
+    , m_metered(metered)
+{
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfo.h b/Source/WebCore/Modules/networkinfo/NetworkInfo.h
new file mode 100644 (file)
index 0000000..d91b675
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NetworkInfo_h
+#define NetworkInfo_h
+
+#if ENABLE(NETWORK_INFO)
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class NetworkInfo : public RefCounted<NetworkInfo> {
+public:
+    static PassRefPtr<NetworkInfo> create(long bandwidth, bool metered) { return adoptRef(new NetworkInfo(bandwidth, metered)); }
+
+    long bandwidth() const { return m_bandwidth; }
+    bool metered() const { return m_metered; }
+
+private:
+    NetworkInfo(long bandwidth, bool metered);
+
+    long m_bandwidth;
+    bool m_metered;
+};
+
+} // namespace WebCore
+
+#endif
+#endif // NetworkInfoConnection_h
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoClient.h b/Source/WebCore/Modules/networkinfo/NetworkInfoClient.h
new file mode 100644 (file)
index 0000000..729118e
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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. ``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
+ * 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 NetworkInfoClient_h
+#define NetworkInfoClient_h
+
+#if ENABLE(NETWORK_INFO)
+
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class NetworkInfoController;
+class Page;
+
+class NetworkInfoClient : public RefCounted<NetworkInfoClient> {
+public:
+    virtual ~NetworkInfoClient() { }
+
+    virtual unsigned int bandwidth() const = 0;
+    virtual bool metered() const = 0;
+   
+    virtual void startUpdating() = 0;
+    virtual void stopUpdating() = 0;
+};
+
+void provideNetworkInfoTo(Page*, NetworkInfoClient*);
+
+}
+
+#endif // ENABLE(NETWORK_INFO)
+
+#endif // NetworkInfoClient_h
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp
new file mode 100644 (file)
index 0000000..13f52ab
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NetworkInfoConnection.h"
+
+#if ENABLE(NETWORK_INFO)
+#include "Event.h"
+#include "Frame.h"
+#include "NetworkInfoClient.h"
+
+namespace WebCore {
+
+PassRefPtr<NetworkInfoConnection> NetworkInfoConnection::create(Navigator* navigator)
+{
+    RefPtr<NetworkInfoConnection> networkInfoConnection(adoptRef(new NetworkInfoConnection(navigator)));
+    networkInfoConnection->suspendIfNeeded();
+    return networkInfoConnection.release();
+}
+
+NetworkInfoConnection::NetworkInfoConnection(Navigator* navigator)
+    : ActiveDOMObject(navigator->frame()->document(), this)
+    , m_controller(NetworkInfoController::from(navigator->frame()->page()))
+    , m_networkInfo(0)
+{
+    m_controller->addListener(this);
+}
+
+NetworkInfoConnection::~NetworkInfoConnection()
+{
+}
+
+unsigned int NetworkInfoConnection::bandwidth() const
+{
+    if (m_networkInfo)
+        return m_networkInfo->bandwidth();
+    
+    return m_controller->client()->bandwidth();
+}
+
+bool NetworkInfoConnection::metered() const
+{
+    if (m_networkInfo)
+        return m_networkInfo->metered();
+    
+    return m_controller->client()->metered();
+}
+
+void NetworkInfoConnection::didChangeNetworkInformation(PassRefPtr<Event> event, PassRefPtr<NetworkInfo> networkInfo)
+{
+    m_networkInfo = networkInfo;
+    dispatchEvent(event);
+}
+
+EventTargetData* NetworkInfoConnection::eventTargetData()
+{
+    return &m_eventTargetData;
+}
+
+EventTargetData* NetworkInfoConnection::ensureEventTargetData()
+{
+    return &m_eventTargetData;
+}
+
+const AtomicString& NetworkInfoConnection::interfaceName() const
+{
+    return eventNames().interfaceForNetworkInfoConnection;
+}
+
+void NetworkInfoConnection::suspend(ReasonForSuspension)
+{
+    if (m_controller)
+        m_controller->removeListener(this);
+}
+
+void NetworkInfoConnection::resume()
+{
+    if (m_controller)
+        m_controller->addListener(this);
+}
+
+void NetworkInfoConnection::stop()
+{
+    if (m_controller)
+        m_controller->removeListener(this);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h
new file mode 100644 (file)
index 0000000..ea7ab8a
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NetworkInfoConnection_h
+#define NetworkInfoConnection_h
+
+#if ENABLE(NETWORK_INFO)
+#include "ActiveDOMObject.h"
+#include "EventListener.h"
+#include "EventTarget.h"
+#include "Navigator.h"
+#include "NetworkInfo.h"
+#include "NetworkInfoController.h"
+#include "PlatformString.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class NetworkInfoController;
+
+class NetworkInfoConnection : public RefCounted<NetworkInfoConnection>, public EventTarget, public ActiveDOMObject {
+public:
+    static PassRefPtr<NetworkInfoConnection> create(Navigator*);
+
+    ~NetworkInfoConnection();
+
+    unsigned int bandwidth() const;
+    bool metered() const;
+    
+    void didChangeNetworkInformation(PassRefPtr<Event>, PassRefPtr<NetworkInfo>);
+
+    // EventTarget implementation.
+    virtual const AtomicString& interfaceName() const;
+    virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
+
+    using RefCounted<NetworkInfoConnection>::ref;
+    using RefCounted<NetworkInfoConnection>::deref;
+
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitnetworkinfochange);
+  
+    // ActiveDOMObject implementation.
+    virtual bool canSuspend() const { return true; }
+    virtual void suspend(ReasonForSuspension);
+    virtual void resume();
+    virtual void stop();
+
+private:
+    explicit NetworkInfoConnection(Navigator*);
+
+    // EventTarget implementation.
+    virtual EventTargetData* eventTargetData();
+    virtual EventTargetData* ensureEventTargetData();
+    virtual void refEventTarget() { ref(); }
+    virtual void derefEventTarget() { deref(); }
+
+    // EventTarget implementation.
+    EventTargetData m_eventTargetData;
+
+    NetworkInfoController* m_controller;
+    RefPtr<NetworkInfo> m_networkInfo; 
+};
+
+} // namespace WebCore
+
+#endif
+#endif // NetworkInfoConnection_h
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.idl b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.idl
new file mode 100644 (file)
index 0000000..8e56efa
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. All Rights Reserved.
+ *
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+module window {
+
+    // http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/index.html
+    interface [
+        Conditional=NETWORK_INFO,
+        ActiveDOMObject,
+        EventTarget
+    ] NetworkInfoConnection {
+        readonly attribute double bandwidth;
+        readonly attribute boolean metered;
+
+        attribute EventListener onwebkitnetworkinfochange;
+
+        // EventTarget interface
+        void addEventListener(in DOMString type, 
+                              in EventListener listener, 
+                              in [Optional] boolean useCapture);
+        void removeEventListener(in DOMString type, 
+                                 in EventListener listener, 
+                                 in [Optional] boolean useCapture);
+        boolean dispatchEvent(in Event evt)
+            raises(EventException);
+    };
+}
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoController.cpp b/Source/WebCore/Modules/networkinfo/NetworkInfoController.cpp
new file mode 100644 (file)
index 0000000..aa695ec
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NetworkInfoController.h"
+
+#if ENABLE(NETWORK_INFO)
+#include "Event.h"
+#include "NetworkInfo.h"
+#include "NetworkInfoClient.h"
+
+namespace WebCore {
+
+NetworkInfoController::NetworkInfoController(Page* page, NetworkInfoClient* client)
+    : m_page(page)
+    , m_client(client)
+{
+}
+
+NetworkInfoController::~NetworkInfoController()
+{
+}
+
+PassOwnPtr<NetworkInfoController> NetworkInfoController::create(Page* page, NetworkInfoClient* client)
+{
+    return adoptPtr(new NetworkInfoController(page, client));
+}
+
+void NetworkInfoController::addListener(NetworkInfoConnection* networkInfoConnection)
+{
+     m_listeners.append(networkInfoConnection);
+     m_client->startUpdating();
+}
+
+void NetworkInfoController::removeListener(NetworkInfoConnection* networkInfoConnection)
+{
+     size_t position = m_listeners.find(networkInfoConnection);
+     if (position == WTF::notFound)
+         return;
+     m_listeners.remove(position);
+     if (m_listeners.isEmpty())
+         m_client->stopUpdating();
+}
+
+void NetworkInfoController::didChangeNetworkInformation(const AtomicString& eventType, PassRefPtr<NetworkInfo> networkInfo)
+{
+     RefPtr<Event> event = Event::create(eventType, false, false);
+     RefPtr<NetworkInfo> networkInformation = networkInfo;
+     for (NetworkInfoListenerList::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
+         (*it)->didChangeNetworkInformation(event, networkInformation);
+}
+
+const AtomicString& NetworkInfoController::supplementName()
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("NetworkInfoController"));
+    return name;
+}
+
+void provideNetworkInfoTo(Page* page, NetworkInfoClient* client)
+{
+    NetworkInfoController::provideTo(page, NetworkInfoController::supplementName(), NetworkInfoController::create(page, client));
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoController.h b/Source/WebCore/Modules/networkinfo/NetworkInfoController.h
new file mode 100644 (file)
index 0000000..4e6283b
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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. ``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
+ * 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 NetworkInfoController_h
+#define NetworkInfoController_h
+
+#if ENABLE(NETWORK_INFO)
+#include "NetworkInfoClient.h"
+#include "NetworkInfoConnection.h"
+#include "Page.h"
+
+namespace WebCore {
+
+class NetworkInfo;
+class NetworkInfoConnection;
+
+class NetworkInfoController : public Supplement<Page> {
+public:
+    ~NetworkInfoController();
+
+    NetworkInfoClient* client() { return m_client; }
+
+    static PassOwnPtr<NetworkInfoController> create(Page*, NetworkInfoClient*);
+
+    static const AtomicString& supplementName();
+    static NetworkInfoController* from(Page* page) { return static_cast<NetworkInfoController*>(Supplement<Page>::from(page, supplementName())); }
+   
+    void addListener(NetworkInfoConnection*);
+    void removeListener(NetworkInfoConnection*);
+
+    void didChangeNetworkInformation(const AtomicString& eventType, PassRefPtr<NetworkInfo>);
+
+private:
+    NetworkInfoController(Page*, NetworkInfoClient*);
+
+    typedef Vector<NetworkInfoConnection*> NetworkInfoListenerList;
+
+    Page* m_page;
+    NetworkInfoClient* m_client;
+    NetworkInfoListenerList m_listeners;
+};
+
+}
+
+#endif // ENABLE(NETWORK_INFO)
+#endif // NetworkInfoController_h
index 6e22b73..a65a52c 100644 (file)
@@ -218,6 +218,8 @@ namespace WebCore {
     \
     macro(webkitRegionLayoutUpdate) \
     \
+    macro(webkitnetworkinfochange) \
+    \
 
 // end of DOM_EVENT_NAMES_FOR_EACH
 
index 280d394..f01b811 100644 (file)
@@ -18,6 +18,7 @@ LocalMediaStream conditional=MEDIA_STREAM
 MediaController conditional=VIDEO
 MediaStream conditional=MEDIA_STREAM
 MessagePort
+NetworkInfoConnection conditional=NETWORK_INFO
 Node
 Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS
 PeerConnection00 conditional=MEDIA_STREAM
index 2a7244c..108a396 100644 (file)
 #include "BatteryController.h"
 #endif
 
+#if ENABLE(NETWORK_INFO)
+#include "NetworkInfo.h"
+#include "NetworkInfoController.h"
+#endif
+
 #if ENABLE(TOUCH_ADJUSTMENT)
 #include "EventHandler.h"
 #include "WebKitPoint.h"
@@ -826,6 +831,22 @@ void Internals::setBatteryStatus(Document* document, const String& eventType, bo
 #endif
 }
 
+void Internals::setNetworkInformation(Document* document, const String& eventType, long bandwidth, bool metered, ExceptionCode& ec)
+{
+    if (!document || !document->page()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+#if ENABLE(NETWORK_INFO)
+    NetworkInfoController::from(document->page())->didChangeNetworkInformation(eventType, NetworkInfo::create(bandwidth, metered));
+#else
+    UNUSED_PARAM(eventType);
+    UNUSED_PARAM(bandwidth);
+    UNUSED_PARAM(metered);
+#endif
+}
+
 bool Internals::hasSpellingMarker(Document* document, int from, int length, ExceptionCode&)
 {
     if (!document || !document->frame())
index 05f949c..87b8761 100644 (file)
@@ -153,6 +153,8 @@ public:
 
     void setBatteryStatus(Document*, const String& eventType, bool charging, double chargingTime, double dischargingTime, double level, ExceptionCode&);
 
+    void setNetworkInformation(Document*, const String& eventType, long bandwidth, bool metered, ExceptionCode&);
+
 #if ENABLE(INSPECTOR)
     unsigned numberOfLiveNodes() const;
     unsigned numberOfLiveDocuments() const;
index ba73634..8822e25 100644 (file)
@@ -129,6 +129,10 @@ module window {
         void setBatteryStatus(in Document document, in DOMString eventType, in boolean charging, in double chargingTime, in double dischargingTime, in double level) raises (DOMException);
 #endif 
 
+#if defined(ENABLE_NETWORK_INFO) && ENABLE_NETWORK_INFO
+        void setNetworkInformation(in Document document, in DOMString eventType, in long bandwidth, in boolean metered) raises (DOMException);
+#endif
+
         [Conditional=INSPECTOR] unsigned long numberOfLiveNodes();
         [Conditional=INSPECTOR] unsigned long numberOfLiveDocuments();
     };
index 7592f99..1b61704 100644 (file)
@@ -1,3 +1,12 @@
+2012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Support the Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=73528
+
+        Reviewed by Adam Barth.
+
+        * PlatformEfl.cmake: Add dummy NetworkInfoClientEfl.cpp files in order to support network information API.
+
 2012-03-30  Eli Fidler  <efidler@rim.com>
 
         Enable OpenType Sanitizer for BlackBerry port.
index 10010c9..54e7d91 100644 (file)
@@ -60,6 +60,15 @@ IF (WTF_USE_PANGO)
   )
 ENDIF ()
 
+IF (ENABLE_NETWORK_INFO)
+  LIST(APPEND WebKit_INCLUDE_DIRECTORIES
+    "${WEBCORE_DIR}/Modules/networkinfo"
+  )
+  LIST(APPEND WebKit_SOURCES
+    efl/WebCoreSupport/NetworkInfoClientEfl.cpp
+  )
+ENDIF ()
+
 IF (ENABLE_NOTIFICATIONS)
   LIST(APPEND WebKit_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/notifications"
index 3f5b8aa..39fe4ed 100644 (file)
@@ -1,3 +1,27 @@
+2012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Support the Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=73528
+
+        Reviewed by Adam Barth.
+
+        Add NetworkInfoClientEfl to support network information API. However,
+        functions are not implemented yet.
+
+        * WebCoreSupport/NetworkInfoClientEfl.cpp: Added.
+        (WebCore::NetworkInfoClientEfl::NetworkInfoClientEfl):
+        (WebCore):
+        (WebCore::NetworkInfoClientEfl::~NetworkInfoClientEfl):
+        (WebCore::NetworkInfoClientEfl::startUpdating):
+        (WebCore::NetworkInfoClientEfl::stopUpdating):
+        (WebCore::NetworkInfoClientEfl::bandwidth):
+        (WebCore::NetworkInfoClientEfl::metered):
+        * WebCoreSupport/NetworkInfoClientEfl.h: Added.
+        (NetworkInfoClientEfl):
+        * ewk/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_ewk_view_priv_new):
+
 2012-03-30  Patrick Gansterer  <paroga@webkit.org>
 
         [EFL] Correct <wtf/*.h> include paths.
diff --git a/Source/WebKit/efl/WebCoreSupport/NetworkInfoClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/NetworkInfoClientEfl.cpp
new file mode 100644 (file)
index 0000000..66d5a00
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NetworkInfoClientEfl.h"
+
+#if ENABLE(NETWORK_INFO)
+#include "NetworkInfo.h"
+#include "NotImplemented.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+NetworkInfoClientEfl::NetworkInfoClientEfl()
+    : m_controller(0)
+{
+}
+
+NetworkInfoClientEfl::~NetworkInfoClientEfl()
+{
+}
+
+void NetworkInfoClientEfl::startUpdating()
+{
+    notImplemented();
+}
+
+void NetworkInfoClientEfl::stopUpdating()
+{
+    notImplemented();
+}
+
+unsigned int NetworkInfoClientEfl::bandwidth() const
+{
+    notImplemented();
+    return 10; // MB/s
+}
+
+bool NetworkInfoClientEfl::metered() const
+{
+    notImplemented();
+    return false;
+}
+
+}
+#endif
diff --git a/Source/WebKit/efl/WebCoreSupport/NetworkInfoClientEfl.h b/Source/WebKit/efl/WebCoreSupport/NetworkInfoClientEfl.h
new file mode 100644 (file)
index 0000000..9797103
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * 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.
+ * 3.  Neither the name of Apple, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NetworkInfoClientEfl_h
+#define NetworkInfoClientEfl_h
+
+#include "NetworkInfoClient.h"
+#include "NetworkInfoController.h"
+
+namespace WebCore {
+class NetworkInfoClientEfl : public WebCore::NetworkInfoClient {
+public:
+    NetworkInfoClientEfl();
+    ~NetworkInfoClientEfl();
+    
+    virtual void startUpdating();
+    virtual void stopUpdating();
+
+    virtual unsigned int bandwidth() const;
+    virtual bool metered() const;
+
+private:
+
+    NetworkInfoController* m_controller;
+};
+}
+
+#endif // NetworkInfoClientEfl_h
index 26b555c..2d42a32 100644 (file)
 #include "NotImplemented.h"
 #endif
 
+#if ENABLE(NETWORK_INFO)
+#include "NetworkInfoClientEfl.h"
+#endif
+
 static const float zoomMinimum = 0.05;
 static const float zoomMaximum = 4.0;
 
@@ -624,6 +628,10 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
     WebCore::provideDeviceOrientationTo(priv->page.get(), new WebCore::DeviceOrientationClientEfl);
 #endif
 
+#if ENABLE(NETWORK_INFO)
+    WebCore::provideNetworkInfoTo(priv->page.get(), new WebCore::NetworkInfoClientEfl);
+#endif
+
 #if ENABLE(VIBRATION)
     WebCore::provideVibrationTo(priv->page.get(), new WebCore::VibrationClientEfl(smartData->self));
 #endif
index 5d03ac7..5926f40 100644 (file)
@@ -87,6 +87,7 @@ WEBKIT_FEATURE(ENABLE_METER_TAG "Enable Meter tag" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_MICRODATA "Enable HTML5 microdata support" DEFAULT OFF)
 WEBKIT_FEATURE(ENABLE_MUTATION_OBSERVERS "Enable HTML5 mutation observers support" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_NETSCAPE_PLUGIN_API "Enable Netscape plugin API" DEFAULT OFF)
+WEBKIT_FEATURE(ENABLE_NETWORK_INFO "Enable Network Information API" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_NOTIFICATIONS "Enable notifications" DEFAULT OFF)
 WEBKIT_FEATURE(ENABLE_ORIENTATION_EVENTS "Enable orientation events" DEFAULT OFF)
 WEBKIT_FEATURE(ENABLE_PAGE_VISIBILITY_API "Enable Page Visibility API" DEFAULT ON)
index bd54af1..ed2770b 100644 (file)
@@ -47,6 +47,7 @@
 #cmakedefine01 ENABLE_MICRODATA
 #cmakedefine01 ENABLE_MUTATION_OBSERVERS
 #cmakedefine01 ENABLE_NETSCAPE_PLUGIN_API
+#cmakedefine01 ENABLE_NETWORK_INFO
 #cmakedefine01 ENABLE_NOTIFICATIONS
 #cmakedefine01 ENABLE_ORIENTATION_EVENTS
 #cmakedefine01 ENABLE_OVERFLOW_SCROLLING
index 7706458..5f68831 100644 (file)
@@ -1,3 +1,14 @@
+2012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Support the Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=73528
+
+        Reviewed by Adam Barth.
+
+        Add network information API feature to build script.
+
+        * Scripts/build-webkit:
+
 2012-03-31  Ojan Vafai  <ojan@chromium.org>
 
         Generate the flakiness dashboard's list of webkit.org builders from the buildbot JSON
index 9198124..3f546b2 100755 (executable)
@@ -114,6 +114,7 @@ my (
     $microdataSupport,
     $mutationObserversSupport,
     $netscapePluginSupport,
+    $networkInfoSupport,
     $notificationsSupport,
     $orientationEventsSupport,
     $pageVisibilityApiSupport,
@@ -290,6 +291,9 @@ my @features = (
     { option => "netscape-plugin", desc => "Netscape Plugin support",
       define => "ENABLE_NETSCAPE_PLUGIN_API", default => !isEfl(), value => \$netscapePluginSupport },
 
+    { option => "network-info", desc => "Network Information API support",
+      define => "ENABLE_NETWORK_INFO", default => isEfl(), value => \$networkInfoSupport },
+
     { option => "notifications", desc => "Toggle Desktop Notifications Support",
       define => "ENABLE_NOTIFICATIONS", default => isBlackBerry(), value => \$notificationsSupport },