| Index: content/browser/web_contents/web_contents_view_mac.mm
|
| diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm
|
| index 6e883b60db92581376da5041593be6a5edb5438b..aa257d6d9f55d7e6dbc8341d0f2d4f7249afd84b 100644
|
| --- a/content/browser/web_contents/web_contents_view_mac.mm
|
| +++ b/content/browser/web_contents/web_contents_view_mac.mm
|
| @@ -159,8 +159,13 @@ void WebContentsViewMac::SizeContents(const gfx::Size& size) {
|
| }
|
|
|
| void WebContentsViewMac::Focus() {
|
| - NSWindow* window = [cocoa_view_.get() window];
|
| - [window makeFirstResponder:GetContentNativeView()];
|
| + RenderWidgetHostView* rwhv =
|
| + web_contents_->GetFullscreenRenderWidgetHostView();
|
| + if (!rwhv)
|
| + rwhv = web_contents_->GetRenderWidgetHostView();
|
| + const gfx::NativeView native_view = rwhv ? rwhv->GetNativeView() : nil;
|
| + NSWindow* const window = [native_view window];
|
| + [window makeFirstResponder:native_view];
|
| if (![window isVisible])
|
| return;
|
| [window makeKeyAndOrderFront:nil];
|
| @@ -170,21 +175,31 @@ void WebContentsViewMac::SetInitialFocus() {
|
| if (web_contents_->FocusLocationBarByDefault())
|
| web_contents_->SetFocusToLocationBar(false);
|
| else
|
| - [[cocoa_view_.get() window] makeFirstResponder:GetContentNativeView()];
|
| + Focus();
|
| }
|
|
|
| void WebContentsViewMac::StoreFocus() {
|
| + RenderWidgetHostView* rwhv =
|
| + web_contents_->GetFullscreenRenderWidgetHostView();
|
| + if (!rwhv)
|
| + rwhv = web_contents_->GetRenderWidgetHostView();
|
| + const gfx::NativeView native_view = rwhv ? rwhv->GetNativeView() : nil;
|
| // We're explicitly being asked to store focus, so don't worry if there's
|
| // already a view saved.
|
| focus_tracker_.reset(
|
| - [[FocusTracker alloc] initWithWindow:[cocoa_view_ window]]);
|
| + [[FocusTracker alloc] initWithWindow:[native_view window]]);
|
| }
|
|
|
| void WebContentsViewMac::RestoreFocus() {
|
| + RenderWidgetHostView* rwhv =
|
| + web_contents_->GetFullscreenRenderWidgetHostView();
|
| + if (!rwhv)
|
| + rwhv = web_contents_->GetRenderWidgetHostView();
|
| + const gfx::NativeView native_view = rwhv ? rwhv->GetNativeView() : nil;
|
| // TODO(avi): Could we be restoring a view that's no longer in the key view
|
| // chain?
|
| if (!(focus_tracker_.get() &&
|
| - [focus_tracker_ restoreFocusInWindow:[cocoa_view_ window]])) {
|
| + [focus_tracker_ restoreFocusInWindow:[native_view window]])) {
|
| // Fall back to the default focus behavior if we could not restore focus.
|
| // TODO(shess): If location-bar gets focus by default, this will
|
| // select-all in the field. If there was a specific selection in
|
|
|