Fix dereferencing nullptr

RenderWidgetHostView might not be available when
the navigator fails to load a url.
This commit is contained in:
deepak1556 2017-01-21 14:56:58 +05:30
parent edcea3e800
commit 54559f99a0

View file

@ -900,6 +900,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
// We have to call it right after LoadURL because the RenderViewHost is only // We have to call it right after LoadURL because the RenderViewHost is only
// created after loading a page. // created after loading a page.
const auto view = web_contents()->GetRenderWidgetHostView(); const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
WebContentsPreferences* web_preferences = WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents()); WebContentsPreferences::FromWebContents(web_contents());
std::string color_name; std::string color_name;
@ -910,6 +911,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
view->SetBackgroundColor(SK_ColorTRANSPARENT); view->SetBackgroundColor(SK_ColorTRANSPARENT);
} }
} }
}
void WebContents::DownloadURL(const GURL& url) { void WebContents::DownloadURL(const GURL& url) {
auto browser_context = web_contents()->GetBrowserContext(); auto browser_context = web_contents()->GetBrowserContext();