| Index: chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm
|
| diff --git a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7323217045e42929529483126c18f68a7c763c71
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm
|
| @@ -0,0 +1,82 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.h"
|
| +#import "chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.h"
|
| +#include "chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +namespace {
|
| +
|
| +// Chrome's WebContentsViewDelegate implementation for WebContents hosted inside
|
| +// a views::Widget on Mac. Context menus and
|
| +class ChromeWebContentsViewDelegateViewsBridge
|
| + : public ChromeWebContentsViewDelegateMac {
|
| + public:
|
| + explicit ChromeWebContentsViewDelegateViewsBridge(
|
| + content::WebContents* web_contents);
|
| + virtual ~ChromeWebContentsViewDelegateViewsBridge() {}
|
| +
|
| + // Overridden from WebContentsViewDelegate:
|
| + virtual bool StoreFocus() OVERRIDE;
|
| + virtual bool RestoreFocus() OVERRIDE;
|
| + virtual bool Focus() OVERRIDE;
|
| + virtual bool TakeFocus(bool reverse) OVERRIDE;
|
| + virtual void SizeChanged(const gfx::Size& size) OVERRIDE;
|
| +
|
| + private:
|
| + scoped_ptr<ChromeWebContentsViewDelegateViews> impl_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViewsBridge);
|
| +};
|
| +
|
| +ChromeWebContentsViewDelegateViewsBridge::
|
| + ChromeWebContentsViewDelegateViewsBridge(content::WebContents* web_contents)
|
| + : ChromeWebContentsViewDelegateMac(web_contents),
|
| + impl_(new ChromeWebContentsViewDelegateViews(web_contents)) {
|
| +}
|
| +
|
| +bool ChromeWebContentsViewDelegateViewsBridge::StoreFocus() {
|
| + return impl_->StoreFocus();
|
| +}
|
| +
|
| +bool ChromeWebContentsViewDelegateViewsBridge::RestoreFocus() {
|
| + return impl_->RestoreFocus();
|
| +}
|
| +
|
| +bool ChromeWebContentsViewDelegateViewsBridge::Focus() {
|
| + return impl_->Focus();
|
| +}
|
| +
|
| +bool ChromeWebContentsViewDelegateViewsBridge::TakeFocus(bool reverse) {
|
| + return impl_->TakeFocus(reverse);
|
| +}
|
| +
|
| +void ChromeWebContentsViewDelegateViewsBridge::SizeChanged(
|
| + const gfx::Size& size) {
|
| + // This is not passed through from the content layer on Mac, and isn't
|
| + // required while the SadTab is a native Cocoa view.
|
| + NOTREACHED();
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +namespace chrome {
|
| +
|
| +content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
|
| + content::WebContents* web_contents,
|
| + gfx::NativeView context) {
|
| + // If the context has a views::Widget, then it is toolkit-views.
|
| + views::Widget* widget = views::Widget::GetWidgetForNativeView(context);
|
| + if (widget)
|
| + return new ChromeWebContentsViewDelegateViewsBridge(web_contents);
|
| +
|
| + return new ChromeWebContentsViewDelegateMac(web_contents);
|
| +}
|
| +
|
| +} // namespace chrome
|
|
|