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

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

Issue 2598163002: WebContentsObserver update for PlzNavigate methods (Closed)
Patch Set: Revert back a state CHECK 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 Java_WebContentsObserverProxy_didNavigateAnyFrame( 170 Java_WebContentsObserverProxy_didNavigateAnyFrame(
182 env, obj, jstring_url, jstring_base_url, jboolean_is_reload); 171 env, obj, jstring_url, jstring_base_url, jboolean_is_reload);
183 } 172 }
184 173
185 void WebContentsObserverProxy::DocumentAvailableInMainFrame() { 174 void WebContentsObserverProxy::DocumentAvailableInMainFrame() {
186 JNIEnv* env = AttachCurrentThread(); 175 JNIEnv* env = AttachCurrentThread();
187 ScopedJavaLocalRef<jobject> obj(java_observer_); 176 ScopedJavaLocalRef<jobject> obj(java_observer_);
188 Java_WebContentsObserverProxy_documentAvailableInMainFrame(env, obj); 177 Java_WebContentsObserverProxy_documentAvailableInMainFrame(env, obj);
189 } 178 }
190 179
180 void WebContentsObserverProxy::DidStartNavigation(
181 NavigationHandle* navigation_handle) {
182 JNIEnv* env = AttachCurrentThread();
183 ScopedJavaLocalRef<jobject> obj(java_observer_);
184 ScopedJavaLocalRef<jstring> jstring_url(
185 ConvertUTF8ToJavaString(env, navigation_handle->GetURL().spec()));
186 Java_WebContentsObserverProxy_didStartNavigation(
187 env, obj, jstring_url, navigation_handle->IsInMainFrame(),
188 navigation_handle->IsErrorPage());
189 }
190
191 void WebContentsObserverProxy::DidFinishNavigation(
192 NavigationHandle* navigation_handle) {
193 JNIEnv* env = AttachCurrentThread();
194 ScopedJavaLocalRef<jobject> obj(java_observer_);
195
196 ScopedJavaLocalRef<jstring> jstring_url(
197 ConvertUTF8ToJavaString(env, navigation_handle->GetURL().spec()));
198 jboolean is_reload = false;
199 if (navigation_handle->HasCommitted()) {
200 is_reload = ui::PageTransitionCoreTypeIs(
201 navigation_handle->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD);
202 }
203
204 Java_WebContentsObserverProxy_didFinishNavigation(
205 env, obj, jstring_url, navigation_handle->IsInMainFrame(),
206 navigation_handle->IsErrorPage(), navigation_handle->HasCommitted(),
207 navigation_handle->IsSamePage(), is_reload);
208 }
209
191 void WebContentsObserverProxy::DidStartProvisionalLoadForFrame( 210 void WebContentsObserverProxy::DidStartProvisionalLoadForFrame(
192 RenderFrameHost* render_frame_host, 211 RenderFrameHost* render_frame_host,
193 const GURL& validated_url, 212 const GURL& validated_url,
194 bool is_error_page) { 213 bool is_error_page) {
195 JNIEnv* env = AttachCurrentThread(); 214 JNIEnv* env = AttachCurrentThread();
196 ScopedJavaLocalRef<jobject> obj(java_observer_); 215 ScopedJavaLocalRef<jobject> obj(java_observer_);
197 ScopedJavaLocalRef<jstring> jstring_url( 216 ScopedJavaLocalRef<jstring> jstring_url(
198 ConvertUTF8ToJavaString(env, validated_url.spec())); 217 ConvertUTF8ToJavaString(env, validated_url.spec()));
199 // TODO(dcheng): Does Java really need the parent frame ID? It doesn't appear 218 // TODO(dcheng): Does Java really need the parent frame ID? It doesn't appear
200 // to be used at all, and it just adds complexity here. 219 // to be used at all, and it just adds complexity here.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // a base URL if there has been a loadUrl("javascript:...") after 360 // a base URL if there has been a loadUrl("javascript:...") after
342 // loadDataWithBaseUrl. 361 // loadDataWithBaseUrl.
343 *url = base_url_of_last_started_data_url_.possibly_invalid_spec(); 362 *url = base_url_of_last_started_data_url_.possibly_invalid_spec();
344 } 363 }
345 } 364 }
346 365
347 bool RegisterWebContentsObserverProxy(JNIEnv* env) { 366 bool RegisterWebContentsObserverProxy(JNIEnv* env) {
348 return RegisterNativesImpl(env); 367 return RegisterNativesImpl(env);
349 } 368 }
350 } // namespace content 369 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698