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,14 +900,16 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
// We have to call it right after LoadURL because the RenderViewHost is only
// created after loading a page.
const auto view = web_contents()->GetRenderWidgetHostView();
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
std::string color_name;
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
&color_name)) {
view->SetBackgroundColor(ParseHexColor(color_name));
} else {
view->SetBackgroundColor(SK_ColorTRANSPARENT);
if (view) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
std::string color_name;
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
&color_name)) {
view->SetBackgroundColor(ParseHexColor(color_name));
} else {
view->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
}