Android: Break interdependency of ContextMenuHelper/Populator
ContextMenuHelper and ContextMenuPopulator refer to each other. This CL
breaks the dependency by the populator having its own native layer
to process the tasks.
This leaves ContextMenuPopulator free of the reference to Context-
MenuPopulator, effectively allowing for the definition of a modularized
build target chrome/browser/contextmenu:java.
Bug: 952703
Change-Id: I2bdabe167e2c98a1d2fef24eb68af993d3beab57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2172176
Commit-Queue: Jinsuk Kim <[email protected]>
Reviewed-by: Theresa <[email protected]>
Cr-Commit-Position: refs/heads/master@{#768731}
diff --git a/chrome/browser/ui/android/context_menu_helper.h b/chrome/browser/ui/android/context_menu_helper.h
index 79c553c3..4eae876 100644
--- a/chrome/browser/ui/android/context_menu_helper.h
+++ b/chrome/browser/ui/android/context_menu_helper.h
@@ -15,33 +15,15 @@
#include "chrome/common/chrome_render_frame.mojom.h"
#include "components/optimization_guide/proto/performance_hints_metadata.pb.h"
#include "content/public/browser/context_menu_params.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents_user_data.h"
-#include "mojo/public/cpp/bindings/associated_remote.h"
namespace content {
-struct ContextMenuParams;
-class RenderFrameHost;
class WebContents;
}
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.contextmenu
-enum ContextMenuImageFormat {
- JPEG = 0,
- PNG = 1,
- ORIGINAL = 2,
-};
-
class ContextMenuHelper
: public content::WebContentsUserData<ContextMenuHelper> {
- protected:
- using ImageRetrieveCallback = base::Callback<void(
- mojo::AssociatedRemote<chrome::mojom::ChromeRenderFrame>
- chrome_render_frame_ptr,
- const base::android::JavaRef<jobject>& jcallback,
- const std::vector<uint8_t>& thumbnail_data,
- const gfx::Size& max_dimen_px,
- const std::string& image_extension)>;
-
public:
~ContextMenuHelper() override;
@@ -53,41 +35,10 @@
void SetPopulator(const base::android::JavaRef<jobject>& jpopulator);
- // Methods called from Java via JNI ------------------------------------------
- base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj);
- void OnStartDownload(JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- jboolean jis_link);
- void SearchForImage(JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj);
- void RetrieveImageForShare(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- const base::android::JavaParamRef<jobject>& jcallback,
- jint max_width_px,
- jint max_height_px,
- jint j_image_type);
- void RetrieveImageForContextMenu(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- const base::android::JavaParamRef<jobject>& jcallback,
- jint max_width_px,
- jint max_height_px);
-
private:
explicit ContextMenuHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<ContextMenuHelper>;
- void RetrieveImageInternal(
- JNIEnv* env,
- const ImageRetrieveCallback& retrieve_callback,
- const base::android::JavaParamRef<jobject>& jcallback,
- jint max_width_px,
- jint max_height_px,
- chrome::mojom::ImageFormat image_format);
-
mojo::AssociatedRemote<chrome::mojom::ChromeRenderFrame>
GetChromeRenderFrame() const;
@@ -95,8 +46,6 @@
content::WebContents* web_contents_;
content::ContextMenuParams context_menu_params_;
- int render_frame_id_;
- int render_process_id_;
WEB_CONTENTS_USER_DATA_KEY_DECL();