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

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

Issue 1779363004: Store and use last base URL between DidStart / DidStopLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests 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
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..8e22c7ac55b10000a11fb4be922065c4fdc92a2e 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()) {
boliu 2016/03/14 18:34:04 auto* ? Actually style guide doesn't really say an
mnaganov (inactive) 2016/03/14 20:10:57 I don't think it makes any difference here.
+ base_url_of_last_started_data_url_ = entry->GetBaseURLForDataURL();
+ }
Java_WebContentsObserverProxy_didStartLoading(env, obj.obj(),
jstring_url.obj());
}
@@ -102,6 +105,7 @@ void WebContentsObserverProxy::DidStopLoading() {
ScopedJavaLocalRef<jobject> obj(java_observer_);
std::string url_string = web_contents()->GetLastCommittedURL().spec();
SetToBaseURLForDataURLIfNeeded(&url_string);
+ 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 +321,14 @@ 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())
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698