Fix popup window behavioral errors introduced by revision 1085 changes (issue #816).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1093 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
88025e3283
commit
6604af5462
|
@ -59,38 +59,21 @@ typedef struct _cef_life_span_handler_t {
|
||||||
///
|
///
|
||||||
// Called on the IO thread before a new popup window is created. The |browser|
|
// 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
|
// and |frame| parameters represent the source of the popup request. The
|
||||||
// |target_url| and |target_frame_name| values may be NULL if none was
|
// |target_url| and |target_frame_name| values may be NULL if none were
|
||||||
// specified with the request. Return true (1) to allow creation of the popup
|
// specified with the request. The |popupFeatures| structure contains
|
||||||
// window or false (0) to cancel creation. If true (1) is returned,
|
// information about the requested popup window. To allow creation of the
|
||||||
// |no_javascript_access| will indicate whether the window that is created
|
// popup window optionally modify |windowInfo|, |client|, |settings| and
|
||||||
// should be scriptable/in the same process as the source browser. Do not
|
// |no_javascript_access| and return false (0). To cancel creation of the
|
||||||
// perform blocking work in this callback as it will block the associated
|
// popup window return true (1). The |client| and |settings| values will
|
||||||
// render process. To completely disable popup windows for a browser set
|
// default to the source browser's values. The |no_javascript_access| value
|
||||||
// cef_browser_tSettings.javascript_open_windows to STATE_DISABLED.
|
// indicates whether the new browser window should be scriptable and in the
|
||||||
///
|
// same process as the source browser.
|
||||||
int (CEF_CALLBACK *can_create_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,
|
||||||
int* no_javascript_access);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called before the cef_browser_host_t object associated with a new popup
|
|
||||||
// window is created. This function will only be called in can_create_popup()
|
|
||||||
// returns true (1). The |browser| parameter represents the source of the
|
|
||||||
// popup request. The |popupFeatures| parameter will contain information about
|
|
||||||
// the style of popup window requested. The framework will create the new
|
|
||||||
// popup window based on the parameters in |windowInfo|. By default, a newly
|
|
||||||
// created popup window will have the same client and settings as the parent
|
|
||||||
// window. To change the client for the new window modify the object that
|
|
||||||
// |client| points to. To change the settings for the new window modify the
|
|
||||||
// |settings| structure.
|
|
||||||
///
|
|
||||||
void (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
const struct _cef_popup_features_t* popupFeatures,
|
const struct _cef_popup_features_t* popupFeatures,
|
||||||
struct _cef_window_info_t* windowInfo, const cef_string_t* target_url,
|
struct _cef_window_info_t* windowInfo, struct _cef_client_t** client,
|
||||||
const cef_string_t* target_frame_name, struct _cef_client_t** client,
|
struct _cef_browser_settings_t* settings, int* no_javascript_access);
|
||||||
struct _cef_browser_settings_t* settings);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after a new window is created.
|
// Called after a new window is created.
|
||||||
|
|
|
@ -54,44 +54,27 @@ class CefLifeSpanHandler : public virtual CefBase {
|
||||||
///
|
///
|
||||||
// Called on the IO thread before a new popup window is created. The |browser|
|
// 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
|
// and |frame| parameters represent the source of the popup request. The
|
||||||
// |target_url| and |target_frame_name| values may be empty if none was
|
// |target_url| and |target_frame_name| values may be empty if none were
|
||||||
// specified with the request. Return true to allow creation of the popup
|
// specified with the request. The |popupFeatures| structure contains
|
||||||
// window or false to cancel creation. If true is returned,
|
// information about the requested popup window. To allow creation of the
|
||||||
// |no_javascript_access| will indicate whether the window that is created
|
// popup window optionally modify |windowInfo|, |client|, |settings| and
|
||||||
// should be scriptable/in the same process as the source browser. Do not
|
// |no_javascript_access| and return false. To cancel creation of the popup
|
||||||
// perform blocking work in this callback as it will block the associated
|
// window return true. The |client| and |settings| values will default to the
|
||||||
// render process. To completely disable popup windows for a browser set
|
// source browser's values. The |no_javascript_access| value indicates whether
|
||||||
// CefBrowserSettings.javascript_open_windows to STATE_DISABLED.
|
// the new browser window should be scriptable and in the same 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 CanCreatePopup(CefRefPtr<CefBrowser> browser,
|
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& target_url,
|
|
||||||
const CefString& target_frame_name,
|
|
||||||
bool* no_javascript_access) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called before the CefBrowserHost object associated with a new popup window
|
|
||||||
// is created. This method will only be called in CanCreatePopup() returns
|
|
||||||
// true. The |browser| parameter represents the source of the popup request.
|
|
||||||
// The |popupFeatures| parameter will contain information about the style of
|
|
||||||
// popup window requested. The framework will create the new popup window
|
|
||||||
// based on the parameters in |windowInfo|. By default, a newly created popup
|
|
||||||
// window will have the same client and settings as the parent window. To
|
|
||||||
// change the client for the new window modify the object that |client| points
|
|
||||||
// to. To change the settings for the new window modify the |settings|
|
|
||||||
// structure.
|
|
||||||
///
|
|
||||||
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
|
|
||||||
virtual void OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|
||||||
const CefPopupFeatures& popupFeatures,
|
|
||||||
CefWindowInfo& windowInfo,
|
|
||||||
const CefString& target_url,
|
const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
|
const CefPopupFeatures& popupFeatures,
|
||||||
|
CefWindowInfo& windowInfo,
|
||||||
CefRefPtr<CefClient>& client,
|
CefRefPtr<CefClient>& client,
|
||||||
CefBrowserSettings& settings) {}
|
CefBrowserSettings& settings,
|
||||||
|
bool* no_javascript_access) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after a new window is created.
|
// Called after a new window is created.
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ void CefBrowserHostImpl::Navigate(const CefNavigateParams& params) {
|
||||||
CefMsg_LoadRequest_Params request;
|
CefMsg_LoadRequest_Params request;
|
||||||
request.url = params.url;
|
request.url = params.url;
|
||||||
if (!request.url.is_valid()) {
|
if (!request.url.is_valid()) {
|
||||||
DLOG(ERROR) << "Invalid URL passed to CefBrowserHostImpl::Navigate: " <<
|
LOG(ERROR) << "Invalid URL passed to CefBrowserHostImpl::Navigate: " <<
|
||||||
params.url;
|
params.url;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1130,7 +1130,7 @@ void CefBrowserHostImpl::LoadURL(int64 frame_id, const std::string& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gurl.is_valid()) {
|
if (!gurl.is_valid()) {
|
||||||
DLOG(ERROR) <<
|
LOG(ERROR) <<
|
||||||
"Invalid URL passed to CefBrowserHostImpl::LoadURL: " << url;
|
"Invalid URL passed to CefBrowserHostImpl::LoadURL: " << url;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1491,56 +1491,13 @@ bool CefBrowserHostImpl::ShouldCreateWebContents(
|
||||||
WindowContainerType window_container_type,
|
WindowContainerType window_container_type,
|
||||||
const string16& frame_name,
|
const string16& frame_name,
|
||||||
const GURL& target_url) {
|
const GURL& target_url) {
|
||||||
// Start with the current browser window's client and settings.
|
CefContentBrowserClient::Get()->GetOrCreateBrowserInfo(
|
||||||
pending_client_ = client_;
|
web_contents->GetRenderProcessHost()->GetID(), route_id);
|
||||||
pending_settings_ = settings_;
|
|
||||||
|
|
||||||
// TODO(cef): Figure out how to populate these values.
|
|
||||||
// See: http://crbug.com/110510
|
|
||||||
CefPopupFeatures features;
|
|
||||||
|
|
||||||
pending_window_info_ = CefWindowInfo();
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
pending_window_info_.SetAsPopup(NULL, CefString());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(OS_WIN) || defined(OS_MACOSX))
|
|
||||||
// Default to the size from the popup features.
|
|
||||||
if (features.xSet)
|
|
||||||
pending_window_info_.x = features.x;
|
|
||||||
if (features.ySet)
|
|
||||||
pending_window_info_.y = features.y;
|
|
||||||
if (features.widthSet)
|
|
||||||
pending_window_info_.width = features.width;
|
|
||||||
if (features.heightSet)
|
|
||||||
pending_window_info_.height = features.height;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (client_.get()) {
|
|
||||||
CefRefPtr<CefLifeSpanHandler> handler = client_->GetLifeSpanHandler();
|
|
||||||
// Give the handler an opportunity to modify window attributes, handler,
|
|
||||||
// or cancel the window creation.
|
|
||||||
if (handler.get()) {
|
|
||||||
handler->OnBeforePopup(this, features, pending_window_info_,
|
|
||||||
target_url.spec(), frame_name,
|
|
||||||
pending_client_, pending_settings_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsWindowRenderingDisabled(pending_window_info_)) {
|
|
||||||
if (!pending_client_->GetRenderHandler().get()) {
|
|
||||||
NOTREACHED() << "CefRenderHandler implementation is required";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (pending_settings_.accelerated_compositing != STATE_DISABLED) {
|
|
||||||
// Accelerated compositing is not supported when window rendering is
|
|
||||||
// disabled.
|
|
||||||
pending_settings_.accelerated_compositing = STATE_DISABLED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
base::AutoLock lock_scope(pending_popup_info_lock_);
|
||||||
|
DCHECK(pending_popup_info_.get());
|
||||||
_Context->browser_context()->set_use_osr_next_contents_view(
|
_Context->browser_context()->set_use_osr_next_contents_view(
|
||||||
IsWindowRenderingDisabled(pending_window_info_));
|
IsWindowRenderingDisabled(pending_popup_info_->window_info));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1550,28 +1507,29 @@ void CefBrowserHostImpl::WebContentsCreated(
|
||||||
int64 source_frame_id,
|
int64 source_frame_id,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
content::WebContents* new_contents) {
|
content::WebContents* new_contents) {
|
||||||
CefWindowHandle opener = NULL;
|
scoped_ptr<PendingPopupInfo> pending_popup_info;
|
||||||
scoped_refptr<CefBrowserInfo> info;
|
{
|
||||||
if (source_contents) {
|
base::AutoLock lock_scope(pending_popup_info_lock_);
|
||||||
opener = GetBrowserForContents(source_contents)->GetWindowHandle();
|
pending_popup_info.reset(pending_popup_info_.release());
|
||||||
|
}
|
||||||
|
DCHECK(pending_popup_info.get());
|
||||||
|
|
||||||
// Popup windows may not have info yet.
|
CefWindowHandle opener = NULL;
|
||||||
info = CefContentBrowserClient::Get()->GetOrCreateBrowserInfo(
|
scoped_refptr<CefBrowserInfo> info =
|
||||||
new_contents->GetRenderProcessHost()->GetID(),
|
CefContentBrowserClient::Get()->GetBrowserInfo(
|
||||||
new_contents->GetRoutingID());
|
new_contents->GetRenderProcessHost()->GetID(),
|
||||||
|
new_contents->GetRoutingID());
|
||||||
|
|
||||||
|
if (source_contents) {
|
||||||
DCHECK(info->is_popup());
|
DCHECK(info->is_popup());
|
||||||
|
opener = GetBrowserForContents(source_contents)->GetWindowHandle();
|
||||||
} else {
|
} else {
|
||||||
info = CefContentBrowserClient::Get()->GetBrowserInfo(
|
|
||||||
new_contents->GetRenderProcessHost()->GetID(),
|
|
||||||
new_contents->GetRoutingID());
|
|
||||||
DCHECK(!info->is_popup());
|
DCHECK(!info->is_popup());
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::Create(
|
CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::Create(
|
||||||
pending_window_info_, pending_settings_, pending_client_, new_contents,
|
pending_popup_info->window_info, pending_popup_info->settings,
|
||||||
info, opener);
|
pending_popup_info->client, new_contents, info, opener);
|
||||||
|
|
||||||
pending_client_ = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
|
void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
|
||||||
|
@ -1599,6 +1557,15 @@ void CefBrowserHostImpl::RunFileChooser(
|
||||||
tab));
|
tab));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CefBrowserHostImpl::SetPendingPopupInfo(
|
||||||
|
scoped_ptr<PendingPopupInfo> info) {
|
||||||
|
base::AutoLock lock_scope(pending_popup_info_lock_);
|
||||||
|
if (pending_popup_info_.get())
|
||||||
|
return false;
|
||||||
|
pending_popup_info_.reset(info.release());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source,
|
void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source,
|
||||||
const gfx::Size& pref_size) {
|
const gfx::Size& pref_size) {
|
||||||
PlatformSizeTo(pref_size.width(), pref_size.height());
|
PlatformSizeTo(pref_size.width(), pref_size.height());
|
||||||
|
|
|
@ -243,6 +243,15 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||||
void RunFileChooser(const content::FileChooserParams& params,
|
void RunFileChooser(const content::FileChooserParams& params,
|
||||||
const RunFileChooserCallback& callback);
|
const RunFileChooserCallback& callback);
|
||||||
|
|
||||||
|
// Used when creating a new popup window.
|
||||||
|
struct PendingPopupInfo {
|
||||||
|
CefWindowInfo window_info;
|
||||||
|
CefBrowserSettings settings;
|
||||||
|
CefRefPtr<CefClient> client;
|
||||||
|
};
|
||||||
|
// Returns false if a popup is already pending.
|
||||||
|
bool SetPendingPopupInfo(scoped_ptr<PendingPopupInfo> info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// content::WebContentsDelegate methods.
|
// content::WebContentsDelegate methods.
|
||||||
virtual content::WebContents* OpenURLFromTab(
|
virtual content::WebContents* OpenURLFromTab(
|
||||||
|
@ -442,10 +451,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||||
scoped_refptr<CefBrowserInfo> browser_info_;
|
scoped_refptr<CefBrowserInfo> browser_info_;
|
||||||
CefWindowHandle opener_;
|
CefWindowHandle opener_;
|
||||||
|
|
||||||
// Used when creating a new popup window.
|
// Pending popup information. Access must be protected by
|
||||||
CefWindowInfo pending_window_info_;
|
// |pending_popup_info_lock_|.
|
||||||
CefBrowserSettings pending_settings_;
|
base::Lock pending_popup_info_lock_;
|
||||||
CefRefPtr<CefClient> pending_client_;
|
scoped_ptr<PendingPopupInfo> pending_popup_info_;
|
||||||
|
|
||||||
// Volatile state information. All access must be protected by the state lock.
|
// Volatile state information. All access must be protected by the state lock.
|
||||||
base::Lock state_lock_;
|
base::Lock state_lock_;
|
||||||
|
|
|
@ -85,7 +85,7 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) {
|
if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) {
|
||||||
devtools_delegate_ = new CefDevToolsDelegate(port);
|
devtools_delegate_ = new CefDevToolsDelegate(port);
|
||||||
} else {
|
} else {
|
||||||
DLOG(WARNING) << "Invalid http debugger port number " << port;
|
LOG(WARNING) << "Invalid http debugger port number " << port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||||
OnGetNewRenderThreadInfo)
|
OnGetNewRenderThreadInfo)
|
||||||
IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewBrowserInfo,
|
IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewBrowserInfo,
|
||||||
OnGetNewBrowserInfo)
|
OnGetNewBrowserInfo)
|
||||||
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow)
|
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_CreateWindow, OnCreateWindow)
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
IPC_END_MESSAGE_MAP()
|
IPC_END_MESSAGE_MAP()
|
||||||
return handled;
|
return handled;
|
||||||
|
@ -86,13 +86,15 @@ void CefBrowserMessageFilter::OnGetNewBrowserInfo(
|
||||||
|
|
||||||
void CefBrowserMessageFilter::OnCreateWindow(
|
void CefBrowserMessageFilter::OnCreateWindow(
|
||||||
const ViewHostMsg_CreateWindow_Params& params,
|
const ViewHostMsg_CreateWindow_Params& params,
|
||||||
int* route_id,
|
IPC::Message* reply_msg) {
|
||||||
int* surface_id,
|
|
||||||
int64* cloned_session_storage_namespace_id) {
|
|
||||||
CefContentBrowserClient::LastCreateWindowParams lcwp;
|
CefContentBrowserClient::LastCreateWindowParams lcwp;
|
||||||
lcwp.opener_id = params.opener_id;
|
lcwp.opener_process_id = host_->GetID();
|
||||||
|
lcwp.opener_view_id = params.opener_id;
|
||||||
lcwp.opener_frame_id = params.opener_frame_id;
|
lcwp.opener_frame_id = params.opener_frame_id;
|
||||||
lcwp.target_url = params.target_url;
|
lcwp.target_url = params.target_url;
|
||||||
lcwp.target_frame_name = params.frame_name;
|
lcwp.target_frame_name = params.frame_name;
|
||||||
CefContentBrowserClient::Get()->set_last_create_window_params(lcwp);
|
CefContentBrowserClient::Get()->set_last_create_window_params(lcwp);
|
||||||
|
|
||||||
|
// Reply message is not used.
|
||||||
|
delete reply_msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,7 @@ class CefBrowserMessageFilter : public IPC::ChannelProxy::MessageFilter {
|
||||||
void OnGetNewBrowserInfo(int routing_id,
|
void OnGetNewBrowserInfo(int routing_id,
|
||||||
CefProcessHostMsg_GetNewBrowserInfo_Params* params);
|
CefProcessHostMsg_GetNewBrowserInfo_Params* params);
|
||||||
void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params,
|
void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params,
|
||||||
int* route_id,
|
IPC::Message* reply_msg);
|
||||||
int* surface_id,
|
|
||||||
int64* cloned_session_storage_namespace_id);
|
|
||||||
|
|
||||||
content::RenderProcessHost* host_;
|
content::RenderProcessHost* host_;
|
||||||
IPC::Channel* channel_;
|
IPC::Channel* channel_;
|
||||||
|
|
|
@ -210,7 +210,7 @@ class Delegate : public InternalHandlerDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handled && domain != CHROME_VERSION) {
|
if (!handled && domain != CHROME_VERSION) {
|
||||||
DLOG(INFO) << "Reguest for unknown chrome resource: " <<
|
LOG(INFO) << "Reguest for unknown chrome resource: " <<
|
||||||
url.spec().c_str();
|
url.spec().c_str();
|
||||||
action->redirect_url =
|
action->redirect_url =
|
||||||
GURL(std::string(kChromeURL) + kChromeVersionDomain);
|
GURL(std::string(kChromeURL) + kChromeVersionDomain);
|
||||||
|
|
|
@ -253,7 +253,7 @@ CefContentBrowserClient::CefContentBrowserClient()
|
||||||
content::PluginServiceImpl::GetInstance()->SetFilter(
|
content::PluginServiceImpl::GetInstance()->SetFilter(
|
||||||
plugin_service_filter_.get());
|
plugin_service_filter_.get());
|
||||||
|
|
||||||
last_create_window_params_.opener_id = MSG_ROUTING_NONE;
|
last_create_window_params_.opener_process_id = MSG_ROUTING_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefContentBrowserClient::~CefContentBrowserClient() {
|
CefContentBrowserClient::~CefContentBrowserClient() {
|
||||||
|
@ -354,8 +354,8 @@ scoped_refptr<CefBrowserInfo> CefContentBrowserClient::GetBrowserInfo(
|
||||||
return browser_info;
|
return browser_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLOG(WARNING) << "No browser info matching process id " <<
|
LOG(WARNING) << "No browser info matching process id " <<
|
||||||
render_process_id << " and view id " << render_view_id;
|
render_process_id << " and view id " << render_view_id;
|
||||||
|
|
||||||
return scoped_refptr<CefBrowserInfo>();
|
return scoped_refptr<CefBrowserInfo>();
|
||||||
}
|
}
|
||||||
|
@ -467,35 +467,92 @@ bool CefContentBrowserClient::CanCreateWindow(
|
||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
*no_javascript_access = false;
|
*no_javascript_access = false;
|
||||||
|
|
||||||
DCHECK_NE(last_create_window_params_.opener_id, MSG_ROUTING_NONE);
|
DCHECK_NE(last_create_window_params_.opener_process_id, MSG_ROUTING_NONE);
|
||||||
if (last_create_window_params_.opener_id == MSG_ROUTING_NONE)
|
if (last_create_window_params_.opener_process_id == MSG_ROUTING_NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser =
|
CefRefPtr<CefBrowserHostImpl> browser =
|
||||||
CefBrowserHostImpl::GetBrowserByRoutingID(
|
CefBrowserHostImpl::GetBrowserByRoutingID(
|
||||||
render_process_id,
|
last_create_window_params_.opener_process_id,
|
||||||
last_create_window_params_.opener_id);
|
last_create_window_params_.opener_view_id);
|
||||||
DCHECK(browser.get());
|
DCHECK(browser.get());
|
||||||
if (!browser.get())
|
if (!browser.get()) {
|
||||||
|
LOG(WARNING) << "CanCreateWindow called before browser was created";
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
bool allow = true;
|
|
||||||
|
|
||||||
CefRefPtr<CefClient> client = browser->GetClient();
|
CefRefPtr<CefClient> client = browser->GetClient();
|
||||||
|
bool allow = true;
|
||||||
|
|
||||||
|
scoped_ptr<CefBrowserHostImpl::PendingPopupInfo> pending_info;
|
||||||
|
pending_info.reset(new CefBrowserHostImpl::PendingPopupInfo);
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
pending_info->window_info.SetAsPopup(NULL, CefString());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Start with the current browser's settings.
|
||||||
|
pending_info->client = client;
|
||||||
|
pending_info->settings = browser->settings();
|
||||||
|
|
||||||
if (client.get()) {
|
if (client.get()) {
|
||||||
CefRefPtr<CefLifeSpanHandler> handler = client->GetLifeSpanHandler();
|
CefRefPtr<CefLifeSpanHandler> handler = client->GetLifeSpanHandler();
|
||||||
if (handler.get()) {
|
if (handler.get()) {
|
||||||
CefRefPtr<CefFrame> frame =
|
CefRefPtr<CefFrame> frame =
|
||||||
browser->GetFrame(last_create_window_params_.opener_frame_id);
|
browser->GetFrame(last_create_window_params_.opener_frame_id);
|
||||||
allow = handler->CanCreatePopup(browser.get(),
|
|
||||||
|
// TODO(cef): Figure out how to populate CefPopupFeatures.
|
||||||
|
// See: http://crbug.com/110510
|
||||||
|
CefPopupFeatures features;
|
||||||
|
|
||||||
|
#if (defined(OS_WIN) || defined(OS_MACOSX))
|
||||||
|
// Default to the size from the popup features.
|
||||||
|
if (features.xSet)
|
||||||
|
pending_info->window_info.x = features.x;
|
||||||
|
if (features.ySet)
|
||||||
|
pending_info->window_info.y = features.y;
|
||||||
|
if (features.widthSet)
|
||||||
|
pending_info->window_info.width = features.width;
|
||||||
|
if (features.heightSet)
|
||||||
|
pending_info->window_info.height = features.height;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
allow = !handler->OnBeforePopup(browser.get(),
|
||||||
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,
|
||||||
|
features,
|
||||||
|
pending_info->window_info,
|
||||||
|
pending_info->client,
|
||||||
|
pending_info->settings,
|
||||||
no_javascript_access);
|
no_javascript_access);
|
||||||
|
if (allow) {
|
||||||
|
if (CefBrowserHostImpl::IsWindowRenderingDisabled(
|
||||||
|
pending_info->window_info)) {
|
||||||
|
if (!pending_info->client->GetRenderHandler().get()) {
|
||||||
|
NOTREACHED() << "CefRenderHandler implementation is required";
|
||||||
|
allow = false;
|
||||||
|
}
|
||||||
|
if (pending_info->settings.accelerated_compositing != STATE_DISABLED) {
|
||||||
|
// Accelerated compositing is not supported when window rendering is
|
||||||
|
// disabled.
|
||||||
|
pending_info->settings.accelerated_compositing = STATE_DISABLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last_create_window_params_.opener_id = MSG_ROUTING_NONE;
|
if (allow) {
|
||||||
|
CefRefPtr<CefClient> pending_client = pending_info->client;
|
||||||
|
allow = browser->SetPendingPopupInfo(pending_info.Pass());
|
||||||
|
if (!allow) {
|
||||||
|
LOG(WARNING) << "Creation of popup window denied because one is already "
|
||||||
|
"pending.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
last_create_window_params_.opener_process_id = MSG_ROUTING_NONE;
|
||||||
|
|
||||||
return allow;
|
return allow;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||||
// these methods.
|
// these methods.
|
||||||
// During popup window creation there is a race between the call to
|
// During popup window creation there is a race between the call to
|
||||||
// CefBrowserMessageFilter::OnGetNewBrowserInfo on the IO thread and the call
|
// CefBrowserMessageFilter::OnGetNewBrowserInfo on the IO thread and the call
|
||||||
// to CefBrowserHostImpl::WebContentsCreated on the UI thread. To resolve this
|
// to CefBrowserHostImpl::ShouldCreateWebContents on the UI thread. To resolve
|
||||||
// race CefBrowserInfo may be created when requested for the first time and
|
// this race CefBrowserInfo may be created when requested for the first time
|
||||||
// before the associated CefBrowserHostImpl is created.
|
// and before the associated CefBrowserHostImpl is created.
|
||||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo();
|
scoped_refptr<CefBrowserInfo> CreateBrowserInfo();
|
||||||
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(int render_process_id,
|
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(int render_process_id,
|
||||||
int render_view_id);
|
int render_view_id);
|
||||||
|
@ -93,7 +93,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||||
// Store additional state from the ViewHostMsg_CreateWindow message that will
|
// Store additional state from the ViewHostMsg_CreateWindow message that will
|
||||||
// be used when CanCreateWindow() is called.
|
// be used when CanCreateWindow() is called.
|
||||||
struct LastCreateWindowParams {
|
struct LastCreateWindowParams {
|
||||||
int opener_id;
|
int opener_process_id;
|
||||||
|
int opener_view_id;
|
||||||
int64 opener_frame_id;
|
int64 opener_frame_id;
|
||||||
GURL target_url;
|
GURL target_url;
|
||||||
string16 target_frame_name;
|
string16 target_frame_name;
|
||||||
|
|
|
@ -281,9 +281,9 @@ CefRefPtr<CefBrowserHostImpl> CefContext::GetBrowserByRoutingID(
|
||||||
if (info.get()) {
|
if (info.get()) {
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
|
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
|
||||||
if (!browser.get()) {
|
if (!browser.get()) {
|
||||||
DLOG(WARNING) << "Found browser id " << info->browser_id() <<
|
LOG(WARNING) << "Found browser id " << info->browser_id() <<
|
||||||
" but no browser object matching process id " <<
|
" but no browser object matching process id " <<
|
||||||
render_process_id << " and view id " << render_view_id;
|
render_process_id << " and view id " << render_view_id;
|
||||||
}
|
}
|
||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ CefRefPtr<CefTaskRunner> CefTaskRunner::GetForThread(CefThreadId threadId) {
|
||||||
if (task_runner.get())
|
if (task_runner.get())
|
||||||
return new CefTaskRunnerImpl(task_runner);
|
return new CefTaskRunnerImpl(task_runner);
|
||||||
|
|
||||||
DLOG(WARNING) << "Invalid thread id " << threadId;
|
LOG(WARNING) << "Invalid thread id " << threadId;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ class CefWebWorkerTaskRunner : public base::SequencedTaskRunner,
|
||||||
const base::Closure& task,
|
const base::Closure& task,
|
||||||
base::TimeDelta delay) OVERRIDE {
|
base::TimeDelta delay) OVERRIDE {
|
||||||
if (delay != base::TimeDelta())
|
if (delay != base::TimeDelta())
|
||||||
DLOG(WARNING) << "Delayed tasks are not supported on WebWorker threads";
|
LOG(WARNING) << "Delayed tasks are not supported on WebWorker threads";
|
||||||
runner_->PostTask(worker_id_, task);
|
runner_->PostTask(worker_id_, task);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,13 @@
|
||||||
|
|
||||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
int CEF_CALLBACK life_span_handler_can_create_popup(
|
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, int* no_javascript_access) {
|
const cef_string_t* target_frame_name,
|
||||||
|
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) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
DCHECK(self);
|
DCHECK(self);
|
||||||
|
@ -35,65 +38,28 @@ int CEF_CALLBACK life_span_handler_can_create_popup(
|
||||||
DCHECK(frame);
|
DCHECK(frame);
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return 0;
|
return 0;
|
||||||
|
// Verify param: popupFeatures; type: struct_byref_const
|
||||||
|
DCHECK(popupFeatures);
|
||||||
|
if (!popupFeatures)
|
||||||
|
return 0;
|
||||||
|
// Verify param: windowInfo; type: struct_byref
|
||||||
|
DCHECK(windowInfo);
|
||||||
|
if (!windowInfo)
|
||||||
|
return 0;
|
||||||
|
// Verify param: client; type: refptr_same_byref
|
||||||
|
DCHECK(client);
|
||||||
|
if (!client)
|
||||||
|
return 0;
|
||||||
|
// Verify param: settings; type: struct_byref
|
||||||
|
DCHECK(settings);
|
||||||
|
if (!settings)
|
||||||
|
return 0;
|
||||||
// Verify param: no_javascript_access; type: bool_byaddr
|
// Verify param: no_javascript_access; type: bool_byaddr
|
||||||
DCHECK(no_javascript_access);
|
DCHECK(no_javascript_access);
|
||||||
if (!no_javascript_access)
|
if (!no_javascript_access)
|
||||||
return 0;
|
return 0;
|
||||||
// Unverified params: target_url, target_frame_name
|
// Unverified params: target_url, target_frame_name
|
||||||
|
|
||||||
// Translate param: no_javascript_access; type: bool_byaddr
|
|
||||||
bool no_javascript_accessBool = (
|
|
||||||
no_javascript_access && *no_javascript_access)?true:false;
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
bool _retval = CefLifeSpanHandlerCppToC::Get(self)->CanCreatePopup(
|
|
||||||
CefBrowserCToCpp::Wrap(browser),
|
|
||||||
CefFrameCToCpp::Wrap(frame),
|
|
||||||
CefString(target_url),
|
|
||||||
CefString(target_frame_name),
|
|
||||||
&no_javascript_accessBool);
|
|
||||||
|
|
||||||
// Restore param: no_javascript_access; type: bool_byaddr
|
|
||||||
if (no_javascript_access)
|
|
||||||
*no_javascript_access = no_javascript_accessBool?true:false;
|
|
||||||
|
|
||||||
// Return type: bool
|
|
||||||
return _retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CEF_CALLBACK life_span_handler_on_before_popup(
|
|
||||||
struct _cef_life_span_handler_t* self, cef_browser_t* browser,
|
|
||||||
const struct _cef_popup_features_t* popupFeatures,
|
|
||||||
cef_window_info_t* windowInfo, const cef_string_t* target_url,
|
|
||||||
const cef_string_t* target_frame_name, cef_client_t** client,
|
|
||||||
struct _cef_browser_settings_t* settings) {
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
DCHECK(self);
|
|
||||||
if (!self)
|
|
||||||
return;
|
|
||||||
// Verify param: browser; type: refptr_diff
|
|
||||||
DCHECK(browser);
|
|
||||||
if (!browser)
|
|
||||||
return;
|
|
||||||
// Verify param: popupFeatures; type: struct_byref_const
|
|
||||||
DCHECK(popupFeatures);
|
|
||||||
if (!popupFeatures)
|
|
||||||
return;
|
|
||||||
// Verify param: windowInfo; type: struct_byref
|
|
||||||
DCHECK(windowInfo);
|
|
||||||
if (!windowInfo)
|
|
||||||
return;
|
|
||||||
// Verify param: client; type: refptr_same_byref
|
|
||||||
DCHECK(client);
|
|
||||||
if (!client)
|
|
||||||
return;
|
|
||||||
// Verify param: settings; type: struct_byref
|
|
||||||
DCHECK(settings);
|
|
||||||
if (!settings)
|
|
||||||
return;
|
|
||||||
// Unverified params: target_url, target_frame_name
|
|
||||||
|
|
||||||
// Translate param: popupFeatures; type: struct_byref_const
|
// Translate param: popupFeatures; type: struct_byref_const
|
||||||
CefPopupFeatures popupFeaturesObj;
|
CefPopupFeatures popupFeaturesObj;
|
||||||
if (popupFeatures)
|
if (popupFeatures)
|
||||||
|
@ -111,16 +77,21 @@ void CEF_CALLBACK life_span_handler_on_before_popup(
|
||||||
CefBrowserSettings settingsObj;
|
CefBrowserSettings settingsObj;
|
||||||
if (settings)
|
if (settings)
|
||||||
settingsObj.AttachTo(*settings);
|
settingsObj.AttachTo(*settings);
|
||||||
|
// Translate param: no_javascript_access; type: bool_byaddr
|
||||||
|
bool no_javascript_accessBool = (
|
||||||
|
no_javascript_access && *no_javascript_access)?true:false;
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup(
|
bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup(
|
||||||
CefBrowserCToCpp::Wrap(browser),
|
CefBrowserCToCpp::Wrap(browser),
|
||||||
popupFeaturesObj,
|
CefFrameCToCpp::Wrap(frame),
|
||||||
windowInfoObj,
|
|
||||||
CefString(target_url),
|
CefString(target_url),
|
||||||
CefString(target_frame_name),
|
CefString(target_frame_name),
|
||||||
|
popupFeaturesObj,
|
||||||
|
windowInfoObj,
|
||||||
clientPtr,
|
clientPtr,
|
||||||
settingsObj);
|
settingsObj,
|
||||||
|
&no_javascript_accessBool);
|
||||||
|
|
||||||
// Restore param: windowInfo; type: struct_byref
|
// Restore param: windowInfo; type: struct_byref
|
||||||
if (windowInfo)
|
if (windowInfo)
|
||||||
|
@ -138,6 +109,12 @@ void CEF_CALLBACK life_span_handler_on_before_popup(
|
||||||
// Restore param: settings; type: struct_byref
|
// Restore param: settings; type: struct_byref
|
||||||
if (settings)
|
if (settings)
|
||||||
settingsObj.DetachTo(*settings);
|
settingsObj.DetachTo(*settings);
|
||||||
|
// Restore param: no_javascript_access; type: bool_byaddr
|
||||||
|
if (no_javascript_access)
|
||||||
|
*no_javascript_access = no_javascript_accessBool?true:false;
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEF_CALLBACK life_span_handler_on_after_created(
|
void CEF_CALLBACK life_span_handler_on_after_created(
|
||||||
|
@ -220,7 +197,6 @@ void CEF_CALLBACK life_span_handler_on_before_close(
|
||||||
CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls)
|
CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls)
|
||||||
: CefCppToC<CefLifeSpanHandlerCppToC, CefLifeSpanHandler,
|
: CefCppToC<CefLifeSpanHandlerCppToC, CefLifeSpanHandler,
|
||||||
cef_life_span_handler_t>(cls) {
|
cef_life_span_handler_t>(cls) {
|
||||||
struct_.struct_.can_create_popup = life_span_handler_can_create_popup;
|
|
||||||
struct_.struct_.on_before_popup = life_span_handler_on_before_popup;
|
struct_.struct_.on_before_popup = life_span_handler_on_before_popup;
|
||||||
struct_.struct_.on_after_created = life_span_handler_on_after_created;
|
struct_.struct_.on_after_created = life_span_handler_on_after_created;
|
||||||
struct_.struct_.run_modal = life_span_handler_run_modal;
|
struct_.struct_.run_modal = life_span_handler_run_modal;
|
||||||
|
|
|
@ -18,10 +18,12 @@
|
||||||
|
|
||||||
// VIRTUAL METHODS - Body may be edited by hand.
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
bool CefLifeSpanHandlerCToCpp::CanCreatePopup(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, bool* no_javascript_access) {
|
const CefString& target_frame_name, const CefPopupFeatures& popupFeatures,
|
||||||
if (CEF_MEMBER_MISSING(struct_, can_create_popup))
|
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
|
||||||
|
CefBrowserSettings& settings, bool* no_javascript_access) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_before_popup))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
@ -40,55 +42,25 @@ bool CefLifeSpanHandlerCToCpp::CanCreatePopup(CefRefPtr<CefBrowser> browser,
|
||||||
return false;
|
return false;
|
||||||
// Unverified params: target_url, target_frame_name
|
// Unverified params: target_url, target_frame_name
|
||||||
|
|
||||||
// Translate param: no_javascript_access; type: bool_byaddr
|
|
||||||
int no_javascript_accessInt = no_javascript_access?*no_javascript_access:0;
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
int _retval = struct_->can_create_popup(struct_,
|
|
||||||
CefBrowserCppToC::Wrap(browser),
|
|
||||||
CefFrameCppToC::Wrap(frame),
|
|
||||||
target_url.GetStruct(),
|
|
||||||
target_frame_name.GetStruct(),
|
|
||||||
&no_javascript_accessInt);
|
|
||||||
|
|
||||||
// Restore param:no_javascript_access; type: bool_byaddr
|
|
||||||
if (no_javascript_access)
|
|
||||||
*no_javascript_access = no_javascript_accessInt?true:false;
|
|
||||||
|
|
||||||
// Return type: bool
|
|
||||||
return _retval?true:false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|
||||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
|
||||||
const CefString& target_url, const CefString& target_frame_name,
|
|
||||||
CefRefPtr<CefClient>& client, CefBrowserSettings& settings) {
|
|
||||||
if (CEF_MEMBER_MISSING(struct_, on_before_popup))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
// Verify param: browser; type: refptr_diff
|
|
||||||
DCHECK(browser.get());
|
|
||||||
if (!browser.get())
|
|
||||||
return;
|
|
||||||
// Unverified params: target_url, target_frame_name
|
|
||||||
|
|
||||||
// Translate param: client; type: refptr_same_byref
|
// Translate param: client; type: refptr_same_byref
|
||||||
cef_client_t* clientStruct = NULL;
|
cef_client_t* clientStruct = NULL;
|
||||||
if (client.get())
|
if (client.get())
|
||||||
clientStruct = CefClientCToCpp::Unwrap(client);
|
clientStruct = CefClientCToCpp::Unwrap(client);
|
||||||
cef_client_t* clientOrig = clientStruct;
|
cef_client_t* clientOrig = clientStruct;
|
||||||
|
// Translate param: no_javascript_access; type: bool_byaddr
|
||||||
|
int no_javascript_accessInt = no_javascript_access?*no_javascript_access:0;
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
struct_->on_before_popup(struct_,
|
int _retval = struct_->on_before_popup(struct_,
|
||||||
CefBrowserCppToC::Wrap(browser),
|
CefBrowserCppToC::Wrap(browser),
|
||||||
&popupFeatures,
|
CefFrameCppToC::Wrap(frame),
|
||||||
&windowInfo,
|
|
||||||
target_url.GetStruct(),
|
target_url.GetStruct(),
|
||||||
target_frame_name.GetStruct(),
|
target_frame_name.GetStruct(),
|
||||||
|
&popupFeatures,
|
||||||
|
&windowInfo,
|
||||||
&clientStruct,
|
&clientStruct,
|
||||||
&settings);
|
&settings,
|
||||||
|
&no_javascript_accessInt);
|
||||||
|
|
||||||
// Restore param:client; type: refptr_same_byref
|
// Restore param:client; type: refptr_same_byref
|
||||||
if (clientStruct) {
|
if (clientStruct) {
|
||||||
|
@ -98,6 +70,12 @@ void CefLifeSpanHandlerCToCpp::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||||
} else {
|
} else {
|
||||||
client = NULL;
|
client = NULL;
|
||||||
}
|
}
|
||||||
|
// Restore param:no_javascript_access; type: bool_byaddr
|
||||||
|
if (no_javascript_access)
|
||||||
|
*no_javascript_access = no_javascript_accessInt?true:false;
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefLifeSpanHandlerCToCpp::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
void CefLifeSpanHandlerCToCpp::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||||
|
|
|
@ -36,14 +36,12 @@ class CefLifeSpanHandlerCToCpp
|
||||||
virtual ~CefLifeSpanHandlerCToCpp() {}
|
virtual ~CefLifeSpanHandlerCToCpp() {}
|
||||||
|
|
||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
virtual bool CanCreatePopup(CefRefPtr<CefBrowser> browser,
|
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame, const CefString& target_url,
|
CefRefPtr<CefFrame> frame, const CefString& target_url,
|
||||||
const CefString& target_frame_name,
|
const CefString& target_frame_name,
|
||||||
bool* no_javascript_access) OVERRIDE;
|
|
||||||
virtual void OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|
||||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||||
const CefString& target_url, const CefString& target_frame_name,
|
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefClient>& client, CefBrowserSettings& settings) OVERRIDE;
|
bool* no_javascript_access) OVERRIDE;
|
||||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
virtual bool RunModal(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual bool RunModal(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
|
|
|
@ -232,16 +232,20 @@ bool ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientHandler::CanCreatePopup(CefRefPtr<CefBrowser> browser,
|
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,
|
||||||
bool* no_javascript_access) {
|
const CefPopupFeatures& popupFeatures,
|
||||||
|
CefWindowInfo& windowInfo,
|
||||||
|
CefRefPtr<CefClient>& client,
|
||||||
|
CefBrowserSettings& settings,
|
||||||
|
bool* no_javascript_access) {
|
||||||
if (browser->GetHost()->IsWindowRenderingDisabled()) {
|
if (browser->GetHost()->IsWindowRenderingDisabled()) {
|
||||||
// Cancel popups in off-screen rendering mode.
|
// Cancel popups in off-screen rendering mode.
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||||
|
|
|
@ -159,11 +159,15 @@ class ClientHandler : public CefClient,
|
||||||
bool* is_keyboard_shortcut) OVERRIDE;
|
bool* is_keyboard_shortcut) OVERRIDE;
|
||||||
|
|
||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
virtual bool CanCreatePopup(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,
|
||||||
bool* no_javascript_access) OVERRIDE;
|
const CefPopupFeatures& popupFeatures,
|
||||||
|
CefWindowInfo& windowInfo,
|
||||||
|
CefRefPtr<CefClient>& client,
|
||||||
|
CefBrowserSettings& settings,
|
||||||
|
bool* no_javascript_access) OVERRIDE;
|
||||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
|
|
|
@ -1455,10 +1455,10 @@ class PopupNavTestHandler : public TestHandler {
|
||||||
|
|
||||||
virtual void RunTest() OVERRIDE {
|
virtual void RunTest() OVERRIDE {
|
||||||
// Add the resources that we will navigate to/from.
|
// Add the resources that we will navigate to/from.
|
||||||
std::string page = "<html><script>window.open('" +
|
std::string page = "<html><script>function doPopup() { window.open('" +
|
||||||
std::string(kPopupNavPopupUrl) + "', '" +
|
std::string(kPopupNavPopupUrl) + "', '" +
|
||||||
std::string(kPopupNavPopupName) +
|
std::string(kPopupNavPopupName) +
|
||||||
"');</script></html>";
|
"'); }</script>Page</html>";
|
||||||
AddResource(kPopupNavPageUrl, page, "text/html");
|
AddResource(kPopupNavPageUrl, page, "text/html");
|
||||||
AddResource(kPopupNavPopupUrl, "<html>Popup</html>", "text/html");
|
AddResource(kPopupNavPopupUrl, "<html>Popup</html>", "text/html");
|
||||||
|
|
||||||
|
@ -1466,12 +1466,16 @@ class PopupNavTestHandler : public TestHandler {
|
||||||
CreateBrowser(kPopupNavPageUrl);
|
CreateBrowser(kPopupNavPageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanCreatePopup(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,
|
||||||
bool* no_javascript_access) OVERRIDE {
|
const CefPopupFeatures& popupFeatures,
|
||||||
got_can_create_popup_.yes();
|
CefWindowInfo& windowInfo,
|
||||||
|
CefRefPtr<CefClient>& client,
|
||||||
|
CefBrowserSettings& settings,
|
||||||
|
bool* no_javascript_access) OVERRIDE {
|
||||||
|
got_on_before_popup_.yes();
|
||||||
|
|
||||||
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
|
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
|
||||||
EXPECT_EQ(GetBrowserId(), browser->GetIdentifier());
|
EXPECT_EQ(GetBrowserId(), browser->GetIdentifier());
|
||||||
|
@ -1480,58 +1484,47 @@ class PopupNavTestHandler : public TestHandler {
|
||||||
EXPECT_STREQ(kPopupNavPopupName, target_frame_name.ToString().c_str());
|
EXPECT_STREQ(kPopupNavPopupName, target_frame_name.ToString().c_str());
|
||||||
EXPECT_FALSE(*no_javascript_access);
|
EXPECT_FALSE(*no_javascript_access);
|
||||||
|
|
||||||
return allow_;
|
return !allow_;
|
||||||
}
|
|
||||||
|
|
||||||
virtual void OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|
||||||
const CefPopupFeatures& popupFeatures,
|
|
||||||
CefWindowInfo& windowInfo,
|
|
||||||
const CefString& target_url,
|
|
||||||
const CefString& target_frame_name,
|
|
||||||
CefRefPtr<CefClient>& client,
|
|
||||||
CefBrowserSettings& settings) OVERRIDE {
|
|
||||||
got_on_before_popup_.yes();
|
|
||||||
|
|
||||||
EXPECT_TRUE(CefCurrentlyOn(TID_UI));
|
|
||||||
EXPECT_EQ(GetBrowserId(), browser->GetIdentifier());
|
|
||||||
EXPECT_STREQ(kPopupNavPopupUrl, target_url.ToString().c_str());
|
|
||||||
EXPECT_STREQ(kPopupNavPopupName, target_frame_name.ToString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
int httpStatusCode) OVERRIDE {
|
int httpStatusCode) OVERRIDE {
|
||||||
std::string url = frame->GetURL();
|
std::string url = frame->GetURL();
|
||||||
if (allow_) {
|
if (url == kPopupNavPageUrl) {
|
||||||
if (url == kPopupNavPopupUrl) {
|
frame->ExecuteJavaScript("doPopup()", kPopupNavPageUrl, 0);
|
||||||
|
|
||||||
|
if (!allow_) {
|
||||||
|
// Wait a bit to make sure the popup window isn't created.
|
||||||
|
CefPostDelayedTask(TID_UI,
|
||||||
|
NewCefRunnableMethod(this, &PopupNavTestHandler::DestroyTest), 200);
|
||||||
|
}
|
||||||
|
} else if (url == kPopupNavPopupUrl) {
|
||||||
|
if (allow_) {
|
||||||
got_popup_load_end_.yes();
|
got_popup_load_end_.yes();
|
||||||
browser->GetHost()->CloseBrowser();
|
browser->GetHost()->CloseBrowser();
|
||||||
DestroyTest();
|
DestroyTest();
|
||||||
|
} else {
|
||||||
|
EXPECT_FALSE(true); // Not reached.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Wait a bit to make sure the popup window isn't created.
|
EXPECT_FALSE(true); // Not reached.
|
||||||
CefPostDelayedTask(TID_UI,
|
|
||||||
NewCefRunnableMethod(this, &PopupNavTestHandler::DestroyTest), 200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void DestroyTest() {
|
virtual void DestroyTest() {
|
||||||
EXPECT_TRUE(got_can_create_popup_);
|
EXPECT_TRUE(got_on_before_popup_);
|
||||||
if (allow_) {
|
if (allow_)
|
||||||
EXPECT_TRUE(got_on_before_popup_);
|
|
||||||
EXPECT_TRUE(got_popup_load_end_);
|
EXPECT_TRUE(got_popup_load_end_);
|
||||||
} else {
|
else
|
||||||
EXPECT_FALSE(got_on_before_popup_);
|
|
||||||
EXPECT_FALSE(got_popup_load_end_);
|
EXPECT_FALSE(got_popup_load_end_);
|
||||||
}
|
|
||||||
|
|
||||||
TestHandler::DestroyTest();
|
TestHandler::DestroyTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool allow_;
|
bool allow_;
|
||||||
|
|
||||||
TrackCallback got_can_create_popup_;
|
|
||||||
TrackCallback got_on_before_popup_;
|
TrackCallback got_on_before_popup_;
|
||||||
TrackCallback got_popup_load_end_;
|
TrackCallback got_popup_load_end_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue