| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/web_contents/web_contents_android.h" | 5 #include "content/browser/web_contents/web_contents_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return; | 164 return; |
| 165 | 165 |
| 166 WebContents* web_contents = web_contents_android->web_contents(); | 166 WebContents* web_contents = web_contents_android->web_contents(); |
| 167 if (!web_contents) | 167 if (!web_contents) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 delete web_contents; | 170 delete web_contents; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // static | 173 // static |
| 174 jobject FromNativePtr(JNIEnv* env, | 174 ScopedJavaLocalRef<jobject> FromNativePtr(JNIEnv* env, |
| 175 jclass clazz, | 175 jclass clazz, |
| 176 jlong web_contents_ptr) { | 176 jlong web_contents_ptr) { |
| 177 WebContentsAndroid* web_contents_android = | 177 WebContentsAndroid* web_contents_android = |
| 178 reinterpret_cast<WebContentsAndroid*>(web_contents_ptr); | 178 reinterpret_cast<WebContentsAndroid*>(web_contents_ptr); |
| 179 | 179 |
| 180 if (!web_contents_android) | 180 if (!web_contents_android) |
| 181 return 0; | 181 return ScopedJavaLocalRef<jobject>(); |
| 182 | 182 |
| 183 // Check to make sure this object hasn't been destroyed. | 183 // Check to make sure this object hasn't been destroyed. |
| 184 if (g_allocated_web_contents_androids.Get().find(web_contents_android) == | 184 if (g_allocated_web_contents_androids.Get().find(web_contents_android) == |
| 185 g_allocated_web_contents_androids.Get().end()) { | 185 g_allocated_web_contents_androids.Get().end()) { |
| 186 return 0; | 186 return ScopedJavaLocalRef<jobject>(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 return web_contents_android->GetJavaObject().Release(); | 189 return web_contents_android->GetJavaObject(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // static | 192 // static |
| 193 bool WebContentsAndroid::Register(JNIEnv* env) { | 193 bool WebContentsAndroid::Register(JNIEnv* env) { |
| 194 return RegisterNativesImpl(env); | 194 return RegisterNativesImpl(env); |
| 195 } | 195 } |
| 196 | 196 |
| 197 WebContentsAndroid::WebContentsAndroid(WebContents* web_contents) | 197 WebContentsAndroid::WebContentsAndroid(WebContents* web_contents) |
| 198 : web_contents_(web_contents), | 198 : web_contents_(web_contents), |
| 199 navigation_controller_(&(web_contents->GetController())), | 199 navigation_controller_(&(web_contents->GetController())), |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 web_contents_->StopMediaSession(); | 541 web_contents_->StopMediaSession(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 ScopedJavaLocalRef<jstring> WebContentsAndroid::GetEncoding( | 544 ScopedJavaLocalRef<jstring> WebContentsAndroid::GetEncoding( |
| 545 JNIEnv* env, jobject obj) const { | 545 JNIEnv* env, jobject obj) const { |
| 546 return base::android::ConvertUTF8ToJavaString(env, | 546 return base::android::ConvertUTF8ToJavaString(env, |
| 547 web_contents_->GetEncoding()); | 547 web_contents_->GetEncoding()); |
| 548 } | 548 } |
| 549 | 549 |
| 550 } // namespace content | 550 } // namespace content |
| OLD | NEW |