# page
GEN := \
$(intermediates)/page/JSBarInfo.h \
+ $(intermediates)/page/JSConnection.h \
$(intermediates)/page/JSConsole.h \
$(intermediates)/page/JSCoordinates.h \
$(intermediates)/page/JSDOMSelection.h \
# page
GEN := \
$(intermediates)/bindings/V8BarInfo.h \
+ $(intermediates)/bindings/V8Connection.h \
$(intermediates)/bindings/V8Console.h \
$(intermediates)/bindings/V8Coordinates.h \
$(intermediates)/bindings/V8DOMSelection.h \
\
page/BarInfo.cpp \
page/Chrome.cpp \
+ page/Connection.cpp \
page/Console.cpp \
page/ContextMenuController.cpp \
page/DOMSelection.cpp \
#endif // SVG
#if PLATFORM(ANDROID)
+#include "Connection.h"
// TODO: Upstream TOUCH_EVENTS guard.
#if ENABLE(TOUCH_EVENTS)
#include "Touch.h"
#include "V8PositionError.h"
#if PLATFORM(ANDROID)
+#include "V8Connection.h"
// TODO: Upstream these guards to webkit.org
#if ENABLE(TOUCH_EVENTS)
#include "V8Touch.h"
#else
#define DOM_OBJECT_TOUCH_EVENT_TYPES(V)
#endif
+#define DOM_OBJECT_CONNECTION_TYPES(V) \
+ V(CONNECTION, Connection)
#endif
#if PLATFORM(ANDROID)
DOM_OBJECT_INSPECTOR_TYPES(V) \
DOM_OBJECT_GEOLOCATION_TYPES(V) \
DOM_OBJECT_TOUCH_EVENT_TYPES(V) \
+ DOM_OBJECT_CONNECTION_TYPES(V) \
DOM_OBJECT_VOIDCALLBACK_TYPES(V)
#endif
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+ };
+
+}
#include "Navigator.h"
#include "CookieJar.h"
+#if PLATFORM(ANDROID)
+#include "Connection.h"
+#endif
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoader.h"
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()
{
namespace WebCore {
+#if PLATFORM(ANDROID)
+ class Connection;
+#endif
class Frame;
class Geolocation;
class MimeTypeArray;
// 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();
mutable RefPtr<PluginArray> m_plugins;
mutable RefPtr<MimeTypeArray> m_mimeTypes;
mutable RefPtr<Geolocation> m_geolocation;
+#if PLATFORM(ANDROID)
+ mutable RefPtr<Connection> m_connection;
+#endif
};
}
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
#define NetworkStateNotifier_h
#include <wtf/Noncopyable.h>
+#if PLATFORM(ANDROID)
+#include "Connection.h"
+#endif
#if PLATFORM(MAC)
void setNetworkStateChangedFunction(void (*)());
bool onLine() const { return m_isOnLine; }
+#if PLATFORM(ANDROID)
+ Connection::ConnectionType type() const { return m_type; }
+#endif
private:
bool m_isOnLine;
+#if PLATFORM(ANDROID)
+ Connection::ConnectionType m_type;
+#endif
void (*m_networkStateChangedFunction)();
void updateState();
#elif PLATFORM(ANDROID)
public:
void networkStateChange(bool online);
+ void networkTypeChange(Connection::ConnectionType type);
#endif
};
inline NetworkStateNotifier::NetworkStateNotifier()
: m_isOnLine(true)
+#if PLATFORM(ANDROID)
+ , m_type(Connection::Unknown)
+#endif
, m_networkStateChangedFunction(0)
{
}
m_networkStateChangedFunction();
}
+void NetworkStateNotifier::networkTypeChange(Connection::ConnectionType type)
+{
+ if (m_type == type)
+ return;
+
+ m_type = type;
+
+ if (m_networkStateChangedFunction)
+ m_networkStateChangedFunction();
+}
+
}
#include <config.h>
#include <wtf/Platform.h>
+#include <wtf/StdLibExtras.h>
+#include "AtomicString.h"
#include "Cache.h"
+#include "Connection.h"
#include "CookieClient.h"
#include "JavaSharedClient.h"
#include "KeyGeneratorClient.h"
static void SharedTimerFired(JNIEnv* env, jobject);
static void SetCacheSize(JNIEnv* env, jobject obj, jint bytes);
static void SetNetworkOnLine(JNIEnv* env, jobject obj, jboolean online);
+ static void SetNetworkType(JNIEnv* env, jobject obj, jstring type, jstring subtype);
static void SetDeferringTimers(JNIEnv* env, jobject obj, jboolean defer);
static void ServiceFuncPtrQueue(JNIEnv*);
static void UpdatePluginDirectories(JNIEnv* env, jobject obj, jobjectArray array, jboolean reload);
WebCore::networkStateNotifier().networkStateChange(online);
}
+void JavaBridge::SetNetworkType(JNIEnv* env, jobject obj, jstring javatype, jstring javasubtype)
+{
+ DEFINE_STATIC_LOCAL(AtomicString, wifi, ("wifi"));
+ DEFINE_STATIC_LOCAL(AtomicString, mobile, ("mobile"));
+ DEFINE_STATIC_LOCAL(AtomicString, mobileSupl, ("mobile_supl"));
+ DEFINE_STATIC_LOCAL(AtomicString, gprs, ("gprs"));
+ DEFINE_STATIC_LOCAL(AtomicString, edge, ("edge"));
+ DEFINE_STATIC_LOCAL(AtomicString, umts, ("umts"));
+
+ String type = to_string(env, javatype);
+ String subtype = to_string(env, javasubtype);
+ Connection::ConnectionType connectionType = Connection::Unknown;
+ if (type == wifi)
+ connectionType = Connection::WiFi;
+ else if (type == mobile || type == mobileSupl) {
+ if (subtype == edge || subtype == gprs)
+ connectionType = Connection::Cell_2G;
+ else if (subtype == umts)
+ connectionType = Connection::Cell_3G;
+ }
+ WebCore::networkStateNotifier().networkTypeChange(connectionType);
+}
+
void JavaBridge::ServiceFuncPtrQueue(JNIEnv*)
{
JavaSharedClient::ServiceFunctionPtrQueue();
(void*) JavaBridge::SetCacheSize },
{ "setNetworkOnLine", "(Z)V",
(void*) JavaBridge::SetNetworkOnLine },
+ { "setNetworkType", "(Ljava/lang/String;Ljava/lang/String;)V",
+ (void*) JavaBridge::SetNetworkType },
{ "nativeServiceFuncPtrQueue", "()V",
(void*) JavaBridge::ServiceFuncPtrQueue },
{ "nativeUpdatePluginDirectories", "([Ljava/lang/String;Z)V",