blob: 70c15b3ac78923defbf04f5619346a32b4dfd9e7 [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"
13#include "base/callback.h"
avi655876a2015-12-25 07:18:1514#include "base/macros.h"
watk2c472002017-03-14 05:52:2815#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"
tedchoc23990ba2015-10-29 18:48:4818#include "ui/gfx/geometry/size.h"
[email protected]e96226872013-12-06 00:02:3719
20namespace content {
21struct ContextMenuParams;
tedchoccd0bf1f2015-12-15 21:23:1022class RenderFrameHost;
[email protected]e96226872013-12-06 00:02:3723class WebContents;
24}
25
26class ContextMenuHelper
27 : public content::WebContentsUserData<ContextMenuHelper> {
28 public:
dcheng361fdb32015-02-04 02:56:0729 ~ContextMenuHelper() override;
[email protected]e96226872013-12-06 00:02:3730
amaralpdbb23e22016-09-26 22:40:1131 void ShowContextMenu(content::RenderFrameHost* render_frame_host,
tedchoccd0bf1f2015-12-15 21:23:1032 const content::ContextMenuParams& params);
[email protected]e96226872013-12-06 00:02:3733
shaktisahu3a2f73d2016-12-06 04:34:3134 void OnContextMenuClosed(JNIEnv* env,
35 const base::android::JavaParamRef<jobject>& obj);
36
[email protected]e96226872013-12-06 00:02:3737 void SetPopulator(jobject jpopulator);
38
39 // Methods called from Java via JNI ------------------------------------------
torneebcfa2262015-11-25 17:47:2440 void OnStartDownload(JNIEnv* env,
41 const base::android::JavaParamRef<jobject>& obj,
42 jboolean jis_link,
bauerbf6d27322016-03-30 17:02:4843 jboolean jis_data_reduction_proxy_enabled);
torneebcfa2262015-11-25 17:47:2444 void SearchForImage(JNIEnv* env,
45 const base::android::JavaParamRef<jobject>& obj);
46 void ShareImage(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
[email protected]e96226872013-12-06 00:02:3747
jwanda88172022017-03-31 22:28:3448 void RetrieveHeaderThumbnail(JNIEnv* env,
49 const base::android::JavaParamRef<jobject>& obj,
50 jint j_max_size_px);
51
[email protected]e96226872013-12-06 00:02:3752 private:
53 explicit ContextMenuHelper(content::WebContents* web_contents);
54 friend class content::WebContentsUserData<ContextMenuHelper>;
55
56 static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams(
57 const content::ContextMenuParams& params);
58
watk2c472002017-03-14 05:52:2859 void OnShareImage(chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer,
60 const std::vector<uint8_t>& thumbnail_data,
tedchoc23990ba2015-10-29 18:48:4861 const gfx::Size& original_size);
62
jwanda88172022017-03-31 22:28:3463 void OnHeaderThumbnailReceived(
64 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer,
65 const std::vector<uint8_t>& thumbnail_data,
66 const gfx::Size& original_size);
67
[email protected]e96226872013-12-06 00:02:3768 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
69 content::WebContents* web_contents_;
70
[email protected]e96226872013-12-06 00:02:3771 content::ContextMenuParams context_menu_params_;
tedchoccd0bf1f2015-12-15 21:23:1072 int render_frame_id_;
73 int render_process_id_;
[email protected]e96226872013-12-06 00:02:3774
watk2c472002017-03-14 05:52:2875 base::WeakPtrFactory<ContextMenuHelper> weak_factory_;
76
[email protected]e96226872013-12-06 00:02:3777 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper);
78};
79
80bool RegisterContextMenuHelper(JNIEnv* env);
81
82#endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_