Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1271)

Unified Diff: content/browser/android/web_contents_observer_proxy.cc

Issue 1799973002: Store and use last base URL between DidStart / DidStopLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/web_contents_observer_proxy.cc
diff --git a/content/browser/android/web_contents_observer_proxy.cc b/content/browser/android/web_contents_observer_proxy.cc
index 4b5b388ce16f7e1b7c83e08f99d2fe1b999aafb8..0483fd867f004fed3c25d3b67068b8daeda52e99 100644
--- a/content/browser/android/web_contents_observer_proxy.cc
+++ b/content/browser/android/web_contents_observer_proxy.cc
@@ -93,6 +93,9 @@ void WebContentsObserverProxy::DidStartLoading() {
ScopedJavaLocalRef<jobject> obj(java_observer_);
ScopedJavaLocalRef<jstring> jstring_url(
ConvertUTF8ToJavaString(env, web_contents()->GetVisibleURL().spec()));
+ if (auto entry = web_contents()->GetController().GetPendingEntry()) {
+ base_url_of_last_started_data_url_ = entry->GetBaseURLForDataURL();
+ }
Java_WebContentsObserverProxy_didStartLoading(env, obj.obj(),
jstring_url.obj());
}
@@ -102,6 +105,8 @@ void WebContentsObserverProxy::DidStopLoading() {
ScopedJavaLocalRef<jobject> obj(java_observer_);
std::string url_string = web_contents()->GetLastCommittedURL().spec();
SetToBaseURLForDataURLIfNeeded(&url_string);
+ // DidStopLoading is the last event we should get.
+ base_url_of_last_started_data_url_ = GURL::EmptyGURL();
ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString(
env, url_string));
Java_WebContentsObserverProxy_didStopLoading(env, obj.obj(),
@@ -317,8 +322,16 @@ void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded(
NavigationEntry* entry =
web_contents()->GetController().GetLastCommittedEntry();
// Note that GetBaseURLForDataURL is only used by the Android WebView.
- if (entry && !entry->GetBaseURLForDataURL().is_empty())
+ // FIXME: Should we only return valid specs and "about:blank" for invalid
+ // ones? This may break apps.
+ if (entry && !entry->GetBaseURLForDataURL().is_empty()) {
*url = entry->GetBaseURLForDataURL().possibly_invalid_spec();
+ } else if (!base_url_of_last_started_data_url_.is_empty()) {
+ // NavigationController can lose the pending entry and recreate it without
+ // a base URL if there has been a loadUrl("javascript:...") after
+ // loadDataWithBaseUrl.
+ *url = base_url_of_last_started_data_url_.possibly_invalid_spec();
+ }
}
bool RegisterWebContentsObserverProxy(JNIEnv* env) {
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698