diff options
author | mkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 11:39:40 +0000 |
---|---|---|
committer | mkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 11:39:40 +0000 |
commit | 3fa8fe590f29d504ce1284d5b4814c64861b4ab7 (patch) | |
tree | b1869fe30e098efda55bf3730ceeea567bd983a7 | |
parent | cc6bed436be3a3bf3a44d4d66eade5156c7d9349 (diff) | |
download | chromium_src-3fa8fe590f29d504ce1284d5b4814c64861b4ab7.zip chromium_src-3fa8fe590f29d504ce1284d5b4814c64861b4ab7.tar.gz chromium_src-3fa8fe590f29d504ce1284d5b4814c64861b4ab7.tar.bz2 |
[android_webview] Add onPageStarted for data loads with base URLs.
This adds the missing onPageStarted callback.
TEST=AndroidWebViewTest
BUG=327391
Android-only, trybots happy
NOTRY=true
Review URL: https://codereview.chromium.org/110573003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240081 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwContents.java | 15 | ||||
-rw-r--r-- | android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java | 17 |
2 files changed, 28 insertions, 4 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 2a27c35..5b8fd9a 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -865,7 +865,7 @@ public class AwContents { */ public void loadUrl(LoadUrlParams params) { if (params.getLoadUrlType() == LoadUrlParams.LOAD_TYPE_DATA && - !params.isBaseUrlDataScheme()) { + !params.isBaseUrlDataScheme()) { // This allows data URLs with a non-data base URL access to file:///android_asset/ and // file:///android_res/ URLs. If AwSettings.getAllowFileAccess permits, it will also // allow access to file:// URLs (subject to OS level permission checks). @@ -874,9 +874,9 @@ public class AwContents { // If we are reloading the same url, then set transition type as reload. if (params.getUrl() != null && - params.getUrl().equals(mContentViewCore.getUrl()) && - params.getTransitionType() == PageTransitionTypes.PAGE_TRANSITION_LINK) { - params.setTransitionType(PageTransitionTypes.PAGE_TRANSITION_RELOAD); + params.getUrl().equals(mContentViewCore.getUrl()) && + params.getTransitionType() == PageTransitionTypes.PAGE_TRANSITION_LINK) { + params.setTransitionType(PageTransitionTypes.PAGE_TRANSITION_RELOAD); } params.setTransitionType( params.getTransitionType() | PageTransitionTypes.PAGE_TRANSITION_FROM_API); @@ -902,6 +902,13 @@ public class AwContents { mHasRequestedVisitedHistoryFromClient = true; requestVisitedHistoryFromClient(); } + + if (params.getLoadUrlType() == LoadUrlParams.LOAD_TYPE_DATA && + params.getBaseUrl() != null) { + // Data loads with a base url will be resolved in Blink, and not cause an onPageStarted + // event to be sent. Sending the callback directly from here. + mContentsClient.getCallbackHelper().postOnPageStarted(params.getBaseUrl()); + } } /** diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java index fde110d..59c3820 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java @@ -24,6 +24,10 @@ import java.io.File; import java.io.FileOutputStream; import java.util.concurrent.TimeUnit; +/** + * Tests for the {@link android.webkit.WebView#loadDataWithBaseURL(String, String, String, String, + * String)} method. + */ public class LoadDataWithBaseUrlTest extends AwTestBase { private TestAwContentsClient mContentsClient; @@ -195,6 +199,19 @@ public class LoadDataWithBaseUrlTest extends AwTestBase { @SmallTest @Feature({"AndroidWebView"}) + public void testloadDataWithBaseUrlCallsOnPageStarted() throws Throwable { + final String baseUrl = "http://base.com/"; + TestCallbackHelperContainer.OnPageStartedHelper onPageStartedHelper = + mContentsClient.getOnPageStartedHelper(); + final int callCount = onPageStartedHelper.getCallCount(); + loadDataWithBaseUrlAsync(CommonResources.ABOUT_HTML, "text/html", false, baseUrl, + "about:blank"); + onPageStartedHelper.waitForCallback(callCount); + assertEquals(baseUrl, onPageStartedHelper.getUrl()); + } + + @SmallTest + @Feature({"AndroidWebView"}) public void testHistoryUrl() throws Throwable { final String pageHtml = "<html><body>Hello, world!</body></html>"; |