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

Side by Side Diff: content/browser/android/web_contents_observer_proxy.cc

Issue 1432083004: [Android WebView] Fire onPageFinished from WebContentsObserver::didStopLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore required AwWebContentsObserverTest changes Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/android/web_contents_observer_proxy.h" 5 #include "content/browser/android/web_contents_observer_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 ScopedJavaLocalRef<jobject> obj(java_observer_); 80 ScopedJavaLocalRef<jobject> obj(java_observer_);
81 ScopedJavaLocalRef<jstring> jstring_url( 81 ScopedJavaLocalRef<jstring> jstring_url(
82 ConvertUTF8ToJavaString(env, web_contents()->GetVisibleURL().spec())); 82 ConvertUTF8ToJavaString(env, web_contents()->GetVisibleURL().spec()));
83 Java_WebContentsObserverProxy_didStartLoading(env, obj.obj(), 83 Java_WebContentsObserverProxy_didStartLoading(env, obj.obj(),
84 jstring_url.obj()); 84 jstring_url.obj());
85 } 85 }
86 86
87 void WebContentsObserverProxy::DidStopLoading() { 87 void WebContentsObserverProxy::DidStopLoading() {
88 JNIEnv* env = AttachCurrentThread(); 88 JNIEnv* env = AttachCurrentThread();
89 ScopedJavaLocalRef<jobject> obj(java_observer_); 89 ScopedJavaLocalRef<jobject> obj(java_observer_);
90 std::string url_string = web_contents()->GetLastCommittedURL().spec();
91 SetToBaseURLForDataURLIfNeeded(&url_string);
90 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( 92 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString(
91 env, web_contents()->GetLastCommittedURL().spec())); 93 env, url_string));
92 Java_WebContentsObserverProxy_didStopLoading(env, obj.obj(), 94 Java_WebContentsObserverProxy_didStopLoading(env, obj.obj(),
93 jstring_url.obj()); 95 jstring_url.obj());
94 } 96 }
95 97
96 void WebContentsObserverProxy::DidFailProvisionalLoad( 98 void WebContentsObserverProxy::DidFailProvisionalLoad(
97 RenderFrameHost* render_frame_host, 99 RenderFrameHost* render_frame_host,
98 const GURL& validated_url, 100 const GURL& validated_url,
99 int error_code, 101 int error_code,
100 const base::string16& error_description, 102 const base::string16& error_description,
101 bool was_ignored_by_handler) { 103 bool was_ignored_by_handler) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 env, obj.obj(), render_frame_host->GetRoutingID(), 200 env, obj.obj(), render_frame_host->GetRoutingID(),
199 !render_frame_host->GetParent(), jstring_url.obj(), transition_type); 201 !render_frame_host->GetParent(), jstring_url.obj(), transition_type);
200 } 202 }
201 203
202 void WebContentsObserverProxy::DidFinishLoad(RenderFrameHost* render_frame_host, 204 void WebContentsObserverProxy::DidFinishLoad(RenderFrameHost* render_frame_host,
203 const GURL& validated_url) { 205 const GURL& validated_url) {
204 JNIEnv* env = AttachCurrentThread(); 206 JNIEnv* env = AttachCurrentThread();
205 ScopedJavaLocalRef<jobject> obj(java_observer_); 207 ScopedJavaLocalRef<jobject> obj(java_observer_);
206 208
207 std::string url_string = validated_url.spec(); 209 std::string url_string = validated_url.spec();
208 NavigationEntry* entry = 210 SetToBaseURLForDataURLIfNeeded(&url_string);
209 web_contents()->GetController().GetLastCommittedEntry();
210 // Note that GetBaseURLForDataURL is only used by the Android WebView.
211 if (entry && !entry->GetBaseURLForDataURL().is_empty())
212 url_string = entry->GetBaseURLForDataURL().possibly_invalid_spec();
213 211
214 ScopedJavaLocalRef<jstring> jstring_url( 212 ScopedJavaLocalRef<jstring> jstring_url(
215 ConvertUTF8ToJavaString(env, url_string)); 213 ConvertUTF8ToJavaString(env, url_string));
216 Java_WebContentsObserverProxy_didFinishLoad( 214 Java_WebContentsObserverProxy_didFinishLoad(
217 env, obj.obj(), render_frame_host->GetRoutingID(), jstring_url.obj(), 215 env, obj.obj(), render_frame_host->GetRoutingID(), jstring_url.obj(),
218 !render_frame_host->GetParent()); 216 !render_frame_host->GetParent());
219 } 217 }
220 218
221 void WebContentsObserverProxy::DocumentLoadedInFrame( 219 void WebContentsObserverProxy::DocumentLoadedInFrame(
222 RenderFrameHost* render_frame_host) { 220 RenderFrameHost* render_frame_host) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 void WebContentsObserverProxy::MediaSessionStateChanged(bool is_controllable, 291 void WebContentsObserverProxy::MediaSessionStateChanged(bool is_controllable,
294 bool is_suspended) { 292 bool is_suspended) {
295 JNIEnv* env = AttachCurrentThread(); 293 JNIEnv* env = AttachCurrentThread();
296 294
297 ScopedJavaLocalRef<jobject> obj(java_observer_); 295 ScopedJavaLocalRef<jobject> obj(java_observer_);
298 296
299 Java_WebContentsObserverProxy_mediaSessionStateChanged( 297 Java_WebContentsObserverProxy_mediaSessionStateChanged(
300 env, obj.obj(), is_controllable, is_suspended); 298 env, obj.obj(), is_controllable, is_suspended);
301 } 299 }
302 300
301 void WebContentsObserverProxy::SetToBaseURLForDataURLIfNeeded(
302 std::string* url) {
303 NavigationEntry* entry =
304 web_contents()->GetController().GetLastCommittedEntry();
305 // Note that GetBaseURLForDataURL is only used by the Android WebView.
306 if (entry && !entry->GetBaseURLForDataURL().is_empty())
307 *url = entry->GetBaseURLForDataURL().possibly_invalid_spec();
308 }
309
303 bool RegisterWebContentsObserverProxy(JNIEnv* env) { 310 bool RegisterWebContentsObserverProxy(JNIEnv* env) {
304 return RegisterNativesImpl(env); 311 return RegisterNativesImpl(env);
305 } 312 }
306 } // namespace content 313 } // namespace content
OLDNEW
« 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