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

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

Issue 2604543002: WebContentsObserver and TabObserver update for PlzNavigate (Closed)
Patch Set: nits Created 3 years, 11 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 unified diff | Download patch
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 void WebContentsObserverProxy::RenderProcessGone( 75 void WebContentsObserverProxy::RenderProcessGone(
76 base::TerminationStatus termination_status) { 76 base::TerminationStatus termination_status) {
77 JNIEnv* env = AttachCurrentThread(); 77 JNIEnv* env = AttachCurrentThread();
78 ScopedJavaLocalRef<jobject> obj(java_observer_); 78 ScopedJavaLocalRef<jobject> obj(java_observer_);
79 jboolean was_oom_protected = 79 jboolean was_oom_protected =
80 termination_status == base::TERMINATION_STATUS_OOM_PROTECTED; 80 termination_status == base::TERMINATION_STATUS_OOM_PROTECTED;
81 Java_WebContentsObserverProxy_renderProcessGone(env, obj, was_oom_protected); 81 Java_WebContentsObserverProxy_renderProcessGone(env, obj, was_oom_protected);
82 } 82 }
83 83
84 void WebContentsObserverProxy::DidFinishNavigation(
85 NavigationHandle* navigation_handle) {
86 JNIEnv* env = AttachCurrentThread();
87 ScopedJavaLocalRef<jobject> obj(java_observer_);
88 ScopedJavaLocalRef<jstring> jstring_url(
89 ConvertUTF8ToJavaString(env, web_contents()->GetVisibleURL().spec()));
90 Java_WebContentsObserverProxy_didFinishNavigation(
91 env, obj, navigation_handle->IsInMainFrame(),
92 navigation_handle->IsErrorPage(), navigation_handle->HasCommitted());
93 }
94
95 void WebContentsObserverProxy::DidStartLoading() { 84 void WebContentsObserverProxy::DidStartLoading() {
96 JNIEnv* env = AttachCurrentThread(); 85 JNIEnv* env = AttachCurrentThread();
97 ScopedJavaLocalRef<jobject> obj(java_observer_); 86 ScopedJavaLocalRef<jobject> obj(java_observer_);
98 ScopedJavaLocalRef<jstring> jstring_url( 87 ScopedJavaLocalRef<jstring> jstring_url(
99 ConvertUTF8ToJavaString(env, web_contents()->GetVisibleURL().spec())); 88 ConvertUTF8ToJavaString(env, web_contents()->GetVisibleURL().spec()));
100 if (auto* entry = web_contents()->GetController().GetPendingEntry()) { 89 if (auto* entry = web_contents()->GetController().GetPendingEntry()) {
101 base_url_of_last_started_data_url_ = entry->GetBaseURLForDataURL(); 90 base_url_of_last_started_data_url_ = entry->GetBaseURLForDataURL();
102 } 91 }
103 Java_WebContentsObserverProxy_didStartLoading(env, obj, jstring_url); 92 Java_WebContentsObserverProxy_didStartLoading(env, obj, jstring_url);
104 } 93 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ui::PageTransition transition_type) { 201 ui::PageTransition transition_type) {
213 JNIEnv* env = AttachCurrentThread(); 202 JNIEnv* env = AttachCurrentThread();
214 ScopedJavaLocalRef<jobject> obj(java_observer_); 203 ScopedJavaLocalRef<jobject> obj(java_observer_);
215 ScopedJavaLocalRef<jstring> jstring_url( 204 ScopedJavaLocalRef<jstring> jstring_url(
216 ConvertUTF8ToJavaString(env, url.spec())); 205 ConvertUTF8ToJavaString(env, url.spec()));
217 Java_WebContentsObserverProxy_didCommitProvisionalLoadForFrame( 206 Java_WebContentsObserverProxy_didCommitProvisionalLoadForFrame(
218 env, obj, render_frame_host->GetRoutingID(), 207 env, obj, render_frame_host->GetRoutingID(),
219 !render_frame_host->GetParent(), jstring_url, transition_type); 208 !render_frame_host->GetParent(), jstring_url, transition_type);
220 } 209 }
221 210
211 void WebContentsObserverProxy::DidStartNavigation(
212 NavigationHandle* navigation_handle) {
213 JNIEnv* env = AttachCurrentThread();
214 ScopedJavaLocalRef<jobject> obj(java_observer_);
215 ScopedJavaLocalRef<jstring> jstring_url(
216 ConvertUTF8ToJavaString(env, navigation_handle->GetURL().spec()));
217 Java_WebContentsObserverProxy_didStartNavigation(
218 env, obj, jstring_url, navigation_handle->IsInMainFrame(),
219 navigation_handle->IsErrorPage());
220 }
221
222 void WebContentsObserverProxy::DidFinishNavigation(
223 NavigationHandle* navigation_handle) {
224 JNIEnv* env = AttachCurrentThread();
225 ScopedJavaLocalRef<jobject> obj(java_observer_);
226 ScopedJavaLocalRef<jstring> jstring_url(
227 ConvertUTF8ToJavaString(env, navigation_handle->GetURL().spec()));
228
229 Java_WebContentsObserverProxy_didFinishNavigation(
230 env, obj, jstring_url, navigation_handle->IsInMainFrame(),
231 navigation_handle->IsErrorPage(), navigation_handle->HasCommitted(),
232 navigation_handle->IsSamePage(),
233 navigation_handle->HasCommitted() ? navigation_handle->GetPageTransition()
234 : -1,
235 navigation_handle->GetNetErrorCode());
236 }
237
222 void WebContentsObserverProxy::DidFinishLoad(RenderFrameHost* render_frame_host, 238 void WebContentsObserverProxy::DidFinishLoad(RenderFrameHost* render_frame_host,
223 const GURL& validated_url) { 239 const GURL& validated_url) {
224 JNIEnv* env = AttachCurrentThread(); 240 JNIEnv* env = AttachCurrentThread();
225 ScopedJavaLocalRef<jobject> obj(java_observer_); 241 ScopedJavaLocalRef<jobject> obj(java_observer_);
226 242
227 std::string url_string = validated_url.spec(); 243 std::string url_string = validated_url.spec();
228 SetToBaseURLForDataURLIfNeeded(&url_string); 244 SetToBaseURLForDataURLIfNeeded(&url_string);
229 245
230 ScopedJavaLocalRef<jstring> jstring_url( 246 ScopedJavaLocalRef<jstring> jstring_url(
231 ConvertUTF8ToJavaString(env, url_string)); 247 ConvertUTF8ToJavaString(env, url_string));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // a base URL if there has been a loadUrl("javascript:...") after 357 // a base URL if there has been a loadUrl("javascript:...") after
342 // loadDataWithBaseUrl. 358 // loadDataWithBaseUrl.
343 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); 359 *url = base_url_of_last_started_data_url_.possibly_invalid_spec();
344 } 360 }
345 } 361 }
346 362
347 bool RegisterWebContentsObserverProxy(JNIEnv* env) { 363 bool RegisterWebContentsObserverProxy(JNIEnv* env) {
348 return RegisterNativesImpl(env); 364 return RegisterNativesImpl(env);
349 } 365 }
350 } // namespace content 366 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698