| 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 "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 "chrome/browser/ui/tab_contents/core_tab_helper.h" | 10 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 env, | 37 env, |
| 38 Java_ContextMenuHelper_create(env, reinterpret_cast<long>(this)).obj()); | 38 Java_ContextMenuHelper_create(env, reinterpret_cast<long>(this)).obj()); |
| 39 DCHECK(!java_obj_.is_null()); | 39 DCHECK(!java_obj_.is_null()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 ContextMenuHelper::~ContextMenuHelper() { | 42 ContextMenuHelper::~ContextMenuHelper() { |
| 43 JNIEnv* env = base::android::AttachCurrentThread(); | 43 JNIEnv* env = base::android::AttachCurrentThread(); |
| 44 Java_ContextMenuHelper_destroy(env, java_obj_.obj()); | 44 Java_ContextMenuHelper_destroy(env, java_obj_.obj()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ContextMenuHelper::ShowContextMenu( | 47 bool ContextMenuHelper::ShowContextMenu( |
| 48 const content::ContextMenuParams& params) { | 48 const content::ContextMenuParams& params) { |
| 49 content::ContentViewCore* content_view_core = | 49 content::ContentViewCore* content_view_core = |
| 50 content::ContentViewCore::FromWebContents(web_contents_); | 50 content::ContentViewCore::FromWebContents(web_contents_); |
| 51 | 51 |
| 52 if (!content_view_core) | 52 if (!content_view_core) |
| 53 return; | 53 return false; |
| 54 | 54 |
| 55 base::android::ScopedJavaLocalRef<jobject> jcontent_view_core( | 55 base::android::ScopedJavaLocalRef<jobject> jcontent_view_core( |
| 56 content_view_core->GetJavaObject()); | 56 content_view_core->GetJavaObject()); |
| 57 | 57 |
| 58 if (jcontent_view_core.is_null()) | 58 if (jcontent_view_core.is_null()) |
| 59 return; | 59 return false; |
| 60 | 60 |
| 61 JNIEnv* env = base::android::AttachCurrentThread(); | 61 JNIEnv* env = base::android::AttachCurrentThread(); |
| 62 context_menu_params_ = params; | 62 context_menu_params_ = params; |
| 63 Java_ContextMenuHelper_showContextMenu( | 63 return Java_ContextMenuHelper_showContextMenu( |
| 64 env, | 64 env, java_obj_.obj(), jcontent_view_core.obj(), |
| 65 java_obj_.obj(), | |
| 66 jcontent_view_core.obj(), | |
| 67 ContextMenuHelper::CreateJavaContextMenuParams(params).obj()); | 65 ContextMenuHelper::CreateJavaContextMenuParams(params).obj()); |
| 68 } | 66 } |
| 69 | 67 |
| 70 void ContextMenuHelper::SetPopulator(jobject jpopulator) { | 68 void ContextMenuHelper::SetPopulator(jobject jpopulator) { |
| 71 JNIEnv* env = base::android::AttachCurrentThread(); | 69 JNIEnv* env = base::android::AttachCurrentThread(); |
| 72 Java_ContextMenuHelper_setPopulator(env, java_obj_.obj(), jpopulator); | 70 Java_ContextMenuHelper_setPopulator(env, java_obj_.obj(), jpopulator); |
| 73 } | 71 } |
| 74 | 72 |
| 75 base::android::ScopedJavaLocalRef<jobject> | 73 base::android::ScopedJavaLocalRef<jobject> |
| 76 ContextMenuHelper::CreateJavaContextMenuParams( | 74 ContextMenuHelper::CreateJavaContextMenuParams( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 env, | 152 env, |
| 155 java_obj_.obj(), | 153 java_obj_.obj(), |
| 156 jwindow_android.obj(), | 154 jwindow_android.obj(), |
| 157 j_bytes.obj()); | 155 j_bytes.obj()); |
| 158 } | 156 } |
| 159 | 157 |
| 160 bool RegisterContextMenuHelper(JNIEnv* env) { | 158 bool RegisterContextMenuHelper(JNIEnv* env) { |
| 161 return RegisterNativesImpl(env) && | 159 return RegisterNativesImpl(env) && |
| 162 ContextMenuParamsAndroid::RegisterNativesImpl(env); | 160 ContextMenuParamsAndroid::RegisterNativesImpl(env); |
| 163 } | 161 } |
| OLD | NEW |