mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add target disposition and user gesture parameters to CefLifeSpanHandler::OnBeforePopup (issue #1525).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2053 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -59,20 +59,26 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
cef_base_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the IO thread before a new popup window is created. The |browser|
|
// Called on the IO thread before a new popup browser is created. The
|
||||||
// and |frame| parameters represent the source of the popup request. The
|
// |browser| and |frame| values represent the source of the popup request. The
|
||||||
// |target_url| and |target_frame_name| values may be NULL if none were
|
// |target_url| and |target_frame_name| values indicate where the popup
|
||||||
// specified with the request. The |popupFeatures| structure contains
|
// browser should navigate and may be NULL if not specified with the request.
|
||||||
// information about the requested popup window. To allow creation of the
|
// The |target_disposition| value indicates where the user intended to open
|
||||||
// popup window optionally modify |windowInfo|, |client|, |settings| and
|
// the popup (e.g. current tab, new tab, etc). The |user_gesture| value will
|
||||||
// |no_javascript_access| and return false (0). To cancel creation of the
|
// be true (1) if the popup was opened via explicit user gesture (e.g.
|
||||||
// popup window return true (1). The |client| and |settings| values will
|
// clicking a link) or false (0) if the popup opened automatically (e.g. via
|
||||||
// default to the source browser's values. The |no_javascript_access| value
|
// the DomContentLoaded event). The |popupFeatures| structure contains
|
||||||
// indicates whether the new browser window should be scriptable and in the
|
// additional information about the requested popup window. To allow creation
|
||||||
// same process as the source browser.
|
// of the popup browser optionally modify |windowInfo|, |client|, |settings|
|
||||||
|
// and |no_javascript_access| and return false (0). To cancel creation of the
|
||||||
|
// popup browser return true (1). The |client| and |settings| values will
|
||||||
|
// default to the source browser's values. If the |no_javascript_access| value
|
||||||
|
// is set to false (0) the new browser will not be scriptable and may not be
|
||||||
|
// hosted in the same renderer process as the source browser.
|
||||||
int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self,
|
int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self,
|
||||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
const cef_string_t* target_url, const cef_string_t* target_frame_name,
|
const cef_string_t* target_url, const cef_string_t* target_frame_name,
|
||||||
|
cef_window_open_disposition_t target_disposition, int user_gesture,
|
||||||
const struct _cef_popup_features_t* popupFeatures,
|
const struct _cef_popup_features_t* popupFeatures,
|
||||||
struct _cef_window_info_t* windowInfo, struct _cef_client_t** client,
|
struct _cef_window_info_t* windowInfo, struct _cef_client_t** client,
|
||||||
struct _cef_browser_settings_t* settings, int* no_javascript_access);
|
struct _cef_browser_settings_t* settings, int* no_javascript_access);
|
||||||
|
@ -51,23 +51,32 @@ class CefClient;
|
|||||||
/*--cef(source=client)--*/
|
/*--cef(source=client)--*/
|
||||||
class CefLifeSpanHandler : public virtual CefBase {
|
class CefLifeSpanHandler : public virtual CefBase {
|
||||||
public:
|
public:
|
||||||
|
typedef cef_window_open_disposition_t WindowOpenDisposition;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the IO thread before a new popup window is created. The |browser|
|
// Called on the IO thread before a new popup browser is created. The
|
||||||
// and |frame| parameters represent the source of the popup request. The
|
// |browser| and |frame| values represent the source of the popup request. The
|
||||||
// |target_url| and |target_frame_name| values may be empty if none were
|
// |target_url| and |target_frame_name| values indicate where the popup
|
||||||
// specified with the request. The |popupFeatures| structure contains
|
// browser should navigate and may be empty if not specified with the request.
|
||||||
|
// The |target_disposition| value indicates where the user intended to open
|
||||||
|
// the popup (e.g. current tab, new tab, etc). The |user_gesture| value will
|
||||||
|
// be true if the popup was opened via explicit user gesture (e.g. clicking a
|
||||||
|
// link) or false if the popup opened automatically (e.g. via the
|
||||||
|
// DomContentLoaded event). The |popupFeatures| structure contains additional
|
||||||
// information about the requested popup window. To allow creation of the
|
// information about the requested popup window. To allow creation of the
|
||||||
// popup window optionally modify |windowInfo|, |client|, |settings| and
|
// popup browser optionally modify |windowInfo|, |client|, |settings| and
|
||||||
// |no_javascript_access| and return false. To cancel creation of the popup
|
// |no_javascript_access| and return false. To cancel creation of the popup
|
||||||
// window return true. The |client| and |settings| values will default to the
|
// browser return true. The |client| and |settings| values will default to the
|
||||||
// source browser's values. The |no_javascript_access| value indicates whether
|
// source browser's values. If the |no_javascript_access| value is set to
|
||||||
// the new browser window should be scriptable and in the same process as the
|
// false the new browser will not be scriptable and may not be hosted in the
|
||||||
// source browser.
|
// same renderer process as the source browser.
|
||||||
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
|
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
|
||||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url,
|
const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
|
WindowOpenDisposition target_disposition,
|
||||||
|
bool user_gesture,
|
||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
CefWindowInfo& windowInfo,
|
CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client,
|
CefRefPtr<CefClient>& client,
|
||||||
|
@ -893,6 +893,23 @@ typedef enum {
|
|||||||
ERR_INSECURE_RESPONSE = -501,
|
ERR_INSECURE_RESPONSE = -501,
|
||||||
} cef_errorcode_t;
|
} cef_errorcode_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// The manner in which a link click should be opened.
|
||||||
|
///
|
||||||
|
typedef enum {
|
||||||
|
WOD_UNKNOWN,
|
||||||
|
WOD_SUPPRESS_OPEN,
|
||||||
|
WOD_CURRENT_TAB,
|
||||||
|
WOD_SINGLETON_TAB,
|
||||||
|
WOD_NEW_FOREGROUND_TAB,
|
||||||
|
WOD_NEW_BACKGROUND_TAB,
|
||||||
|
WOD_NEW_POPUP,
|
||||||
|
WOD_NEW_WINDOW,
|
||||||
|
WOD_SAVE_TO_DISK,
|
||||||
|
WOD_OFF_THE_RECORD,
|
||||||
|
WOD_IGNORE_ACTION
|
||||||
|
} cef_window_open_disposition_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// "Verb" of a drag-and-drop operation as negotiated between the source and
|
// "Verb" of a drag-and-drop operation as negotiated between the source and
|
||||||
// destination. These constants match their equivalents in WebCore's
|
// destination. These constants match their equivalents in WebCore's
|
||||||
|
@ -901,6 +901,8 @@ bool CefContentBrowserClient::CanCreateWindow(
|
|||||||
frame,
|
frame,
|
||||||
last_create_window_params_.target_url.spec(),
|
last_create_window_params_.target_url.spec(),
|
||||||
last_create_window_params_.target_frame_name,
|
last_create_window_params_.target_frame_name,
|
||||||
|
static_cast<cef_window_open_disposition_t>(disposition),
|
||||||
|
user_gesture,
|
||||||
cef_features,
|
cef_features,
|
||||||
pending_info->window_info,
|
pending_info->window_info,
|
||||||
pending_info->client,
|
pending_info->client,
|
||||||
|
@ -22,6 +22,7 @@ int CEF_CALLBACK life_span_handler_on_before_popup(
|
|||||||
struct _cef_life_span_handler_t* self, cef_browser_t* browser,
|
struct _cef_life_span_handler_t* self, cef_browser_t* browser,
|
||||||
cef_frame_t* frame, const cef_string_t* target_url,
|
cef_frame_t* frame, const cef_string_t* target_url,
|
||||||
const cef_string_t* target_frame_name,
|
const cef_string_t* target_frame_name,
|
||||||
|
cef_window_open_disposition_t target_disposition, int user_gesture,
|
||||||
const struct _cef_popup_features_t* popupFeatures,
|
const struct _cef_popup_features_t* popupFeatures,
|
||||||
cef_window_info_t* windowInfo, cef_client_t** client,
|
cef_window_info_t* windowInfo, cef_client_t** client,
|
||||||
struct _cef_browser_settings_t* settings, int* no_javascript_access) {
|
struct _cef_browser_settings_t* settings, int* no_javascript_access) {
|
||||||
@ -87,6 +88,8 @@ int CEF_CALLBACK life_span_handler_on_before_popup(
|
|||||||
CefFrameCToCpp::Wrap(frame),
|
CefFrameCToCpp::Wrap(frame),
|
||||||
CefString(target_url),
|
CefString(target_url),
|
||||||
CefString(target_frame_name),
|
CefString(target_frame_name),
|
||||||
|
target_disposition,
|
||||||
|
user_gesture?true:false,
|
||||||
popupFeaturesObj,
|
popupFeaturesObj,
|
||||||
windowInfoObj,
|
windowInfoObj,
|
||||||
clientPtr,
|
clientPtr,
|
||||||
|
@ -20,9 +20,11 @@
|
|||||||
|
|
||||||
bool CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
bool CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame, const CefString& target_url,
|
CefRefPtr<CefFrame> frame, const CefString& target_url,
|
||||||
const CefString& target_frame_name, const CefPopupFeatures& popupFeatures,
|
const CefString& target_frame_name,
|
||||||
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
|
WindowOpenDisposition target_disposition, bool user_gesture,
|
||||||
CefBrowserSettings& settings, bool* no_javascript_access) {
|
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||||
|
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
|
||||||
|
bool* no_javascript_access) {
|
||||||
if (CEF_MEMBER_MISSING(struct_, on_before_popup))
|
if (CEF_MEMBER_MISSING(struct_, on_before_popup))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -56,6 +58,8 @@ bool CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|||||||
CefFrameCppToC::Wrap(frame),
|
CefFrameCppToC::Wrap(frame),
|
||||||
target_url.GetStruct(),
|
target_url.GetStruct(),
|
||||||
target_frame_name.GetStruct(),
|
target_frame_name.GetStruct(),
|
||||||
|
target_disposition,
|
||||||
|
user_gesture,
|
||||||
&popupFeatures,
|
&popupFeatures,
|
||||||
&windowInfo,
|
&windowInfo,
|
||||||
&clientStruct,
|
&clientStruct,
|
||||||
|
@ -37,6 +37,7 @@ class CefLifeSpanHandlerCToCpp
|
|||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url, const CefString& target_frame_name,
|
const CefString& target_url, const CefString& target_frame_name,
|
||||||
|
WindowOpenDisposition target_disposition, bool user_gesture,
|
||||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
|
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
|
||||||
bool* no_javascript_access) override;
|
bool* no_javascript_access) override;
|
||||||
|
@ -326,6 +326,8 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url,
|
const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
|
WindowOpenDisposition target_disposition,
|
||||||
|
bool user_gesture,
|
||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
CefWindowInfo& windowInfo,
|
CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client,
|
CefRefPtr<CefClient>& client,
|
||||||
|
@ -170,6 +170,8 @@ class ClientHandler : public CefClient,
|
|||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url,
|
const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
|
WindowOpenDisposition target_disposition,
|
||||||
|
bool user_gesture,
|
||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
CefWindowInfo& windowInfo,
|
CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client,
|
CefRefPtr<CefClient>& client,
|
||||||
|
@ -1805,6 +1805,8 @@ class PopupNavTestHandler : public TestHandler {
|
|||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url,
|
const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
|
WindowOpenDisposition target_disposition,
|
||||||
|
bool user_gesture,
|
||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
CefWindowInfo& windowInfo,
|
CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client,
|
CefRefPtr<CefClient>& client,
|
||||||
@ -1817,6 +1819,8 @@ class PopupNavTestHandler : public TestHandler {
|
|||||||
EXPECT_STREQ(kPopupNavPageUrl, frame->GetURL().ToString().c_str());
|
EXPECT_STREQ(kPopupNavPageUrl, frame->GetURL().ToString().c_str());
|
||||||
EXPECT_STREQ(kPopupNavPopupUrl, target_url.ToString().c_str());
|
EXPECT_STREQ(kPopupNavPopupUrl, target_url.ToString().c_str());
|
||||||
EXPECT_STREQ(kPopupNavPopupName, target_frame_name.ToString().c_str());
|
EXPECT_STREQ(kPopupNavPopupName, target_frame_name.ToString().c_str());
|
||||||
|
EXPECT_EQ(WOD_NEW_FOREGROUND_TAB, target_disposition);
|
||||||
|
EXPECT_FALSE(user_gesture);
|
||||||
EXPECT_FALSE(*no_javascript_access);
|
EXPECT_FALSE(*no_javascript_access);
|
||||||
|
|
||||||
return (mode_ == DENY); // Return true to cancel the popup.
|
return (mode_ == DENY); // Return true to cancel the popup.
|
||||||
|
@ -475,6 +475,8 @@ class PopupTestHandler : public TestHandler {
|
|||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url,
|
const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
|
WindowOpenDisposition target_disposition,
|
||||||
|
bool user_gesture,
|
||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
CefWindowInfo& windowInfo,
|
CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client,
|
CefRefPtr<CefClient>& client,
|
||||||
@ -484,6 +486,14 @@ class PopupTestHandler : public TestHandler {
|
|||||||
|
|
||||||
const std::string& url = target_url;
|
const std::string& url = target_url;
|
||||||
EXPECT_STREQ(url.c_str(), popup_url_.c_str());
|
EXPECT_STREQ(url.c_str(), popup_url_.c_str());
|
||||||
|
|
||||||
|
EXPECT_EQ(WOD_NEW_FOREGROUND_TAB, target_disposition);
|
||||||
|
|
||||||
|
if (mode_ == MODE_WINDOW_OPEN)
|
||||||
|
EXPECT_FALSE(user_gesture);
|
||||||
|
else
|
||||||
|
EXPECT_TRUE(user_gesture);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user