| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 using base::android::ScopedJavaGlobalRef; | 53 using base::android::ScopedJavaGlobalRef; |
| 54 using base::android::ScopedJavaLocalRef; | 54 using base::android::ScopedJavaLocalRef; |
| 55 using base::android::ToJavaIntArray; | 55 using base::android::ToJavaIntArray; |
| 56 | 56 |
| 57 namespace content { | 57 namespace content { |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 // Track all WebContentsAndroid objects here so that we don't deserialize a | 61 // Track all WebContentsAndroid objects here so that we don't deserialize a |
| 62 // destroyed WebContents object. | 62 // destroyed WebContents object. |
| 63 base::LazyInstance<base::hash_set<WebContentsAndroid*> >::Leaky | 63 base::LazyInstance<base::hash_set<WebContentsAndroid*>>::Leaky |
| 64 g_allocated_web_contents_androids = LAZY_INSTANCE_INITIALIZER; | 64 g_allocated_web_contents_androids = LAZY_INSTANCE_INITIALIZER; |
| 65 | 65 |
| 66 void JavaScriptResultCallback(const ScopedJavaGlobalRef<jobject>& callback, | 66 void JavaScriptResultCallback(const ScopedJavaGlobalRef<jobject>& callback, |
| 67 const base::Value* result) { | 67 const base::Value* result) { |
| 68 JNIEnv* env = base::android::AttachCurrentThread(); | 68 JNIEnv* env = base::android::AttachCurrentThread(); |
| 69 std::string json; | 69 std::string json; |
| 70 base::JSONWriter::Write(*result, &json); | 70 base::JSONWriter::Write(*result, &json); |
| 71 ScopedJavaLocalRef<jstring> j_json = ConvertUTF8ToJavaString(env, json); | 71 ScopedJavaLocalRef<jstring> j_json = ConvertUTF8ToJavaString(env, json); |
| 72 Java_WebContentsImpl_onEvaluateJavaScriptResult(env, j_json, callback); | 72 Java_WebContentsImpl_onEvaluateJavaScriptResult(env, j_json, callback); |
| 73 } | 73 } |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); | 770 env, obj, callback, id, http_status_code, jurl, jbitmaps, jsizes); |
| 771 } | 771 } |
| 772 | 772 |
| 773 void WebContentsAndroid::SetMediaSession( | 773 void WebContentsAndroid::SetMediaSession( |
| 774 const ScopedJavaLocalRef<jobject>& j_media_session) { | 774 const ScopedJavaLocalRef<jobject>& j_media_session) { |
| 775 JNIEnv* env = base::android::AttachCurrentThread(); | 775 JNIEnv* env = base::android::AttachCurrentThread(); |
| 776 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); | 776 Java_WebContentsImpl_setMediaSession(env, obj_, j_media_session); |
| 777 } | 777 } |
| 778 | 778 |
| 779 } // namespace content | 779 } // namespace content |
| OLD | NEW |