Upstream version 6.35.131.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core / src / org / xwalk / core / XWalkResourceClient.java
index 4490600..63fa3a7 100644 (file)
@@ -4,12 +4,57 @@
 
 package org.xwalk.core;
 
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.View;
 import android.webkit.WebResourceResponse;
 
 /**
- * This interface notifies the embedder resource events/callbacks.
+ * This class notifies the embedder resource events/callbacks.
  */
 public class XWalkResourceClient {
+    /** Success */
+    public static final int ERROR_OK = 0;
+    /** Generic error */
+    public static final int ERROR_UNKNOWN = -1;
+    /** Server or proxy hostname lookup failed */
+    public static final int ERROR_HOST_LOOKUP = -2;
+    /** Unsupported authentication scheme (not basic or digest) */
+    public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;
+    /** User authentication failed on server */
+    public static final int ERROR_AUTHENTICATION = -4;
+    /** User authentication failed on proxy */
+    public static final int ERROR_PROXY_AUTHENTICATION = -5;
+    /** Failed to connect to the server */
+    public static final int ERROR_CONNECT = -6;
+    /** Failed to read or write to the server */
+    public static final int ERROR_IO = -7;
+    /** Connection timed out */
+    public static final int ERROR_TIMEOUT = -8;
+    /** Too many redirects */
+    public static final int ERROR_REDIRECT_LOOP = -9;
+    /** Unsupported URI scheme */
+    public static final int ERROR_UNSUPPORTED_SCHEME = -10;
+    /** Failed to perform SSL handshake */
+    public static final int ERROR_FAILED_SSL_HANDSHAKE = -11;
+    /** Malformed URL */
+    public static final int ERROR_BAD_URL = -12;
+    /** Generic file error */
+    public static final int ERROR_FILE = -13;
+    /** File not found */
+    public static final int ERROR_FILE_NOT_FOUND = -14;
+    /** Too many requests during this load */
+    public static final int ERROR_TOO_MANY_REQUESTS = -15;
+
+    /**
+     * Constructor.
+     * @param view the owner XWalkView instance.
+     */
+    public XWalkResourceClient(XWalkView view) {
+        // Keep the above parameter for future use.
+    }
+
     /**
      * Notify the client that the XWalkView will load the resource specified
      * by the given url.
@@ -31,7 +76,7 @@ public class XWalkResourceClient {
     /**
      * Notify the client the progress info of loading a specific url.
      * @param view the owner XWalkView instance.
-     * @param url the loading process in percent.
+     * @param progressInPercent the loading process in percent.
      */
     public void onProgressChanged(XWalkView view, int progressInPercent) {
     }
@@ -63,6 +108,17 @@ public class XWalkResourceClient {
      */
     public void onReceivedLoadError(XWalkView view, int errorCode, String description,
             String failingUrl) {
-        // TODO(yongsheng): Need to define errorCode.
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(view.getContext());
+        dialogBuilder.setTitle(android.R.string.dialog_alert_title)
+                .setMessage(description)
+                .setCancelable(false)
+                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.dismiss();
+                    }
+                });
+        AlertDialog dialog = dialogBuilder.create();
+        dialog.show();
     }
 }