- (void)windowDidBecomeMain:(NSNotification*)notification {
shell_->NotifyWindowFocus();
- if (shell_->GetWebContents())
- shell_->GetWebContents()->GetView()->StoreFocus();
+ content::WebContents* web_contents = shell_->GetWebContents();
+ if (!web_contents)
+ return;
+
+ web_contents->GetView()->RestoreFocus();
- content::RenderWidgetHostView* rwhv =
- shell_->GetWebContents()->GetRenderWidgetHostView();
+ content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(true);
}
- (void)windowDidResignMain:(NSNotification*)notification {
shell_->NotifyWindowBlur();
- if (shell_->GetWebContents())
- shell_->GetWebContents()->GetView()->StoreFocus();
+ content::WebContents* web_contents = shell_->GetWebContents();
+ if (!web_contents)
+ return;
+
+ web_contents->GetView()->StoreFocus();
- content::RenderWidgetHostView* rwhv =
- shell_->GetWebContents()->GetRenderWidgetHostView();
+ content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(false);
}