summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/BrowserFrame.java
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-11-12 14:11:16 +0000
committerIain Merrick <husky@google.com>2010-11-15 11:18:39 +0000
commit83d4a23c280bdcaf6c301651b76ddc6fbf08949c (patch)
tree05053e1132837a6675fffcadaacf016d7f8b3668 /core/java/android/webkit/BrowserFrame.java
parent2f3496b424583204df93511e6ca9795d38637c5d (diff)
Provide default error strings in BrowserFrame.onReceivedError().
This method is called from both the Android and Chrome HTTP stacks. We want the same user-facing behaviour in each case, but the Chrome code does not have easy access to the same error message strings. Therefore, I'll have the Chrome HTTP stack provide empty strings for the descriptions. (See change I9042a2ee in external/webkit). This CL makes BrowserFrame check for empty or null strings and use the standard error messages instead. The strings were package-private, so I did a little cleaning up to make them public (but still hidden from the API). Using a switch statement instead of an array because it's more robust and should be comparably efficient. Bug: 3172265 Test: Load http://google.com:81 to force a timeout error, check that the correct message is displayed. Change-Id: I7dec8dffe8ad9e513fdb90877e0b466e707174a8
Diffstat (limited to 'core/java/android/webkit/BrowserFrame.java')
-rw-r--r--core/java/android/webkit/BrowserFrame.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index cce7914ccb85..ed5663e0f610 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -26,6 +26,7 @@ import android.graphics.Bitmap;
import android.net.ParseException;
import android.net.Uri;
import android.net.WebAddress;
+import android.net.http.ErrorStrings;
import android.net.http.SslCertificate;
import android.os.Handler;
import android.os.Message;
@@ -323,16 +324,20 @@ class BrowserFrame extends Handler {
* native callback
* Report an error to an activity.
* @param errorCode The HTTP error code.
- * @param description A String description.
+ * @param description Optional human-readable description. If no description
+ * is given, we'll use a standard localized error message.
+ * @param failingUrl The URL that was being loaded when the error occurred.
* TODO: Report all errors including resource errors but include some kind
* of domain identifier. Change errorCode to an enum for a cleaner
* interface.
*/
- private void reportError(final int errorCode, final String description,
- final String failingUrl) {
+ private void reportError(int errorCode, String description, String failingUrl) {
// As this is called for the main resource and loading will be stopped
// after, reset the state variables.
resetLoadingStates();
+ if (description == null || description.isEmpty()) {
+ description = ErrorStrings.getString(errorCode, mContext);
+ }
mCallbackProxy.onReceivedError(errorCode, description, failingUrl);
}