diff options
author | Ben Murdoch <benm@google.com> | 2009-05-12 19:41:18 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-06-05 12:12:36 +0100 |
commit | bf22f208d6fb755dd4ddebbde1a1a3b23e597990 (patch) | |
tree | 92484dab0bec3b056d6f3df68ca2e9e046c37816 | |
parent | 3df5c413a68315c2771082a8e2deb3bdf814d6d9 (diff) | |
download | external_webkit-bf22f208d6fb755dd4ddebbde1a1a3b23e597990.zip external_webkit-bf22f208d6fb755dd4ddebbde1a1a3b23e597990.tar.gz external_webkit-bf22f208d6fb755dd4ddebbde1a1a3b23e597990.tar.bz2 |
Implement adding console messages
-rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 6 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 |
3 files changed, 17 insertions, 3 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index c4ff2f0..6e97ae5 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -143,10 +143,10 @@ bool ChromeClientAndroid::menubarVisible() { notImplemented(); return false; } void ChromeClientAndroid::setResizable(bool) { notImplemented(); } // This function is called by the JavaScript bindings to print usually an error to -// a message console. +// a message console. Pass the message to the java side so that the client can +// handle it as it sees fit. void ChromeClientAndroid::addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) { - notImplemented(); - LOGD("Console: %s line: %d source: %s\n", message.latin1().data(), lineNumber, sourceID.latin1().data()); + android::WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view())->addMessageToConsole(message, lineNumber, sourceID); } bool ChromeClientAndroid::canRunBeforeUnloadConfirmPanel() { return true; } diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 9563638..78681bc 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -169,6 +169,7 @@ struct WebViewCore::JavaGlue { jmethodID m_restoreScale; jmethodID m_needTouchEvents; jmethodID m_exceededDatabaseQuota; + jmethodID m_addMessageToConsole; AutoJObject object(JNIEnv* env) { return getRealObject(env, m_obj); } @@ -233,6 +234,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(I)V"); m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); m_javaGlue->m_exceededDatabaseQuota = GetJMethod(env, clazz, "exceededDatabaseQuota", "(Ljava/lang/String;Ljava/lang/String;J)V"); + m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V"); env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this); @@ -1787,6 +1789,16 @@ void WebViewCore::popupReply(const int* array, int count) } } +void WebViewCore::addMessageToConsole(const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceID) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jstring jMessageStr = env->NewString((unsigned short *)message.characters(), message.length()); + jstring jSourceIDStr = env->NewString((unsigned short *)sourceID.characters(), sourceID.length()); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_addMessageToConsole, jMessageStr, lineNumber, jSourceIDStr); + env->DeleteLocalRef(jMessageStr); + env->DeleteLocalRef(jSourceIDStr); + checkException(env); +} + void WebViewCore::jsAlert(const WebCore::String& url, const WebCore::String& text) { JNIEnv* env = JSC::Bindings::getJNIEnv(); diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 7f8aebd..c60a12c 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -179,6 +179,8 @@ namespace android { const WebCore::String& databaseIdentifier, const unsigned long long currentQuota); + void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID); + // // Followings support calls from Java to native WebCore // |