[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 | |
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame^] | 8 | #include <string> |
| 9 | |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 10 | #include "base/android/jni_android.h" |
| 11 | #include "base/callback.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
| 13 | #include "content/public/browser/web_contents_user_data.h" |
| 14 | #include "content/public/common/context_menu_params.h" |
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame^] | 15 | #include "ui/gfx/geometry/size.h" |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 16 | |
| 17 | namespace content { |
| 18 | struct ContextMenuParams; |
| 19 | class WebContents; |
| 20 | } |
| 21 | |
| 22 | class ContextMenuHelper |
| 23 | : public content::WebContentsUserData<ContextMenuHelper> { |
| 24 | public: |
dcheng | 361fdb3 | 2015-02-04 02:56:07 | [diff] [blame] | 25 | ~ContextMenuHelper() override; |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 26 | |
| 27 | void ShowContextMenu(const content::ContextMenuParams& params); |
| 28 | |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 29 | void SetPopulator(jobject jpopulator); |
| 30 | |
| 31 | // Methods called from Java via JNI ------------------------------------------ |
megjablon | 3d5616a | 2015-06-23 21:19:37 | [diff] [blame] | 32 | void OnStartDownload( |
| 33 | JNIEnv* env, jobject obj, jboolean jis_link, jstring jheaders); |
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame^] | 34 | void SearchForImage(JNIEnv* env, jobject obj); |
| 35 | void ShareImage(JNIEnv* env, jobject obj); |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 36 | |
| 37 | private: |
| 38 | explicit ContextMenuHelper(content::WebContents* web_contents); |
| 39 | friend class content::WebContentsUserData<ContextMenuHelper>; |
| 40 | |
| 41 | static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams( |
| 42 | const content::ContextMenuParams& params); |
| 43 | |
tedchoc | 23990ba | 2015-10-29 18:48:48 | [diff] [blame^] | 44 | void OnShareImage(const std::string& thumbnail_data, |
| 45 | const gfx::Size& original_size); |
| 46 | |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 47 | base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
| 48 | content::WebContents* web_contents_; |
| 49 | |
[email protected] | e9622687 | 2013-12-06 00:02:37 | [diff] [blame] | 50 | content::ContextMenuParams context_menu_params_; |
| 51 | |
| 52 | DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper); |
| 53 | }; |
| 54 | |
| 55 | bool RegisterContextMenuHelper(JNIEnv* env); |
| 56 | |
| 57 | #endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_ |