Fix dereferencing nullptr
RenderWidgetHostView might not be available when the navigator fails to load a url.
This commit is contained in:
parent
edcea3e800
commit
54559f99a0
1 changed files with 10 additions and 8 deletions
|
@ -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
|
// 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();
|
||||||
WebContentsPreferences* web_preferences =
|
if (view) {
|
||||||
WebContentsPreferences::FromWebContents(web_contents());
|
WebContentsPreferences* web_preferences =
|
||||||
std::string color_name;
|
WebContentsPreferences::FromWebContents(web_contents());
|
||||||
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
std::string color_name;
|
||||||
&color_name)) {
|
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
||||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
&color_name)) {
|
||||||
} else {
|
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
} else {
|
||||||
|
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue