| 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 c27c9927397f02c273ef4721495a1a56ad8db365..1505c04edea63ea191bbbc83631993ca818ff997 100644
|
| --- a/content/browser/web_contents/web_contents_view_mac.mm
|
| +++ b/content/browser/web_contents/web_contents_view_mac.mm
|
| @@ -20,7 +20,7 @@
|
| #import "content/browser/web_contents/web_drag_source_mac.h"
|
| #include "content/common/view_messages.h"
|
| #include "content/public/browser/web_contents_delegate.h"
|
| -#include "content/public/browser/web_contents_view_delegate.h"
|
| +#import "content/public/browser/web_contents_view_delegate_mac.h"
|
| #include "skia/ext/skia_utils_mac.h"
|
| #import "third_party/mozilla/NSPasteboard+Utils.h"
|
| #include "ui/base/clipboard/custom_data_helper.h"
|
| @@ -159,6 +159,9 @@ void WebContentsViewMac::SizeContents(const gfx::Size& size) {
|
| }
|
|
|
| void WebContentsViewMac::Focus() {
|
| + if (delegate_ && delegate_->Focus())
|
| + return;
|
| +
|
| NSWindow* window = [cocoa_view_.get() window];
|
| [window makeFirstResponder:GetContentNativeView()];
|
| if (![window isVisible])
|
| @@ -176,6 +179,10 @@ void WebContentsViewMac::SetInitialFocus() {
|
| void WebContentsViewMac::StoreFocus() {
|
| // We're explicitly being asked to store focus, so don't worry if there's
|
| // already a view saved.
|
| + focus_tracker_.reset();
|
| + if (delegate_ && delegate_->StoreFocus())
|
| + return;
|
| +
|
| focus_tracker_.reset(
|
| [[FocusTracker alloc] initWithWindow:[cocoa_view_ window]]);
|
| }
|
| @@ -183,6 +190,9 @@ void WebContentsViewMac::StoreFocus() {
|
| void WebContentsViewMac::RestoreFocus() {
|
| // TODO(avi): Could we be restoring a view that's no longer in the key view
|
| // chain?
|
| + if (delegate_ && delegate_->RestoreFocus())
|
| + return;
|
| +
|
| if (!(focus_tracker_.get() &&
|
| [focus_tracker_ restoreFocusInWindow:[cocoa_view_ window]])) {
|
| // Fall back to the default focus behavior if we could not restore focus.
|
| @@ -212,6 +222,9 @@ void WebContentsViewMac::GotFocus() {
|
| // This is called when the renderer asks us to take focus back (i.e., it has
|
| // iterated past the last focusable element on the page).
|
| void WebContentsViewMac::TakeFocus(bool reverse) {
|
| + if (delegate_ && delegate_->TakeFocus(reverse))
|
| + return;
|
| +
|
| if (reverse) {
|
| [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()];
|
| } else {
|
| @@ -299,9 +312,13 @@ RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget(
|
| RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(
|
| render_widget_host);
|
| if (delegate()) {
|
| + WebContentsViewDelegateMac* delegate_mac =
|
| + delegate()->AsWebContentsViewDelegateMac();
|
| base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate> >
|
| - rw_delegate(
|
| - delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host));
|
| + rw_delegate(delegate_mac
|
| + ? delegate_mac->CreateRenderWidgetHostViewDelegate(
|
| + render_widget_host)
|
| + : nil);
|
|
|
| view->SetDelegate(rw_delegate.get());
|
| }
|
|
|