blob: 2d6b5b48a49ddb030c56e8de42a382f3551a30bc [file] [log] [blame]
[email protected]e96226872013-12-06 00:02:371// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_
6#define CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_
7
dcheng9603ab92016-04-08 04:17:328#include <memory>
tedchoc23990ba2015-10-29 18:48:489#include <string>
watk2c472002017-03-14 05:52:2810#include <vector>
tedchoc23990ba2015-10-29 18:48:4811
[email protected]e96226872013-12-06 00:02:3712#include "base/android/jni_android.h"
tedchoc69a502c2017-04-07 18:11:3613#include "base/android/scoped_java_ref.h"
avi655876a2015-12-25 07:18:1514#include "base/macros.h"
injaed698fa92017-06-23 19:39:3015#include "chrome/common/thumbnail_capturer.mojom.h"
[email protected]e96226872013-12-06 00:02:3716#include "content/public/browser/web_contents_user_data.h"
17#include "content/public/common/context_menu_params.h"
18
19namespace content {
20struct ContextMenuParams;
tedchoccd0bf1f2015-12-15 21:23:1021class RenderFrameHost;
[email protected]e96226872013-12-06 00:02:3722class WebContents;
23}
24
25class ContextMenuHelper
26 : public content::WebContentsUserData<ContextMenuHelper> {
injaed698fa92017-06-23 19:39:3027 protected:
28 using ImageRetrieveCallback = base::Callback<void(
29 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer_ptr,
30 const base::android::JavaRef<jobject>& jcallback,
31 const std::vector<uint8_t>& thumbnail_data,
32 const gfx::Size& max_dimen_px)>;
33
[email protected]e96226872013-12-06 00:02:3734 public:
dcheng361fdb32015-02-04 02:56:0735 ~ContextMenuHelper() override;
[email protected]e96226872013-12-06 00:02:3736
amaralpdbb23e22016-09-26 22:40:1137 void ShowContextMenu(content::RenderFrameHost* render_frame_host,
tedchoccd0bf1f2015-12-15 21:23:1038 const content::ContextMenuParams& params);
[email protected]e96226872013-12-06 00:02:3739
shaktisahu3a2f73d2016-12-06 04:34:3140 void OnContextMenuClosed(JNIEnv* env,
41 const base::android::JavaParamRef<jobject>& obj);
42
[email protected]e96226872013-12-06 00:02:3743 void SetPopulator(jobject jpopulator);
44
45 // Methods called from Java via JNI ------------------------------------------
tedchoc69a502c2017-04-07 18:11:3646 base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents(
47 JNIEnv* env,
48 const base::android::JavaParamRef<jobject>& obj);
torneebcfa2262015-11-25 17:47:2449 void OnStartDownload(JNIEnv* env,
50 const base::android::JavaParamRef<jobject>& obj,
51 jboolean jis_link,
bauerbf6d27322016-03-30 17:02:4852 jboolean jis_data_reduction_proxy_enabled);
injaed698fa92017-06-23 19:39:3053 void RetrieveImageForShare(
54 JNIEnv* env,
55 const base::android::JavaParamRef<jobject>& obj,
56 const base::android::JavaParamRef<jobject>& jcallback,
57 jint max_dimen_px);
58 void RetrieveImageForContextMenu(
59 JNIEnv* env,
60 const base::android::JavaParamRef<jobject>& obj,
61 const base::android::JavaParamRef<jobject>& jcallback,
62 jint max_dimen_px);
63 void RetrieveImageInternal(
64 JNIEnv* env,
65 const ImageRetrieveCallback& retrieve_callback,
66 const base::android::JavaParamRef<jobject>& jcallback,
67 jint max_dimen_px);
torneebcfa2262015-11-25 17:47:2468 void SearchForImage(JNIEnv* env,
69 const base::android::JavaParamRef<jobject>& obj);
jwanda88172022017-03-31 22:28:3470
[email protected]e96226872013-12-06 00:02:3771 private:
72 explicit ContextMenuHelper(content::WebContents* web_contents);
73 friend class content::WebContentsUserData<ContextMenuHelper>;
74
75 static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams(
76 const content::ContextMenuParams& params);
77
[email protected]e96226872013-12-06 00:02:3778 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
79 content::WebContents* web_contents_;
80
[email protected]e96226872013-12-06 00:02:3781 content::ContextMenuParams context_menu_params_;
tedchoccd0bf1f2015-12-15 21:23:1082 int render_frame_id_;
83 int render_process_id_;
[email protected]e96226872013-12-06 00:02:3784
[email protected]e96226872013-12-06 00:02:3785 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper);
86};
87
88bool RegisterContextMenuHelper(JNIEnv* env);
89
90#endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_