blob: 7b774637f82ac41aeb8a2d94700a690f45afa27d [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
tedchoc23990ba2015-10-29 18:48:488#include <string>
9
[email protected]e96226872013-12-06 00:02:3710#include "base/android/jni_android.h"
11#include "base/callback.h"
avi655876a2015-12-25 07:18:1512#include "base/macros.h"
[email protected]e96226872013-12-06 00:02:3713#include "base/memory/scoped_ptr.h"
14#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
tedchoccd0bf1f2015-12-15 21:23:1029 bool ShowContextMenu(content::RenderFrameHost* render_frame_host,
30 const content::ContextMenuParams& params);
[email protected]e96226872013-12-06 00:02:3731
[email protected]e96226872013-12-06 00:02:3732 void SetPopulator(jobject jpopulator);
33
34 // Methods called from Java via JNI ------------------------------------------
torneebcfa2262015-11-25 17:47:2435 void OnStartDownload(JNIEnv* env,
36 const base::android::JavaParamRef<jobject>& obj,
37 jboolean jis_link,
38 const base::android::JavaParamRef<jstring>& jheaders);
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]e96226872013-12-06 00:02:3742
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
tedchoc23990ba2015-10-29 18:48:4850 void OnShareImage(const std::string& thumbnail_data,
51 const gfx::Size& original_size);
52
[email protected]e96226872013-12-06 00:02:3753 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
54 content::WebContents* web_contents_;
55
[email protected]e96226872013-12-06 00:02:3756 content::ContextMenuParams context_menu_params_;
tedchoccd0bf1f2015-12-15 21:23:1057 int render_frame_id_;
58 int render_process_id_;
[email protected]e96226872013-12-06 00:02:3759
60 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper);
61};
62
63bool RegisterContextMenuHelper(JNIEnv* env);
64
65#endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_