| 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 "chrome/browser/ui/android/context_menu_helper.h" | 5 #include "chrome/browser/ui/android/context_menu_helper.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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 env, | 42 env, |
| 43 Java_ContextMenuHelper_create(env, reinterpret_cast<long>(this)).obj()); | 43 Java_ContextMenuHelper_create(env, reinterpret_cast<long>(this)).obj()); |
| 44 DCHECK(!java_obj_.is_null()); | 44 DCHECK(!java_obj_.is_null()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 ContextMenuHelper::~ContextMenuHelper() { | 47 ContextMenuHelper::~ContextMenuHelper() { |
| 48 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
| 49 Java_ContextMenuHelper_destroy(env, java_obj_); | 49 Java_ContextMenuHelper_destroy(env, java_obj_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool ContextMenuHelper::ShowContextMenu( | 52 void ContextMenuHelper::ShowContextMenu( |
| 53 content::RenderFrameHost* render_frame_host, | 53 content::RenderFrameHost* render_frame_host, |
| 54 const content::ContextMenuParams& params) { | 54 const content::ContextMenuParams& params) { |
| 55 content::ContentViewCore* content_view_core = | 55 content::ContentViewCore* content_view_core = |
| 56 content::ContentViewCore::FromWebContents(web_contents_); | 56 content::ContentViewCore::FromWebContents(web_contents_); |
| 57 | 57 |
| 58 if (!content_view_core) | 58 if (!content_view_core) |
| 59 return false; | 59 return; |
| 60 | 60 |
| 61 base::android::ScopedJavaLocalRef<jobject> jcontent_view_core( | 61 base::android::ScopedJavaLocalRef<jobject> jcontent_view_core( |
| 62 content_view_core->GetJavaObject()); | 62 content_view_core->GetJavaObject()); |
| 63 | 63 |
| 64 if (jcontent_view_core.is_null()) | 64 if (jcontent_view_core.is_null()) |
| 65 return false; | 65 return; |
| 66 | 66 |
| 67 JNIEnv* env = base::android::AttachCurrentThread(); | 67 JNIEnv* env = base::android::AttachCurrentThread(); |
| 68 context_menu_params_ = params; | 68 context_menu_params_ = params; |
| 69 render_frame_id_ = render_frame_host->GetRoutingID(); | 69 render_frame_id_ = render_frame_host->GetRoutingID(); |
| 70 render_process_id_ = render_frame_host->GetProcess()->GetID(); | 70 render_process_id_ = render_frame_host->GetProcess()->GetID(); |
| 71 | 71 |
| 72 return Java_ContextMenuHelper_showContextMenu( | 72 Java_ContextMenuHelper_showContextMenu( |
| 73 env, java_obj_, jcontent_view_core, | 73 env, java_obj_, jcontent_view_core, |
| 74 ContextMenuHelper::CreateJavaContextMenuParams(params)); | 74 ContextMenuHelper::CreateJavaContextMenuParams(params)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ContextMenuHelper::SetPopulator(jobject jpopulator) { | 77 void ContextMenuHelper::SetPopulator(jobject jpopulator) { |
| 78 JNIEnv* env = base::android::AttachCurrentThread(); | 78 JNIEnv* env = base::android::AttachCurrentThread(); |
| 79 Java_ContextMenuHelper_setPopulator(env, java_obj_, jpopulator); | 79 Java_ContextMenuHelper_setPopulator(env, java_obj_, jpopulator); |
| 80 } | 80 } |
| 81 | 81 |
| 82 base::android::ScopedJavaLocalRef<jobject> | 82 base::android::ScopedJavaLocalRef<jobject> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 env, reinterpret_cast<const uint8_t*>(thumbnail_data.data()), | 170 env, reinterpret_cast<const uint8_t*>(thumbnail_data.data()), |
| 171 thumbnail_data.length()); | 171 thumbnail_data.length()); |
| 172 | 172 |
| 173 Java_ContextMenuHelper_onShareImageReceived(env, java_obj_, jwindow_android, | 173 Java_ContextMenuHelper_onShareImageReceived(env, java_obj_, jwindow_android, |
| 174 j_bytes); | 174 j_bytes); |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool RegisterContextMenuHelper(JNIEnv* env) { | 177 bool RegisterContextMenuHelper(JNIEnv* env) { |
| 178 return RegisterNativesImpl(env); | 178 return RegisterNativesImpl(env); |
| 179 } | 179 } |
| OLD | NEW |