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:
parent
7b1166b18a
commit
11b831119a
|
@ -125,6 +125,7 @@ public:
|
|||
m_y = y;
|
||||
m_nWidth = width;
|
||||
m_nHeight = height;
|
||||
m_bHidden = false;
|
||||
}
|
||||
|
||||
CefWindowInfo& operator=(const CefWindowInfo& r)
|
||||
|
@ -140,6 +141,7 @@ public:
|
|||
m_y = r.m_y;
|
||||
m_nWidth = r.m_nWidth;
|
||||
m_nHeight = r.m_nHeight;
|
||||
m_bHidden = r.m_bHidden;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef struct _cef_window_info_t
|
|||
int m_y;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
int m_bHidden;
|
||||
|
||||
// NSView pointer for the parent view.
|
||||
cef_window_handle_t m_ParentView;
|
||||
|
|
|
@ -775,7 +775,7 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
|||
view->setFocusedFrame(frame);
|
||||
|
||||
// Give focus to the window if it is currently visible.
|
||||
if(IsWindowVisible(UIT_GetMainWndHandle()))
|
||||
if(UIT_IsViewVisible(UIT_GetMainWndHandle()))
|
||||
UIT_SetFocus(UIT_GetWebViewHost(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -280,6 +280,7 @@ public:
|
|||
|
||||
protected:
|
||||
static void UIT_CloseView(gfx::NativeView view);
|
||||
static bool UIT_IsViewVisible(gfx::NativeView view);
|
||||
|
||||
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
||||
void UIT_DestroyDevToolsClient();
|
||||
|
|
|
@ -91,7 +91,7 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
|||
|
||||
Unlock();
|
||||
|
||||
if (newWnd != nil) {
|
||||
if (newWnd != nil && !window_info_.m_bHidden) {
|
||||
// Show the window.
|
||||
[newWnd makeKeyAndOrderFront: nil];
|
||||
}
|
||||
|
@ -156,5 +156,13 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
|
|||
// static
|
||||
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);
|
||||
}
|
||||
|
||||
// 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)
|
||||
// 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.
|
||||
std::string hostNameStr;
|
||||
if (is_standard)
|
||||
hostNameStr = host_name;
|
||||
CefRefPtr<SchemeRequestJobWrapper> wrapper(
|
||||
new SchemeRequestJobWrapper(scheme_name,
|
||||
(is_standard?host_name:std::string()),
|
||||
is_standard, factory));
|
||||
new SchemeRequestJobWrapper(scheme_name, hostNameStr, is_standard,
|
||||
factory));
|
||||
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(wrapper.get(),
|
||||
&SchemeRequestJobWrapper::RegisterScheme));
|
||||
|
|
|
@ -14,40 +14,6 @@
|
|||
#include <stdio.h>
|
||||
#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
|
||||
|
||||
|
@ -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(
|
||||
CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
#include "download_handler.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
|
||||
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.
|
||||
CefRefPtr<CefBrowser> AppGetBrowser();
|
||||
|
||||
|
|
|
@ -481,6 +481,27 @@ int main(int argc, char* argv[])
|
|||
|
||||
// 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(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& url)
|
||||
|
|
|
@ -651,6 +651,27 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// 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(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& url)
|
||||
|
|
Loading…
Reference in New Issue