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:
Marshall Greenblatt 2015-03-06 21:38:38 +00:00
parent 36fd5e3ed0
commit 5de989e306
11 changed files with 83 additions and 23 deletions

View File

@ -59,20 +59,26 @@ typedef struct _cef_life_span_handler_t {
cef_base_t base;
///
// Called on the IO thread before a new popup window is created. The |browser|
// and |frame| parameters represent the source of the popup request. The
// |target_url| and |target_frame_name| values may be NULL if none were
// specified with the request. The |popupFeatures| structure contains
// information about the requested popup window. To allow creation of the
// popup window optionally modify |windowInfo|, |client|, |settings| and
// |no_javascript_access| and return false (0). To cancel creation of the
// popup window return true (1). The |client| and |settings| values will
// default to the source browser's values. The |no_javascript_access| value
// indicates whether the new browser window should be scriptable and in the
// same process as the source browser.
// Called on the IO thread before a new popup browser is created. The
// |browser| and |frame| values represent the source of the popup request. The
// |target_url| and |target_frame_name| values indicate where the popup
// browser should navigate and may be NULL 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 (1) if the popup was opened via explicit user gesture (e.g.
// clicking a link) or false (0) 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 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,
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
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,
struct _cef_window_info_t* windowInfo, struct _cef_client_t** client,
struct _cef_browser_settings_t* settings, int* no_javascript_access);

View File

@ -51,23 +51,32 @@ class CefClient;
/*--cef(source=client)--*/
class CefLifeSpanHandler : public virtual CefBase {
public:
typedef cef_window_open_disposition_t WindowOpenDisposition;
///
// Called on the IO thread before a new popup window is created. The |browser|
// and |frame| parameters represent the source of the popup request. The
// |target_url| and |target_frame_name| values may be empty if none were
// specified with the request. The |popupFeatures| structure contains
// Called on the IO thread before a new popup browser is created. The
// |browser| and |frame| values represent the source of the popup request. The
// |target_url| and |target_frame_name| values indicate where the popup
// 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
// 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
// window return true. The |client| and |settings| values will default to the
// source browser's values. The |no_javascript_access| value indicates whether
// the new browser window should be scriptable and in the same process as the
// source browser.
// browser return true. The |client| and |settings| values will default to the
// source browser's values. If the |no_javascript_access| value is set to
// false the new browser will not be scriptable and may not be hosted in the
// same renderer process as the source browser.
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,

View File

@ -893,6 +893,23 @@ typedef enum {
ERR_INSECURE_RESPONSE = -501,
} 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
// destination. These constants match their equivalents in WebCore's

View File

@ -901,6 +901,8 @@ bool CefContentBrowserClient::CanCreateWindow(
frame,
last_create_window_params_.target_url.spec(),
last_create_window_params_.target_frame_name,
static_cast<cef_window_open_disposition_t>(disposition),
user_gesture,
cef_features,
pending_info->window_info,
pending_info->client,

View File

@ -22,6 +22,7 @@ int CEF_CALLBACK life_span_handler_on_before_popup(
struct _cef_life_span_handler_t* self, cef_browser_t* browser,
cef_frame_t* frame, 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,
cef_window_info_t* windowInfo, cef_client_t** client,
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),
CefString(target_url),
CefString(target_frame_name),
target_disposition,
user_gesture?true:false,
popupFeaturesObj,
windowInfoObj,
clientPtr,

View File

@ -20,9 +20,11 @@
bool CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, const CefString& target_url,
const CefString& target_frame_name, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
CefBrowserSettings& settings, bool* no_javascript_access) {
const CefString& target_frame_name,
WindowOpenDisposition target_disposition, bool user_gesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
bool* no_javascript_access) {
if (CEF_MEMBER_MISSING(struct_, on_before_popup))
return false;
@ -56,6 +58,8 @@ bool CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefFrameCppToC::Wrap(frame),
target_url.GetStruct(),
target_frame_name.GetStruct(),
target_disposition,
user_gesture,
&popupFeatures,
&windowInfo,
&clientStruct,

View File

@ -37,6 +37,7 @@ class CefLifeSpanHandlerCToCpp
// CefLifeSpanHandler methods
bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const CefString& target_url, const CefString& target_frame_name,
WindowOpenDisposition target_disposition, bool user_gesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
bool* no_javascript_access) override;

View File

@ -326,6 +326,8 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,

View File

@ -170,6 +170,8 @@ class ClientHandler : public CefClient,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,

View File

@ -1805,6 +1805,8 @@ class PopupNavTestHandler : public TestHandler {
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
@ -1817,6 +1819,8 @@ class PopupNavTestHandler : public TestHandler {
EXPECT_STREQ(kPopupNavPageUrl, frame->GetURL().ToString().c_str());
EXPECT_STREQ(kPopupNavPopupUrl, target_url.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);
return (mode_ == DENY); // Return true to cancel the popup.

View File

@ -475,6 +475,8 @@ class PopupTestHandler : public TestHandler {
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
@ -484,6 +486,14 @@ class PopupTestHandler : public TestHandler {
const std::string& url = target_url;
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;
}