blob: 71d645b91083721d0853c23c5c4a3b12b3e52125 [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"
Nicholas Vernec6b829a2017-10-24 13:43:5615#include "chrome/common/chrome_render_frame.mojom.h"
Josh Simmons6067fdb2020-01-17 08:56:5016#include "components/optimization_guide/proto/performance_hints_metadata.pb.h"
Lukasz Anforowicz8c4446dc2020-03-11 22:16:4217#include "content/public/browser/context_menu_params.h"
[email protected]e96226872013-12-06 00:02:3718#include "content/public/browser/web_contents_user_data.h"
Shimi Zhang4570d122019-09-06 22:50:5519#include "mojo/public/cpp/bindings/associated_remote.h"
[email protected]e96226872013-12-06 00:02:3720
21namespace content {
22struct ContextMenuParams;
tedchoccd0bf1f2015-12-15 21:23:1023class RenderFrameHost;
[email protected]e96226872013-12-06 00:02:3724class WebContents;
25}
26
27class ContextMenuHelper
28 : public content::WebContentsUserData<ContextMenuHelper> {
injaed698fa92017-06-23 19:39:3029 protected:
30 using ImageRetrieveCallback = base::Callback<void(
Shimi Zhang4570d122019-09-06 22:50:5531 mojo::AssociatedRemote<chrome::mojom::ChromeRenderFrame>
32 chrome_render_frame_ptr,
injaed698fa92017-06-23 19:39:3033 const base::android::JavaRef<jobject>& jcallback,
34 const std::vector<uint8_t>& thumbnail_data,
35 const gfx::Size& max_dimen_px)>;
36
[email protected]e96226872013-12-06 00:02:3737 public:
dcheng361fdb32015-02-04 02:56:0738 ~ContextMenuHelper() override;
[email protected]e96226872013-12-06 00:02:3739
amaralpdbb23e22016-09-26 22:40:1140 void ShowContextMenu(content::RenderFrameHost* render_frame_host,
tedchoccd0bf1f2015-12-15 21:23:1041 const content::ContextMenuParams& params);
[email protected]e96226872013-12-06 00:02:3742
shaktisahu3a2f73d2016-12-06 04:34:3143 void OnContextMenuClosed(JNIEnv* env,
44 const base::android::JavaParamRef<jobject>& obj);
45
Torne (Richard Coles)0a108752017-07-25 15:08:4146 void SetPopulator(const base::android::JavaRef<jobject>& jpopulator);
[email protected]e96226872013-12-06 00:02:3747
48 // Methods called from Java via JNI ------------------------------------------
tedchoc69a502c2017-04-07 18:11:3649 base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents(
50 JNIEnv* env,
51 const base::android::JavaParamRef<jobject>& obj);
torneebcfa2262015-11-25 17:47:2452 void OnStartDownload(JNIEnv* env,
53 const base::android::JavaParamRef<jobject>& obj,
54 jboolean jis_link,
bauerbf6d27322016-03-30 17:02:4855 jboolean jis_data_reduction_proxy_enabled);
injaed698fa92017-06-23 19:39:3056 void RetrieveImageForShare(
57 JNIEnv* env,
58 const base::android::JavaParamRef<jobject>& obj,
59 const base::android::JavaParamRef<jobject>& jcallback,
Daniel Park0de66772017-11-03 21:20:4760 jint max_width_px,
61 jint max_height_px);
injaed698fa92017-06-23 19:39:3062 void RetrieveImageForContextMenu(
63 JNIEnv* env,
64 const base::android::JavaParamRef<jobject>& obj,
65 const base::android::JavaParamRef<jobject>& jcallback,
Daniel Park0de66772017-11-03 21:20:4766 jint max_width_px,
67 jint max_height_px);
injaed698fa92017-06-23 19:39:3068 void RetrieveImageInternal(
69 JNIEnv* env,
70 const ImageRetrieveCallback& retrieve_callback,
71 const base::android::JavaParamRef<jobject>& jcallback,
Daniel Park0de66772017-11-03 21:20:4772 jint max_width_px,
73 jint max_height_px);
torneebcfa2262015-11-25 17:47:2474 void SearchForImage(JNIEnv* env,
75 const base::android::JavaParamRef<jobject>& obj);
jwanda88172022017-03-31 22:28:3476
[email protected]e96226872013-12-06 00:02:3777 private:
78 explicit ContextMenuHelper(content::WebContents* web_contents);
79 friend class content::WebContentsUserData<ContextMenuHelper>;
80
[email protected]e96226872013-12-06 00:02:3781 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
82 content::WebContents* web_contents_;
83
[email protected]e96226872013-12-06 00:02:3784 content::ContextMenuParams context_menu_params_;
tedchoccd0bf1f2015-12-15 21:23:1085 int render_frame_id_;
86 int render_process_id_;
[email protected]e96226872013-12-06 00:02:3787
François Doray4f51d5d2018-12-03 22:26:2488 WEB_CONTENTS_USER_DATA_KEY_DECL();
89
[email protected]e96226872013-12-06 00:02:3790 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper);
91};
92
[email protected]e96226872013-12-06 00:02:3793#endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_