| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_android.h" | 5 #include "content/browser/android/web_contents_observer_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include <jni.h> | 9 #include <jni.h> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (obj.is_null()) | 91 if (obj.is_null()) |
| 92 return; | 92 return; |
| 93 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( | 93 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( |
| 94 env, web_contents()->GetLastCommittedURL().spec())); | 94 env, web_contents()->GetLastCommittedURL().spec())); |
| 95 Java_WebContentsObserverAndroid_didStopLoading( | 95 Java_WebContentsObserverAndroid_didStopLoading( |
| 96 env, obj.obj(), jstring_url.obj()); | 96 env, obj.obj(), jstring_url.obj()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void WebContentsObserverAndroid::DidFailProvisionalLoad( | 99 void WebContentsObserverAndroid::DidFailProvisionalLoad( |
| 100 int64 frame_id, | 100 int64 frame_id, |
| 101 const string16& frame_unique_name, | 101 const base::string16& frame_unique_name, |
| 102 bool is_main_frame, | 102 bool is_main_frame, |
| 103 const GURL& validated_url, | 103 const GURL& validated_url, |
| 104 int error_code, | 104 int error_code, |
| 105 const string16& error_description, | 105 const base::string16& error_description, |
| 106 RenderViewHost* render_view_host) { | 106 RenderViewHost* render_view_host) { |
| 107 DidFailLoadInternal( | 107 DidFailLoadInternal( |
| 108 true, is_main_frame, error_code, error_description, validated_url); | 108 true, is_main_frame, error_code, error_description, validated_url); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void WebContentsObserverAndroid::DidFailLoad( | 111 void WebContentsObserverAndroid::DidFailLoad( |
| 112 int64 frame_id, | 112 int64 frame_id, |
| 113 const GURL& validated_url, | 113 const GURL& validated_url, |
| 114 bool is_main_frame, | 114 bool is_main_frame, |
| 115 int error_code, | 115 int error_code, |
| 116 const string16& error_description, | 116 const base::string16& error_description, |
| 117 RenderViewHost* render_view_host) { | 117 RenderViewHost* render_view_host) { |
| 118 DidFailLoadInternal( | 118 DidFailLoadInternal( |
| 119 false, is_main_frame, error_code, error_description, validated_url); | 119 false, is_main_frame, error_code, error_description, validated_url); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void WebContentsObserverAndroid::DidNavigateMainFrame( | 122 void WebContentsObserverAndroid::DidNavigateMainFrame( |
| 123 const LoadCommittedDetails& details, | 123 const LoadCommittedDetails& details, |
| 124 const FrameNavigateParams& params) { | 124 const FrameNavigateParams& params) { |
| 125 JNIEnv* env = AttachCurrentThread(); | 125 JNIEnv* env = AttachCurrentThread(); |
| 126 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); | 126 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return; | 168 return; |
| 169 ScopedJavaLocalRef<jstring> jstring_url( | 169 ScopedJavaLocalRef<jstring> jstring_url( |
| 170 ConvertUTF8ToJavaString(env, validated_url.spec())); | 170 ConvertUTF8ToJavaString(env, validated_url.spec())); |
| 171 Java_WebContentsObserverAndroid_didStartProvisionalLoadForFrame( | 171 Java_WebContentsObserverAndroid_didStartProvisionalLoadForFrame( |
| 172 env, obj.obj(), frame_id, parent_frame_id, is_main_frame, | 172 env, obj.obj(), frame_id, parent_frame_id, is_main_frame, |
| 173 jstring_url.obj(), is_error_page, is_iframe_srcdoc); | 173 jstring_url.obj(), is_error_page, is_iframe_srcdoc); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void WebContentsObserverAndroid::DidCommitProvisionalLoadForFrame( | 176 void WebContentsObserverAndroid::DidCommitProvisionalLoadForFrame( |
| 177 int64 frame_id, | 177 int64 frame_id, |
| 178 const string16& frame_unique_name, | 178 const base::string16& frame_unique_name, |
| 179 bool is_main_frame, | 179 bool is_main_frame, |
| 180 const GURL& url, | 180 const GURL& url, |
| 181 PageTransition transition_type, | 181 PageTransition transition_type, |
| 182 RenderViewHost* render_view_host) { | 182 RenderViewHost* render_view_host) { |
| 183 JNIEnv* env = AttachCurrentThread(); | 183 JNIEnv* env = AttachCurrentThread(); |
| 184 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); | 184 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); |
| 185 if (obj.is_null()) | 185 if (obj.is_null()) |
| 186 return; | 186 return; |
| 187 ScopedJavaLocalRef<jstring> jstring_url( | 187 ScopedJavaLocalRef<jstring> jstring_url( |
| 188 ConvertUTF8ToJavaString(env, url.spec())); | 188 ConvertUTF8ToJavaString(env, url.spec())); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); | 244 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); |
| 245 if (obj.is_null()) | 245 if (obj.is_null()) |
| 246 return; | 246 return; |
| 247 Java_WebContentsObserverAndroid_didDetachInterstitialPage(env, obj.obj()); | 247 Java_WebContentsObserverAndroid_didDetachInterstitialPage(env, obj.obj()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void WebContentsObserverAndroid::DidFailLoadInternal( | 250 void WebContentsObserverAndroid::DidFailLoadInternal( |
| 251 bool is_provisional_load, | 251 bool is_provisional_load, |
| 252 bool is_main_frame, | 252 bool is_main_frame, |
| 253 int error_code, | 253 int error_code, |
| 254 const string16& description, | 254 const base::string16& description, |
| 255 const GURL& url) { | 255 const GURL& url) { |
| 256 JNIEnv* env = AttachCurrentThread(); | 256 JNIEnv* env = AttachCurrentThread(); |
| 257 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); | 257 ScopedJavaLocalRef<jobject> obj(weak_java_observer_.get(env)); |
| 258 if (obj.is_null()) | 258 if (obj.is_null()) |
| 259 return; | 259 return; |
| 260 ScopedJavaLocalRef<jstring> jstring_error_description( | 260 ScopedJavaLocalRef<jstring> jstring_error_description( |
| 261 ConvertUTF16ToJavaString(env, description)); | 261 ConvertUTF16ToJavaString(env, description)); |
| 262 ScopedJavaLocalRef<jstring> jstring_url( | 262 ScopedJavaLocalRef<jstring> jstring_url( |
| 263 ConvertUTF8ToJavaString(env, url.spec())); | 263 ConvertUTF8ToJavaString(env, url.spec())); |
| 264 | 264 |
| 265 Java_WebContentsObserverAndroid_didFailLoad( | 265 Java_WebContentsObserverAndroid_didFailLoad( |
| 266 env, obj.obj(), | 266 env, obj.obj(), |
| 267 is_provisional_load, | 267 is_provisional_load, |
| 268 is_main_frame, | 268 is_main_frame, |
| 269 error_code, | 269 error_code, |
| 270 jstring_error_description.obj(), jstring_url.obj()); | 270 jstring_error_description.obj(), jstring_url.obj()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool RegisterWebContentsObserverAndroid(JNIEnv* env) { | 273 bool RegisterWebContentsObserverAndroid(JNIEnv* env) { |
| 274 return RegisterNativesImpl(env); | 274 return RegisterNativesImpl(env); |
| 275 } | 275 } |
| 276 } // namespace content | 276 } // namespace content |
| OLD | NEW |