summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authormnaganov <mnaganov@chromium.org>2015-11-13 13:15:31 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-13 21:16:50 +0000
commit8f1314f6d90ebcc24506cd036e76f98c3881e8ba (patch)
tree600363fdb394d9272a044092cad8375a5080879f /content
parent22241d9e94fbab2e6f111c8c994464ddc485b560 (diff)
downloadchromium_src-8f1314f6d90ebcc24506cd036e76f98c3881e8ba.zip
chromium_src-8f1314f6d90ebcc24506cd036e76f98c3881e8ba.tar.gz
chromium_src-8f1314f6d90ebcc24506cd036e76f98c3881e8ba.tar.bz2
[Android WebView] Fire onPageFinished from WebContentsObserver::didStopLoading
After CL https://codereview.chromium.org/1381003004, WebContentsObserver::didStopLoading has become the last event fired when loading is finished. WebView was using WebContentsObserver::didFinishLoad event when it is fired for the main frame, but this callback now happens before WebContentsImpl has updated its internal state. This causes subtle race issues, e.g. unwanted reloading of the currently loading page due to UA string update, which caused flakiness of AwSettingsTest#testUserAgentStringOverrideForHistory test. However, as didStopLoading is fired in some cases when didFinishLoad isn't, we still need to use didFinishLoad to gate posting of onPageFinishedEvent. BUG=553762 Review URL: https://codereview.chromium.org/1432083004 Cr-Commit-Position: refs/heads/master@{#359642}
Diffstat (limited to 'content')
-rw-r--r--content/browser/android/web_contents_observer_proxy.cc19
-rw-r--r--content/browser/android/web_contents_observer_proxy.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/content/browser/android/web_contents_observer_proxy.cc b/content/browser/android/web_contents_observer_proxy.cc
index c04f926..923f5a6 100644
--- a/content/browser/android/web_contents_observer_proxy.cc
+++ b/content/browser/android/web_contents_observer_proxy.cc
@@ -87,8 +87,10 @@ void WebContentsObserverProxy::DidStartLoading() {
void WebContentsObserverProxy::DidStopLoading() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj(java_observer_);
+ std::string url_string = web_contents()->GetLastCommittedURL().spec();
+ SetToBaseURLForDataURLIfNeeded(&url_string);
ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString(
- env, web_contents()->GetLastCommittedURL().spec()));
+ env, url_string));
Java_WebContentsObserverProxy_didStopLoading(env, obj.obj(),
jstring_url.obj());
}
@@ -205,11 +207,7 @@ void WebContentsObserverProxy::DidFinishLoad(RenderFrameHost* render_frame_host,
ScopedJavaLocalRef<jobject> obj(java_observer_);
std::string url_string = validated_url.spec();
- NavigationEntry* entry =
- web_contents()->GetController().GetLastCommittedEntry();
- // Note that GetBaseURLForDataURL is only used by the Android WebView.
- if (entry && !entry->GetBaseURLForDataURL().is_empty())
- url_string = entry->GetBaseURLForDataURL().possibly_invalid_spec();
+ SetToBaseURLForDataURLIfNeeded(&url_string);
ScopedJavaLocalRef<jstring> jstring_url(
ConvertUTF8ToJavaString(env, url_string));
@@ -300,6 +298,15 @@ void WebContentsObserverProxy::MediaSessionStateChanged(bool is_controllable,
env, obj.obj(), is_controllable, is_suspended);
}
+void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded(
+ std::string* url) {
+ NavigationEntry* entry =
+ web_contents()->GetController().GetLastCommittedEntry();
+ // Note that GetBaseURLForDataURL is only used by the Android WebView.
+ if (entry && !entry->GetBaseURLForDataURL().is_empty())
+ *url = entry->GetBaseURLForDataURL().possibly_invalid_spec();
+}
+
bool RegisterWebContentsObserverProxy(JNIEnv* env) {
return RegisterNativesImpl(env);
}
diff --git a/content/browser/android/web_contents_observer_proxy.h b/content/browser/android/web_contents_observer_proxy.h
index bbce094..a366cfb 100644
--- a/content/browser/android/web_contents_observer_proxy.h
+++ b/content/browser/android/web_contents_observer_proxy.h
@@ -73,6 +73,7 @@ class WebContentsObserverProxy : public WebContentsObserver {
NavigationController::ReloadType reload_type) override;
void MediaSessionStateChanged(bool is_controllable,
bool is_suspended) override;
+ void SetToBaseURLForDataURLIfNeeded(std::string* url);
void DidFailLoadInternal(bool is_provisional_load,
bool is_main_frame,