[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 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 | ||||
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 | |||||
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 8 | #include <memory> |
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame] | 9 | #include <string> |
10 | |||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 11 | #include "base/android/jni_android.h" |
12 | #include "base/callback.h" | ||||
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 13 | #include "base/macros.h" |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 14 | #include "content/public/browser/web_contents_user_data.h" |
15 | #include "content/public/common/context_menu_params.h" | ||||
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame] | 16 | #include "ui/gfx/geometry/size.h" |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 17 | |
18 | namespace content { | ||||
19 | struct ContextMenuParams; | ||||
tedchoc | cd0bf1f | 2015-12-15 21:23:10 | [diff] [blame] | 20 | class RenderFrameHost; |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 21 | class WebContents; |
22 | } | ||||
23 | |||||
24 | class ContextMenuHelper | ||||
25 | : public content::WebContentsUserData<ContextMenuHelper> { | ||||
26 | public: | ||||
dcheng | 361fdb3 | 2015-02-04 02:56:07 | [diff] [blame] | 27 | ~ContextMenuHelper() override; |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 28 | |
amaralp | dbb23e2 | 2016-09-26 22:40:11 | [diff] [blame] | 29 | void ShowContextMenu(content::RenderFrameHost* render_frame_host, |
tedchoc | cd0bf1f | 2015-12-15 21:23:10 | [diff] [blame] | 30 | const content::ContextMenuParams& params); |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 31 | |
shaktisahu | 3a2f73d | 2016-12-06 04:34:31 | [diff] [blame^] | 32 | void OnContextMenuClosed(JNIEnv* env, |
33 | const base::android::JavaParamRef<jobject>& obj); | ||||
34 | |||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 35 | void SetPopulator(jobject jpopulator); |
36 | |||||
37 | // Methods called from Java via JNI ------------------------------------------ | ||||
torne | ebcfa226 | 2015-11-25 17:47:24 | [diff] [blame] | 38 | void OnStartDownload(JNIEnv* env, |
39 | const base::android::JavaParamRef<jobject>& obj, | ||||
40 | jboolean jis_link, | ||||
bauerb | f6d2732 | 2016-03-30 17:02:48 | [diff] [blame] | 41 | jboolean jis_data_reduction_proxy_enabled); |
torne | ebcfa226 | 2015-11-25 17:47:24 | [diff] [blame] | 42 | void SearchForImage(JNIEnv* env, |
43 | const base::android::JavaParamRef<jobject>& obj); | ||||
44 | void ShareImage(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | ||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 45 | |
46 | private: | ||||
47 | explicit ContextMenuHelper(content::WebContents* web_contents); | ||||
48 | friend class content::WebContentsUserData<ContextMenuHelper>; | ||||
49 | |||||
50 | static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams( | ||||
51 | const content::ContextMenuParams& params); | ||||
52 | |||||
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame] | 53 | void OnShareImage(const std::string& thumbnail_data, |
54 | const gfx::Size& original_size); | ||||
55 | |||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 56 | base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
57 | content::WebContents* web_contents_; | ||||
58 | |||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 59 | content::ContextMenuParams context_menu_params_; |
tedchoc | cd0bf1f | 2015-12-15 21:23:10 | [diff] [blame] | 60 | int render_frame_id_; |
61 | int render_process_id_; | ||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 62 | |
63 | DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper); | ||||
64 | }; | ||||
65 | |||||
66 | bool RegisterContextMenuHelper(JNIEnv* env); | ||||
67 | |||||
68 | #endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ |