| 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 #ifndef CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ | 6 #define CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "chrome/common/thumbnail_capturer.mojom.h" | 16 #include "chrome/common/thumbnail_capturer.mojom.h" |
| 16 #include "content/public/browser/web_contents_user_data.h" | 17 #include "content/public/browser/web_contents_user_data.h" |
| 17 #include "content/public/common/context_menu_params.h" | 18 #include "content/public/common/context_menu_params.h" |
| 18 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 struct ContextMenuParams; | 22 struct ContextMenuParams; |
| 22 class RenderFrameHost; | 23 class RenderFrameHost; |
| 23 class WebContents; | 24 class WebContents; |
| 24 } | 25 } |
| 25 | 26 |
| 26 class ContextMenuHelper | 27 class ContextMenuHelper |
| 27 : public content::WebContentsUserData<ContextMenuHelper> { | 28 : public content::WebContentsUserData<ContextMenuHelper> { |
| 28 public: | 29 public: |
| 29 ~ContextMenuHelper() override; | 30 ~ContextMenuHelper() override; |
| 30 | 31 |
| 31 void ShowContextMenu(content::RenderFrameHost* render_frame_host, | 32 void ShowContextMenu(content::RenderFrameHost* render_frame_host, |
| 32 const content::ContextMenuParams& params); | 33 const content::ContextMenuParams& params); |
| 33 | 34 |
| 34 void OnContextMenuClosed(JNIEnv* env, | 35 void OnContextMenuClosed(JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& obj); | 36 const base::android::JavaParamRef<jobject>& obj); |
| 36 | 37 |
| 37 void SetPopulator(jobject jpopulator); | 38 void SetPopulator(jobject jpopulator); |
| 38 | 39 |
| 39 // Methods called from Java via JNI ------------------------------------------ | 40 // Methods called from Java via JNI ------------------------------------------ |
| 41 base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents( |
| 42 JNIEnv* env, |
| 43 const base::android::JavaParamRef<jobject>& obj); |
| 40 void OnStartDownload(JNIEnv* env, | 44 void OnStartDownload(JNIEnv* env, |
| 41 const base::android::JavaParamRef<jobject>& obj, | 45 const base::android::JavaParamRef<jobject>& obj, |
| 42 jboolean jis_link, | 46 jboolean jis_link, |
| 43 jboolean jis_data_reduction_proxy_enabled); | 47 jboolean jis_data_reduction_proxy_enabled); |
| 48 void RetrieveImage(JNIEnv* env, |
| 49 const base::android::JavaParamRef<jobject>& obj, |
| 50 const base::android::JavaParamRef<jobject>& jcallback, |
| 51 jint max_dimen_px); |
| 44 void SearchForImage(JNIEnv* env, | 52 void SearchForImage(JNIEnv* env, |
| 45 const base::android::JavaParamRef<jobject>& obj); | 53 const base::android::JavaParamRef<jobject>& obj); |
| 46 void ShareImage(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
| 47 | |
| 48 void RetrieveHeaderThumbnail(JNIEnv* env, | |
| 49 const base::android::JavaParamRef<jobject>& obj, | |
| 50 jint j_max_size_px); | |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 explicit ContextMenuHelper(content::WebContents* web_contents); | 56 explicit ContextMenuHelper(content::WebContents* web_contents); |
| 54 friend class content::WebContentsUserData<ContextMenuHelper>; | 57 friend class content::WebContentsUserData<ContextMenuHelper>; |
| 55 | 58 |
| 56 static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams( | 59 static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams( |
| 57 const content::ContextMenuParams& params); | 60 const content::ContextMenuParams& params); |
| 58 | 61 |
| 62 void OnRetrieveImage(chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer, |
| 63 const base::android::JavaRef<jobject>& jcallback, |
| 64 const std::vector<uint8_t>& thumbnail_data, |
| 65 const gfx::Size& original_size); |
| 66 |
| 59 void OnShareImage(chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer, | 67 void OnShareImage(chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer, |
| 60 const std::vector<uint8_t>& thumbnail_data, | 68 const std::vector<uint8_t>& thumbnail_data, |
| 61 const gfx::Size& original_size); | 69 const gfx::Size& original_size); |
| 62 | 70 |
| 63 void OnHeaderThumbnailReceived( | 71 void OnHeaderThumbnailReceived( |
| 64 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer, | 72 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer, |
| 65 const std::vector<uint8_t>& thumbnail_data, | 73 const std::vector<uint8_t>& thumbnail_data, |
| 66 const gfx::Size& original_size); | 74 const gfx::Size& original_size); |
| 67 | 75 |
| 68 base::android::ScopedJavaGlobalRef<jobject> java_obj_; | 76 base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
| 69 content::WebContents* web_contents_; | 77 content::WebContents* web_contents_; |
| 70 | 78 |
| 71 content::ContextMenuParams context_menu_params_; | 79 content::ContextMenuParams context_menu_params_; |
| 72 int render_frame_id_; | 80 int render_frame_id_; |
| 73 int render_process_id_; | 81 int render_process_id_; |
| 74 | 82 |
| 75 base::WeakPtrFactory<ContextMenuHelper> weak_factory_; | 83 base::WeakPtrFactory<ContextMenuHelper> weak_factory_; |
| 76 | 84 |
| 77 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper); | 85 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper); |
| 78 }; | 86 }; |
| 79 | 87 |
| 80 bool RegisterContextMenuHelper(JNIEnv* env); | 88 bool RegisterContextMenuHelper(JNIEnv* env); |
| 81 | 89 |
| 82 #endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ | 90 #endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ |
| OLD | NEW |