Commit 5b5349ca authored by mnaganov@chromium.org's avatar mnaganov@chromium.org

[Android WebView] Provide a minimal error description for nav errors

Since not all net error codes can be mapped onto Android error codes,
at least provide a minimal description for the client.

Review URL: https://chromiumcodereview.appspot.com/15979017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204002 0039d316-1c4b-4281-b951-d872f2087c98
parent b2c489d3
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.android_webview.test; package org.chromium.android_webview.test;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import android.webkit.WebSettings;
import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AndroidProtocolHandler; import org.chromium.android_webview.AndroidProtocolHandler;
...@@ -118,4 +119,21 @@ public class ClientOnReceivedErrorTest extends AwTestBase { ...@@ -118,4 +119,21 @@ public class ClientOnReceivedErrorTest extends AwTestBase {
assertEquals(url, onReceivedErrorHelper.getFailingUrl()); assertEquals(url, onReceivedErrorHelper.getFailingUrl());
assertNotNull(onReceivedErrorHelper.getDescription()); assertNotNull(onReceivedErrorHelper.getDescription());
} }
@MediumTest
@Feature({"AndroidWebView"})
public void testCacheMiss() throws Throwable {
TestCallbackHelperContainer.OnReceivedErrorHelper onReceivedErrorHelper =
mContentsClient.getOnReceivedErrorHelper();
final String url = "http://example.com/index.html";
int onReceivedErrorCallCount = onReceivedErrorHelper.getCallCount();
getAwSettingsOnUiThread(mAwContents).setCacheMode(WebSettings.LOAD_CACHE_ONLY);
loadUrlAsync(mAwContents, url);
onReceivedErrorHelper.waitForCallback(onReceivedErrorCallCount);
assertEquals(ErrorCodeConversionHelper.ERROR_UNKNOWN,
onReceivedErrorHelper.getErrorCode());
assertEquals(url, onReceivedErrorHelper.getFailingUrl());
assertNotNull(onReceivedErrorHelper.getDescription());
}
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/visitedlink/renderer/visitedlink_slave.h" #include "components/visitedlink/renderer/visitedlink_slave.h"
#include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_thread.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/base/net_errors.h"
#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h" #include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h" #include "third_party/WebKit/public/platform/WebURLError.h"
...@@ -68,9 +69,13 @@ void AwContentRendererClient::GetNavigationErrorStrings( ...@@ -68,9 +69,13 @@ void AwContentRendererClient::GetNavigationErrorStrings(
std::string contents; std::string contents;
if (err.empty()) { if (err.empty()) {
contents = AwResource::GetNoDomainPageContent(); contents = AwResource::GetNoDomainPageContent();
if (error_description)
*error_description = ASCIIToUTF16(net::ErrorToString(error.reason));
} else { } else {
contents = AwResource::GetLoadErrorPageContent(); contents = AwResource::GetLoadErrorPageContent();
ReplaceSubstringsAfterOffset(&contents, 0, "%e", err); ReplaceSubstringsAfterOffset(&contents, 0, "%e", err);
if (error_description)
*error_description = error.localizedDescription;
} }
ReplaceSubstringsAfterOffset(&contents, 0, "%s", ReplaceSubstringsAfterOffset(&contents, 0, "%s",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment