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 "components/web_contents_delegate_android/web_contents_delegate_android
.h" | 5 #include "components/web_contents_delegate_android/web_contents_delegate_android
.h" |
6 | 6 |
7 #include <android/keycodes.h> | 7 #include <android/keycodes.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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 JNIEnv* env = AttachCurrentThread(); | 88 JNIEnv* env = AttachCurrentThread(); |
89 ScopedJavaLocalRef<jstring> java_url = | 89 ScopedJavaLocalRef<jstring> java_url = |
90 ConvertUTF8ToJavaString(env, url.spec()); | 90 ConvertUTF8ToJavaString(env, url.spec()); |
91 ScopedJavaLocalRef<jstring> extra_headers = | 91 ScopedJavaLocalRef<jstring> extra_headers = |
92 ConvertUTF8ToJavaString(env, params.extra_headers); | 92 ConvertUTF8ToJavaString(env, params.extra_headers); |
93 ScopedJavaLocalRef<jbyteArray> post_data; | 93 ScopedJavaLocalRef<jbyteArray> post_data; |
94 if (params.uses_post && | 94 if (params.uses_post && |
95 params.browser_initiated_post_data.get() && | 95 params.browser_initiated_post_data.get() && |
96 params.browser_initiated_post_data.get()->size()) { | 96 params.browser_initiated_post_data.get()->size()) { |
97 post_data = base::android::ToJavaByteArray( | 97 post_data = base::android::ToJavaByteArray( |
98 env, | 98 env, params.browser_initiated_post_data.get()->front_as<uint8_t>(), |
99 params.browser_initiated_post_data.get()->front_as<uint8>(), | |
100 params.browser_initiated_post_data.get()->size()); | 99 params.browser_initiated_post_data.get()->size()); |
101 } | 100 } |
102 Java_WebContentsDelegateAndroid_openNewTab(env, | 101 Java_WebContentsDelegateAndroid_openNewTab(env, |
103 obj.obj(), | 102 obj.obj(), |
104 java_url.obj(), | 103 java_url.obj(), |
105 extra_headers.obj(), | 104 extra_headers.obj(), |
106 post_data.obj(), | 105 post_data.obj(), |
107 disposition, | 106 disposition, |
108 params.is_renderer_initiated); | 107 params.is_renderer_initiated); |
109 return NULL; | 108 return NULL; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); | 274 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); |
276 } | 275 } |
277 | 276 |
278 void WebContentsDelegateAndroid::MoveContents(WebContents* source, | 277 void WebContentsDelegateAndroid::MoveContents(WebContents* source, |
279 const gfx::Rect& pos) { | 278 const gfx::Rect& pos) { |
280 // Do nothing. | 279 // Do nothing. |
281 } | 280 } |
282 | 281 |
283 bool WebContentsDelegateAndroid::AddMessageToConsole( | 282 bool WebContentsDelegateAndroid::AddMessageToConsole( |
284 WebContents* source, | 283 WebContents* source, |
285 int32 level, | 284 int32_t level, |
286 const base::string16& message, | 285 const base::string16& message, |
287 int32 line_no, | 286 int32_t line_no, |
288 const base::string16& source_id) { | 287 const base::string16& source_id) { |
289 JNIEnv* env = AttachCurrentThread(); | 288 JNIEnv* env = AttachCurrentThread(); |
290 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 289 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
291 if (obj.is_null()) | 290 if (obj.is_null()) |
292 return WebContentsDelegate::AddMessageToConsole(source, level, message, | 291 return WebContentsDelegate::AddMessageToConsole(source, level, message, |
293 line_no, source_id); | 292 line_no, source_id); |
294 ScopedJavaLocalRef<jstring> jmessage(ConvertUTF16ToJavaString(env, message)); | 293 ScopedJavaLocalRef<jstring> jmessage(ConvertUTF16ToJavaString(env, message)); |
295 ScopedJavaLocalRef<jstring> jsource_id( | 294 ScopedJavaLocalRef<jstring> jsource_id( |
296 ConvertUTF16ToJavaString(env, source_id)); | 295 ConvertUTF16ToJavaString(env, source_id)); |
297 int jlevel = WEB_CONTENTS_DELEGATE_LOG_LEVEL_DEBUG; | 296 int jlevel = WEB_CONTENTS_DELEGATE_LOG_LEVEL_DEBUG; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 // Native JNI methods | 437 // Native JNI methods |
439 // ---------------------------------------------------------------------------- | 438 // ---------------------------------------------------------------------------- |
440 | 439 |
441 // Register native methods | 440 // Register native methods |
442 | 441 |
443 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 442 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
444 return RegisterNativesImpl(env); | 443 return RegisterNativesImpl(env); |
445 } | 444 } |
446 | 445 |
447 } // namespace web_contents_delegate_android | 446 } // namespace web_contents_delegate_android |
OLD | NEW |