[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 | |
tedchoc | cd0bf1f | 2015-12-15 21:23:10 | [diff] [blame] | 29 | bool ShowContextMenu(content::RenderFrameHost* render_frame_host, |
30 | const content::ContextMenuParams& params); | ||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 31 | |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 32 | void SetPopulator(jobject jpopulator); |
33 | |||||
34 | // Methods called from Java via JNI ------------------------------------------ | ||||
torne | ebcfa226 | 2015-11-25 17:47:24 | [diff] [blame] | 35 | void OnStartDownload(JNIEnv* env, |
36 | const base::android::JavaParamRef<jobject>& obj, | ||||
37 | jboolean jis_link, | ||||
bauerb | f6d2732 | 2016-03-30 17:02:48 | [diff] [blame] | 38 | jboolean jis_data_reduction_proxy_enabled); |
torne | ebcfa226 | 2015-11-25 17:47:24 | [diff] [blame] | 39 | void SearchForImage(JNIEnv* env, |
40 | const base::android::JavaParamRef<jobject>& obj); | ||||
41 | void ShareImage(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | ||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 42 | |
43 | private: | ||||
44 | explicit ContextMenuHelper(content::WebContents* web_contents); | ||||
45 | friend class content::WebContentsUserData<ContextMenuHelper>; | ||||
46 | |||||
47 | static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams( | ||||
48 | const content::ContextMenuParams& params); | ||||
49 | |||||
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame] | 50 | void OnShareImage(const std::string& thumbnail_data, |
51 | const gfx::Size& original_size); | ||||
52 | |||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 53 | base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
54 | content::WebContents* web_contents_; | ||||
55 | |||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 56 | content::ContextMenuParams context_menu_params_; |
tedchoc | cd0bf1f | 2015-12-15 21:23:10 | [diff] [blame] | 57 | int render_frame_id_; |
58 | int render_process_id_; | ||||
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 59 | |
60 | DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper); | ||||
61 | }; | ||||
62 | |||||
63 | bool RegisterContextMenuHelper(JNIEnv* env); | ||||
64 | |||||
65 | #endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ |