blob: 499eaad5918e010b251bd504b20be2c362b41a23 [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"
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"
tedchoc23990ba2015-10-29 18:48:4815#include "ui/gfx/geometry/size.h"
[email protected]e96226872013-12-06 00:02:3716
17namespace content {
18struct ContextMenuParams;
19class WebContents;
20}
21
22class ContextMenuHelper
23 : public content::WebContentsUserData<ContextMenuHelper> {
24 public:
dcheng361fdb32015-02-04 02:56:0725 ~ContextMenuHelper() override;
[email protected]e96226872013-12-06 00:02:3726
27 void ShowContextMenu(const content::ContextMenuParams& params);
28
[email protected]e96226872013-12-06 00:02:3729 void SetPopulator(jobject jpopulator);
30
31 // Methods called from Java via JNI ------------------------------------------
torneebcfa2262015-11-25 17:47:2432 void OnStartDownload(JNIEnv* env,
33 const base::android::JavaParamRef<jobject>& obj,
34 jboolean jis_link,
35 const base::android::JavaParamRef<jstring>& jheaders);
36 void SearchForImage(JNIEnv* env,
37 const base::android::JavaParamRef<jobject>& obj);
38 void ShareImage(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
[email protected]e96226872013-12-06 00:02:3739
40 private:
41 explicit ContextMenuHelper(content::WebContents* web_contents);
42 friend class content::WebContentsUserData<ContextMenuHelper>;
43
44 static base::android::ScopedJavaLocalRef<jobject> CreateJavaContextMenuParams(
45 const content::ContextMenuParams& params);
46
tedchoc23990ba2015-10-29 18:48:4847 void OnShareImage(const std::string& thumbnail_data,
48 const gfx::Size& original_size);
49
[email protected]e96226872013-12-06 00:02:3750 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
51 content::WebContents* web_contents_;
52
[email protected]e96226872013-12-06 00:02:3753 content::ContextMenuParams context_menu_params_;
54
55 DISALLOW_COPY_AND_ASSIGN(ContextMenuHelper);
56};
57
58bool RegisterContextMenuHelper(JNIEnv* env);
59
60#endif // CHROME_BROWSER_UI_ANDROID_CONTEXT_MENU_HELPER_H_