mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Mac:
- Fix compile errors. - Add support for creating hidden windows and TEST_REDIRECT_POPUP_URLS. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@201 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -125,6 +125,7 @@ public:
|
|||||||
m_y = y;
|
m_y = y;
|
||||||
m_nWidth = width;
|
m_nWidth = width;
|
||||||
m_nHeight = height;
|
m_nHeight = height;
|
||||||
|
m_bHidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowInfo& operator=(const CefWindowInfo& r)
|
CefWindowInfo& operator=(const CefWindowInfo& r)
|
||||||
@ -140,6 +141,7 @@ public:
|
|||||||
m_y = r.m_y;
|
m_y = r.m_y;
|
||||||
m_nWidth = r.m_nWidth;
|
m_nWidth = r.m_nWidth;
|
||||||
m_nHeight = r.m_nHeight;
|
m_nHeight = r.m_nHeight;
|
||||||
|
m_bHidden = r.m_bHidden;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ typedef struct _cef_window_info_t
|
|||||||
int m_y;
|
int m_y;
|
||||||
int m_nWidth;
|
int m_nWidth;
|
||||||
int m_nHeight;
|
int m_nHeight;
|
||||||
|
int m_bHidden;
|
||||||
|
|
||||||
// NSView pointer for the parent view.
|
// NSView pointer for the parent view.
|
||||||
cef_window_handle_t m_ParentView;
|
cef_window_handle_t m_ParentView;
|
||||||
|
@ -775,7 +775,7 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
|||||||
view->setFocusedFrame(frame);
|
view->setFocusedFrame(frame);
|
||||||
|
|
||||||
// Give focus to the window if it is currently visible.
|
// Give focus to the window if it is currently visible.
|
||||||
if(IsWindowVisible(UIT_GetMainWndHandle()))
|
if(UIT_IsViewVisible(UIT_GetMainWndHandle()))
|
||||||
UIT_SetFocus(UIT_GetWebViewHost(), true);
|
UIT_SetFocus(UIT_GetWebViewHost(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void UIT_CloseView(gfx::NativeView view);
|
static void UIT_CloseView(gfx::NativeView view);
|
||||||
|
static bool UIT_IsViewVisible(gfx::NativeView view);
|
||||||
|
|
||||||
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
||||||
void UIT_DestroyDevToolsClient();
|
void UIT_DestroyDevToolsClient();
|
||||||
|
@ -91,7 +91,7 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
|||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if (newWnd != nil) {
|
if (newWnd != nil && !window_info_.m_bHidden) {
|
||||||
// Show the window.
|
// Show the window.
|
||||||
[newWnd makeKeyAndOrderFront: nil];
|
[newWnd makeKeyAndOrderFront: nil];
|
||||||
}
|
}
|
||||||
@ -156,5 +156,13 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
|
|||||||
// static
|
// static
|
||||||
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
|
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
|
||||||
{
|
{
|
||||||
[view performSelector:@selector(performClose:) withObject:nil afterDelay:0];
|
[[view window] performSelector:@selector(performClose:)
|
||||||
|
withObject:nil
|
||||||
|
afterDelay:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool CefBrowserImpl::UIT_IsViewVisible(gfx::NativeView view)
|
||||||
|
{
|
||||||
|
return [[view window] isVisible];
|
||||||
}
|
}
|
||||||
|
@ -488,3 +488,9 @@ void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
|
|||||||
{
|
{
|
||||||
PostMessage(view, WM_CLOSE, 0, 0);
|
PostMessage(view, WM_CLOSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool CefBrowserImpl::UIT_IsViewVisible(gfx::NativeView view)
|
||||||
|
{
|
||||||
|
return IsWindowVisible(view) ? true : false;
|
||||||
|
}
|
||||||
|
@ -409,10 +409,12 @@ bool CefRegisterScheme(const CefString& scheme_name,
|
|||||||
// RunnableMethodTraits::RetainCallee() (originating from NewRunnableMethod)
|
// RunnableMethodTraits::RetainCallee() (originating from NewRunnableMethod)
|
||||||
// will call AddRef() and Release() on the object in debug mode, resulting in
|
// will call AddRef() and Release() on the object in debug mode, resulting in
|
||||||
// the object being deleted if it doesn't already have a reference.
|
// the object being deleted if it doesn't already have a reference.
|
||||||
|
std::string hostNameStr;
|
||||||
|
if (is_standard)
|
||||||
|
hostNameStr = host_name;
|
||||||
CefRefPtr<SchemeRequestJobWrapper> wrapper(
|
CefRefPtr<SchemeRequestJobWrapper> wrapper(
|
||||||
new SchemeRequestJobWrapper(scheme_name,
|
new SchemeRequestJobWrapper(scheme_name, hostNameStr, is_standard,
|
||||||
(is_standard?host_name:std::string()),
|
factory));
|
||||||
is_standard, factory));
|
|
||||||
|
|
||||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(wrapper.get(),
|
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(wrapper.get(),
|
||||||
&SchemeRequestJobWrapper::RegisterScheme));
|
&SchemeRequestJobWrapper::RegisterScheme));
|
||||||
|
@ -14,40 +14,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Define this value to redirect all popup URLs to the main application browser
|
|
||||||
// window.
|
|
||||||
//#define TEST_REDIRECT_POPUP_URLS
|
|
||||||
|
|
||||||
#ifdef TEST_REDIRECT_POPUP_URLS
|
|
||||||
// Handler for popup windows that loads the request in an existing browser
|
|
||||||
// window.
|
|
||||||
class ClientPopupHandler : public ClientHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ClientPopupHandler(CefRefPtr<CefBrowser> parentBrowser)
|
|
||||||
: m_ParentBrowser(parentBrowser)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
virtual ~ClientPopupHandler()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
|
||||||
CefRefPtr<CefFrame> frame,
|
|
||||||
CefRefPtr<CefRequest> request,
|
|
||||||
NavType navType, bool isRedirect)
|
|
||||||
{
|
|
||||||
REQUIRE_UI_THREAD();
|
|
||||||
|
|
||||||
m_ParentBrowser->GetMainFrame()->LoadRequest(request);
|
|
||||||
browser->CloseBrowser();
|
|
||||||
return RV_HANDLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
CefRefPtr<CefBrowser> m_ParentBrowser;
|
|
||||||
};
|
|
||||||
#endif // TEST_REDIRECT_POPUP_URLS
|
|
||||||
|
|
||||||
// ClientHandler::ClientDownloadListener implementation
|
// ClientHandler::ClientDownloadListener implementation
|
||||||
|
|
||||||
@ -80,30 +46,6 @@ ClientHandler::~ClientHandler()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
|
||||||
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& createInfo, bool popup,
|
|
||||||
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
|
||||||
CefString& url, CefBrowserSettings& settings)
|
|
||||||
{
|
|
||||||
REQUIRE_UI_THREAD();
|
|
||||||
|
|
||||||
#ifdef TEST_REDIRECT_POPUP_URLS
|
|
||||||
if(popup) {
|
|
||||||
std::string urlStr = url;
|
|
||||||
if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) {
|
|
||||||
// Show all popup windows excluding DevTools in the current window.
|
|
||||||
#ifdef _WIN32
|
|
||||||
// Make the popup window hidden.
|
|
||||||
createInfo.m_dwStyle &= ~WS_VISIBLE;
|
|
||||||
#endif
|
|
||||||
handler = new ClientPopupHandler(m_Browser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // TEST_REDIRECT_POPUP_URLS
|
|
||||||
|
|
||||||
return RV_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleAfterCreated(
|
CefHandler::RetVal ClientHandler::HandleAfterCreated(
|
||||||
CefRefPtr<CefBrowser> browser)
|
CefRefPtr<CefBrowser> browser)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#include "download_handler.h"
|
#include "download_handler.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
// Define this value to redirect all popup URLs to the main application browser
|
||||||
|
// window.
|
||||||
|
//s#define TEST_REDIRECT_POPUP_URLS
|
||||||
|
|
||||||
// Client implementation of the browser handler class
|
// Client implementation of the browser handler class
|
||||||
class ClientHandler : public CefThreadSafeBase<CefHandler>
|
class ClientHandler : public CefThreadSafeBase<CefHandler>
|
||||||
{
|
{
|
||||||
@ -420,6 +424,41 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TEST_REDIRECT_POPUP_URLS
|
||||||
|
// Handler for popup windows that loads the request in an existing browser
|
||||||
|
// window.
|
||||||
|
class ClientPopupHandler : public ClientHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClientPopupHandler(CefRefPtr<CefBrowser> parentBrowser)
|
||||||
|
: m_ParentBrowser(parentBrowser)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ClientPopupHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefRequest> request,
|
||||||
|
NavType navType, bool isRedirect)
|
||||||
|
{
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
|
if (m_ParentBrowser.get()) {
|
||||||
|
m_ParentBrowser->GetMainFrame()->LoadRequest(request);
|
||||||
|
browser->CloseBrowser();
|
||||||
|
m_ParentBrowser = NULL;
|
||||||
|
}
|
||||||
|
return RV_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CefRefPtr<CefBrowser> m_ParentBrowser;
|
||||||
|
};
|
||||||
|
#endif // TEST_REDIRECT_POPUP_URLS
|
||||||
|
|
||||||
|
|
||||||
// Returns the main browser window instance.
|
// Returns the main browser window instance.
|
||||||
CefRefPtr<CefBrowser> AppGetBrowser();
|
CefRefPtr<CefBrowser> AppGetBrowser();
|
||||||
|
|
||||||
|
@ -481,6 +481,27 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// ClientHandler implementation
|
// ClientHandler implementation
|
||||||
|
|
||||||
|
CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
||||||
|
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& createInfo, bool popup,
|
||||||
|
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
||||||
|
CefString& url, CefBrowserSettings& settings)
|
||||||
|
{
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
|
#ifdef TEST_REDIRECT_POPUP_URLS
|
||||||
|
if(popup) {
|
||||||
|
std::string urlStr = url;
|
||||||
|
if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) {
|
||||||
|
// Show all popup windows excluding DevTools in the current window.
|
||||||
|
createInfo.m_bHidden = true;
|
||||||
|
handler = new ClientPopupHandler(m_Browser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // TEST_REDIRECT_POPUP_URLS
|
||||||
|
|
||||||
|
return RV_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url)
|
const CefString& url)
|
||||||
|
@ -651,6 +651,27 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
// ClientHandler implementation
|
// ClientHandler implementation
|
||||||
|
|
||||||
|
CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
||||||
|
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& createInfo, bool popup,
|
||||||
|
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
||||||
|
CefString& url, CefBrowserSettings& settings)
|
||||||
|
{
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
|
#ifdef TEST_REDIRECT_POPUP_URLS
|
||||||
|
if(popup) {
|
||||||
|
std::string urlStr = url;
|
||||||
|
if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) {
|
||||||
|
// Show all popup windows excluding DevTools in the current window.
|
||||||
|
createInfo.m_dwStyle &= ~WS_VISIBLE;
|
||||||
|
handler = new ClientPopupHandler(m_Browser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // TEST_REDIRECT_POPUP_URLS
|
||||||
|
|
||||||
|
return RV_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url)
|
const CefString& url)
|
||||||
|
Reference in New Issue
Block a user