Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8244)

Unified Diff: chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm

Issue 659233002: STASH: Epic Experimental patch for toolkit-views App List on Mac Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Fix a few things. Works@master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698