diff options
Diffstat (limited to 'WebCore/page')
-rw-r--r-- | WebCore/page/Connection.cpp | 39 | ||||
-rw-r--r-- | WebCore/page/Connection.h | 54 | ||||
-rw-r--r-- | WebCore/page/Connection.idl | 38 | ||||
-rw-r--r-- | WebCore/page/Navigator.cpp | 12 | ||||
-rw-r--r-- | WebCore/page/Navigator.h | 10 | ||||
-rw-r--r-- | WebCore/page/Navigator.idl | 3 |
6 files changed, 156 insertions, 0 deletions
diff --git a/WebCore/page/Connection.cpp b/WebCore/page/Connection.cpp new file mode 100644 index 0000000..ffbb838 --- /dev/null +++ b/WebCore/page/Connection.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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 "Connection.h" + +#include "NetworkStateNotifier.h" + +namespace WebCore { + +Connection::ConnectionType Connection::type() const +{ + return networkStateNotifier().type(); +} + +};
\ No newline at end of file diff --git a/WebCore/page/Connection.h b/WebCore/page/Connection.h new file mode 100644 index 0000000..837a36f --- /dev/null +++ b/WebCore/page/Connection.h @@ -0,0 +1,54 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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 Connection_h +#define Connection_h + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Connection : public RefCounted<Connection> { +public: + enum ConnectionType { + Unknown = 0, + Ethernet = 1, + WiFi = 2, + Cell_2G = 3, + Cell_3G = 4, + }; + + static PassRefPtr<Connection> create() { return adoptRef(new Connection()); } + + ConnectionType type() const; + +private: + Connection() { } +}; + +} // namespace WebCore + +#endif // Connection_h diff --git a/WebCore/page/Connection.idl b/WebCore/page/Connection.idl new file mode 100644 index 0000000..b4cfbd1 --- /dev/null +++ b/WebCore/page/Connection.idl @@ -0,0 +1,38 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. + */ + + module core { + + interface Connection { + readonly attribute unsigned short type; + + const unsigned short UNKNOWN = 0; + const unsigned short ETHERNET = 1; + const unsigned short WIFI = 2; + const unsigned short CELL_2G = 3; + const unsigned short CELL_3G = 4; + }; + +} diff --git a/WebCore/page/Navigator.cpp b/WebCore/page/Navigator.cpp index a4193fc..8563a0e 100644 --- a/WebCore/page/Navigator.cpp +++ b/WebCore/page/Navigator.cpp @@ -24,6 +24,9 @@ #include "Navigator.h" #include "CookieJar.h" +#if PLATFORM(ANDROID) +#include "Connection.h" +#endif #include "ExceptionCode.h" #include "Frame.h" #include "FrameLoader.h" @@ -155,6 +158,15 @@ Geolocation* Navigator::geolocation() const return m_geolocation.get(); } +#if PLATFORM(ANDROID) +Connection* Navigator::connection() const +{ + if (!m_connection) + m_connection = Connection::create(); + return m_connection.get(); +} +#endif + #if ENABLE(DOM_STORAGE) void Navigator::getStorageUpdates() { diff --git a/WebCore/page/Navigator.h b/WebCore/page/Navigator.h index 107082b..9967fba 100644 --- a/WebCore/page/Navigator.h +++ b/WebCore/page/Navigator.h @@ -27,6 +27,9 @@ namespace WebCore { +#if PLATFORM(ANDROID) + class Connection; +#endif class Frame; class Geolocation; class MimeTypeArray; @@ -57,6 +60,10 @@ namespace WebCore { // This is used for GC marking. Geolocation* optionalGeolocation() const { return m_geolocation.get(); } +#if PLATFORM(ANDROID) + Connection* connection() const; +#endif + #if ENABLE(DOM_STORAGE) // Relinquishes the storage lock, if one exists. void getStorageUpdates(); @@ -71,6 +78,9 @@ namespace WebCore { mutable RefPtr<PluginArray> m_plugins; mutable RefPtr<MimeTypeArray> m_mimeTypes; mutable RefPtr<Geolocation> m_geolocation; +#if PLATFORM(ANDROID) + mutable RefPtr<Connection> m_connection; +#endif }; } diff --git a/WebCore/page/Navigator.idl b/WebCore/page/Navigator.idl index 99b22af..f3079de 100644 --- a/WebCore/page/Navigator.idl +++ b/WebCore/page/Navigator.idl @@ -39,6 +39,9 @@ module window { readonly attribute boolean onLine; + // ANDROID-only for now, upstreaming in progress. + readonly attribute Connection connection; + #if defined(ENABLE_GEOLOCATION) && ENABLE_GEOLOCATION readonly attribute Geolocation geolocation; #endif |