summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-04-17 13:21:53 +0100
committerBen Murdoch <benm@google.com>2009-06-05 12:39:02 +0100
commit6262ae5c9df44c0673cebaeaf7f655094f5b5485 (patch)
treed389d929f5de0f1928bc60950d650257e3d6a3e3
parent79525264e5a594f9d99ef7ca0b6ac8e8f47a6ac6 (diff)
downloadframeworks_base-6262ae5c9df44c0673cebaeaf7f655094f5b5485.zip
frameworks_base-6262ae5c9df44c0673cebaeaf7f655094f5b5485.tar.gz
frameworks_base-6262ae5c9df44c0673cebaeaf7f655094f5b5485.tar.bz2
Implement handling of console messages from WebCore. Default implementation in WebChromeClient is to do nothing.
-rw-r--r--core/java/android/webkit/CallbackProxy.java30
-rw-r--r--core/java/android/webkit/WebChromeClient.java11
-rw-r--r--core/java/android/webkit/WebViewCore.java10
3 files changed, 51 insertions, 0 deletions
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index 2fb6964..c407044 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -100,6 +100,7 @@ class CallbackProxy extends Handler {
private static final int SWITCH_OUT_HISTORY = 125;
private static final int EXCEEDED_DATABASE_QUOTA = 126;
private static final int JS_TIMEOUT = 127;
+ private static final int ADD_MESSAGE_TO_CONSOLE = 128;
// Message triggered by the client to resume execution
private static final int NOTIFY = 200;
@@ -581,6 +582,13 @@ class CallbackProxy extends Handler {
case SWITCH_OUT_HISTORY:
mWebView.switchOutDrawHistory();
break;
+
+ case ADD_MESSAGE_TO_CONSOLE:
+ String message = msg.getData().getString("message");
+ String sourceID = msg.getData().getString("sourceID");
+ int lineNumber = msg.getData().getInt("lineNumber");
+ mWebChromeClient.addMessageToConsole(message, lineNumber, sourceID);
+ break;
}
}
@@ -1087,6 +1095,28 @@ class CallbackProxy extends Handler {
}
/**
+ * Called by WebViewCore when we have a message to be added to the JavaScript
+ * error console. Sends a message to the Java side with the details.
+ * @param message The message to add to the console.
+ * @param lineNumber The lineNumber of the source file on which the error
+ * occurred.
+ * @param sourceID The filename of the source file in which the error
+ * occurred.
+ * @hide pending API counsel.
+ */
+ public void addMessageToConsole(String message, int lineNumber, String sourceID) {
+ if (mWebChromeClient == null) {
+ return;
+ }
+
+ Message msg = obtainMessage(ADD_MESSAGE_TO_CONSOLE);
+ msg.getData().putString("message", message);
+ msg.getData().putString("sourceID", sourceID);
+ msg.getData().putInt("lineNumber", lineNumber);
+ sendMessage(msg);
+ }
+
+ /**
* @hide pending API council approval
*/
public boolean onJsTimeout() {
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index bd64f89..754b1d9 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -189,4 +189,15 @@ public class WebChromeClient {
public boolean onJsTimeout() {
return true;
}
+
+ /**
+ * Add a JavaScript error message to the console. Clients should override
+ * this to process the log message as they see fit.
+ * @param message The error message to report.
+ * @param lineNumber The line number of the error.
+ * @param sourceID The name of the source file that caused the error.
+ * @hide pending API council.
+ */
+ public void addMessageToConsole(String message, int lineNumber, String sourceID) {
+ }
}
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index de142ae..f4b99b9 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -227,6 +227,16 @@ final class WebViewCore {
}
/**
+ * Add an error message to the client's console.
+ * @param message The message to add
+ * @param lineNumber the line on which the error occurred
+ * @param sourceID the filename of the source that caused the error.
+ */
+ protected void addMessageToConsole(String message, int lineNumber, String sourceID) {
+ mCallbackProxy.addMessageToConsole(message, lineNumber, sourceID);
+ }
+
+ /**
* Invoke a javascript alert.
* @param message The message displayed in the alert.
*/