blob: 8e9e57477599123410cc01c1de7cf327eb6c76f5 [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>
10
[email protected]e96226872013-12-06 00:02:3711#include "base/android/jni_android.h"
12#include "base/callback.h"
avi655876a2015-12-25 07:18:1513#include "base/macros.h"
[email protected]e96226872013-12-06 00:02:3714#include "content/public/browser/web_contents_user_data.h"
15#include "content/public/common/context_menu_params.h"
tedchoc23990ba2015-10-29 18:48:4816#include "ui/gfx/geometry/size.h"
[email protected]e96226872013-12-06 00:02:3717
18namespace content {
19struct ContextMenuParams;
tedchoccd0bf1f2015-12-15 21:23:1020class RenderFrameHost;
[email protected]e96226872013-12-06 00:02:3721class WebContents;
22}
23
24class ContextMenuHelper
25 : public content::WebContentsUserData<ContextMenuHelper> {
26 public:
dcheng361fdb32015-02-04 02:56:0727 ~ContextMenuHelper() override;
[email protected]e96226872013-12-06 00:02:3728
amaralpdbb23e22016-09-26 22:40:1129 void ShowContextMenu(content::RenderFrameHost* render_frame_host,
tedchoccd0bf1f2015-12-15 21:23:1030 const content::ContextMenuParams& params);
[email protected]e96226872013-12-06 00:02:3731
shaktisahu3a2f73d2016-12-06 04:34:3132 void OnContextMenuClosed(JNIEnv* env,
33 const base::android::JavaParamRef<jobject>& obj);
34
[email protected]e96226872013-12-06 00:02:3735 void SetPopulator(jobject jpopulator);
36
37 // Methods called from Java via JNI ------------------------------------------
torneebcfa2262015-11-25 17:47:2438 void OnStartDownload(JNIEnv* env,
39 const base::android::JavaParamRef<jobject>& obj,
40 jboolean jis_link,
bauerbf6d27322016-03-30 17:02:4841 jboolean jis_data_reduction_proxy_enabled);
torneebcfa2262015-11-25 17:47:2442 void SearchForImage(JNIEnv* env,
43 const base::android::JavaParamRef<jobject>& obj);
44 void ShareImage(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
[email protected]e96226872013-12-06 00:02:3745
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
tedchoc23990ba2015-10-29 18:48:4853 void OnShareImage(const std::string& thumbnail_data,
54 const gfx::Size& original_size);
55
[email protected]e96226872013-12-06 00:02:3756 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
57 content::WebContents* web_contents_;
58
[email protected]e96226872013-12-06 00:02:3759 content::ContextMenuParams context_menu_params_;
tedchoccd0bf1f2015-12-15 21:23:1060 int render_frame_id_;
61 int render_process_id_;
[email protected]e96226872013-12-06 00:02:3762
63 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper);
64};
65
66bool RegisterContextMenuHelper(JNIEnv* env);
67
68#endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_