Allow for cases where CefBrowserImpl::UIT_CreateBrowser() may fail (issue #322).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@336 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-10-21 21:00:59 +00:00
parent fb2eb5f4b5
commit c422ab5aa8
5 changed files with 21 additions and 6 deletions

View File

@@ -153,7 +153,8 @@ CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(
CefRefPtr<CefBrowser> browser( CefRefPtr<CefBrowser> browser(
new CefBrowserImpl(windowInfo, settings, NULL, client)); new CefBrowserImpl(windowInfo, settings, NULL, client));
static_cast<CefBrowserImpl*>(browser.get())->UIT_CreateBrowser(url); if (!static_cast<CefBrowserImpl*>(browser.get())->UIT_CreateBrowser(url))
return NULL;
return browser; return browser;
} }
@@ -1142,7 +1143,8 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
// Don't pass the URL to UIT_CreateBrowser for popup windows or the URL will // Don't pass the URL to UIT_CreateBrowser for popup windows or the URL will
// be loaded twice. // be loaded twice.
browser->UIT_CreateBrowser(CefString()); if (!browser->UIT_CreateBrowser(CefString()))
return NULL;
return browser; return browser;
} }

View File

@@ -221,7 +221,7 @@ public:
} }
// Create the native browser window and populate browser members. // Create the native browser window and populate browser members.
void UIT_CreateBrowser(const CefString& url); bool UIT_CreateBrowser(const CefString& url);
// Destroy the browser members. This method should only be called after the // Destroy the browser members. This method should only be called after the
// native browser window is not longer processing messages. // native browser window is not longer processing messages.

View File

@@ -42,7 +42,7 @@ gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() {
return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL; return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
} }
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url) bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
Lock(); Lock();
@@ -79,6 +79,8 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
if(url.size() > 0) if(url.size() > 0)
UIT_LoadURL(GetMainFrame(), url); UIT_LoadURL(GetMainFrame(), url);
return true;
} }
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)

View File

@@ -41,7 +41,7 @@ gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() {
return window_info_.m_View; return window_info_.m_View;
} }
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url) bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
Lock(); Lock();
@@ -119,6 +119,8 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
if(url.size() > 0) if(url.size() > 0)
UIT_LoadURL(GetMainFrame(), url); UIT_LoadURL(GetMainFrame(), url);
return true;
} }
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)

View File

@@ -163,7 +163,7 @@ gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() {
window_info_.m_hWndParent : window_info_.m_hWnd; window_info_.m_hWndParent : window_info_.m_hWnd;
} }
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url) bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
Lock(); Lock();
@@ -177,7 +177,14 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
window_info_.m_x, window_info_.m_y, window_info_.m_nWidth, window_info_.m_x, window_info_.m_y, window_info_.m_nWidth,
window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu, window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu,
::GetModuleHandle(NULL), NULL); ::GetModuleHandle(NULL), NULL);
// It's possible for CreateWindowEx to fail if the parent window was
// destroyed between the call to CreateBrowser and the above one.
DCHECK(window_info_.m_hWnd != NULL); DCHECK(window_info_.m_hWnd != NULL);
if (!window_info_.m_hWnd) {
Unlock();
return false;
}
if (window_info_.m_bTransparentPainting && if (window_info_.m_bTransparentPainting &&
!(window_info_.m_dwStyle & WS_CHILD)) { !(window_info_.m_dwStyle & WS_CHILD)) {
@@ -248,6 +255,8 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
if(url.length() > 0) if(url.length() > 0)
UIT_LoadURL(GetMainFrame(), url); UIT_LoadURL(GetMainFrame(), url);
return true;
} }
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)