From d6fc4a4c16b5309bb4f8bc76fc1bf2a02a364432 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 17 Jan 2017 12:43:49 -0500 Subject: [PATCH] Add CefContextMenuParams::GetTitleText method (issue #2030) --- include/capi/cef_context_menu_handler_capi.h | 8 ++++++++ include/cef_context_menu_handler.h | 7 +++++++ libcef/browser/context_menu_params_impl.cc | 5 +++++ libcef/browser/context_menu_params_impl.h | 1 + libcef_dll/cpptoc/context_menu_params_cpptoc.cc | 16 ++++++++++++++++ libcef_dll/ctocpp/context_menu_params_ctocpp.cc | 16 ++++++++++++++++ libcef_dll/ctocpp/context_menu_params_ctocpp.h | 1 + 7 files changed, 54 insertions(+) diff --git a/include/capi/cef_context_menu_handler_capi.h b/include/capi/cef_context_menu_handler_capi.h index 6ac55c013..7670d80d0 100644 --- a/include/capi/cef_context_menu_handler_capi.h +++ b/include/capi/cef_context_menu_handler_capi.h @@ -192,6 +192,14 @@ typedef struct _cef_context_menu_params_t { int (CEF_CALLBACK *has_image_contents)( struct _cef_context_menu_params_t* self); + /// + // Returns the title text or the alt text if the context menu was invoked on + // an image. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_title_text)( + struct _cef_context_menu_params_t* self); + /// // Returns the URL of the top level page that the context menu was invoked on. /// diff --git a/include/cef_context_menu_handler.h b/include/cef_context_menu_handler.h index ab4503577..2bad463b1 100644 --- a/include/cef_context_menu_handler.h +++ b/include/cef_context_menu_handler.h @@ -195,6 +195,13 @@ class CefContextMenuParams : public virtual CefBase { /*--cef()--*/ virtual bool HasImageContents() =0; + /// + // Returns the title text or the alt text if the context menu was invoked on + // an image. + /// + /*--cef()--*/ + virtual CefString GetTitleText() = 0; + /// // Returns the URL of the top level page that the context menu was invoked on. /// diff --git a/libcef/browser/context_menu_params_impl.cc b/libcef/browser/context_menu_params_impl.cc index bdca98f34..1ab4c1858 100644 --- a/libcef/browser/context_menu_params_impl.cc +++ b/libcef/browser/context_menu_params_impl.cc @@ -64,6 +64,11 @@ bool CefContextMenuParamsImpl::HasImageContents() { return const_value().has_image_contents; } +CefString CefContextMenuParamsImpl::GetTitleText() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().title_text; +} + CefString CefContextMenuParamsImpl::GetPageUrl() { CEF_VALUE_VERIFY_RETURN(false, CefString()); return const_value().page_url.spec(); diff --git a/libcef/browser/context_menu_params_impl.h b/libcef/browser/context_menu_params_impl.h index 2dbeac2da..71fb29226 100644 --- a/libcef/browser/context_menu_params_impl.h +++ b/libcef/browser/context_menu_params_impl.h @@ -25,6 +25,7 @@ class CefContextMenuParamsImpl CefString GetUnfilteredLinkUrl() override; CefString GetSourceUrl() override; bool HasImageContents() override; + CefString GetTitleText() override; CefString GetPageUrl() override; CefString GetFrameUrl() override; CefString GetFrameCharset() override; diff --git a/libcef_dll/cpptoc/context_menu_params_cpptoc.cc b/libcef_dll/cpptoc/context_menu_params_cpptoc.cc index e9a9f7390..17a41fa50 100644 --- a/libcef_dll/cpptoc/context_menu_params_cpptoc.cc +++ b/libcef_dll/cpptoc/context_menu_params_cpptoc.cc @@ -125,6 +125,21 @@ int CEF_CALLBACK context_menu_params_has_image_contents( return _retval; } +cef_string_userfree_t CEF_CALLBACK context_menu_params_get_title_text( + struct _cef_context_menu_params_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefContextMenuParamsCppToC::Get(self)->GetTitleText(); + + // Return type: string + return _retval.DetachToUserFree(); +} + cef_string_userfree_t CEF_CALLBACK context_menu_params_get_page_url( struct _cef_context_menu_params_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -352,6 +367,7 @@ CefContextMenuParamsCppToC::CefContextMenuParamsCppToC() { context_menu_params_get_unfiltered_link_url; GetStruct()->get_source_url = context_menu_params_get_source_url; GetStruct()->has_image_contents = context_menu_params_has_image_contents; + GetStruct()->get_title_text = context_menu_params_get_title_text; GetStruct()->get_page_url = context_menu_params_get_page_url; GetStruct()->get_frame_url = context_menu_params_get_frame_url; GetStruct()->get_frame_charset = context_menu_params_get_frame_charset; diff --git a/libcef_dll/ctocpp/context_menu_params_ctocpp.cc b/libcef_dll/ctocpp/context_menu_params_ctocpp.cc index 3549b33b8..45620a14e 100644 --- a/libcef_dll/ctocpp/context_menu_params_ctocpp.cc +++ b/libcef_dll/ctocpp/context_menu_params_ctocpp.cc @@ -120,6 +120,22 @@ bool CefContextMenuParamsCToCpp::HasImageContents() { return _retval?true:false; } +CefString CefContextMenuParamsCToCpp::GetTitleText() { + cef_context_menu_params_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_title_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = _struct->get_title_text(_struct); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + CefString CefContextMenuParamsCToCpp::GetPageUrl() { cef_context_menu_params_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_page_url)) diff --git a/libcef_dll/ctocpp/context_menu_params_ctocpp.h b/libcef_dll/ctocpp/context_menu_params_ctocpp.h index 69651df43..a0e00a52b 100644 --- a/libcef_dll/ctocpp/context_menu_params_ctocpp.h +++ b/libcef_dll/ctocpp/context_menu_params_ctocpp.h @@ -39,6 +39,7 @@ class CefContextMenuParamsCToCpp CefString GetUnfilteredLinkUrl() OVERRIDE; CefString GetSourceUrl() OVERRIDE; bool HasImageContents() OVERRIDE; + CefString GetTitleText() OVERRIDE; CefString GetPageUrl() OVERRIDE; CefString GetFrameUrl() OVERRIDE; CefString GetFrameCharset() OVERRIDE;