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

Unified Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 329743002: MacViews: Initial skeleton for implementing NativeWidgetMac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to master (header conflict with r276556) Created 6 years, 6 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: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7890ca93304ec3f39a4fd02745238ed1af55b8b4
--- /dev/null
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -0,0 +1,39 @@
+// 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.
+
+#import "ui/views/cocoa/bridged_native_widget.h"
+
+#include "base/logging.h"
+#import "ui/views/cocoa/bridged_content_view.h"
+
+namespace views {
+
+BridgedNativeWidget::BridgedNativeWidget() {
+}
+
+BridgedNativeWidget::~BridgedNativeWidget() {
+ SetRootView(NULL);
+}
+
+void BridgedNativeWidget::Init(base::scoped_nsobject<NSWindow> window) {
+ DCHECK(!window_);
+ window_.swap(window);
+}
+
+void BridgedNativeWidget::SetRootView(views::View* view) {
+ if (view == [bridged_view_ hostedView])
+ return;
+
+ [bridged_view_ clearView];
+ bridged_view_.reset();
+ // Note that there can still be references to the old |bridged_view_|
+ // floating around in Cocoa libraries at this point. However, references to
+ // the old views::View will be gone, so any method calls will become no-ops.
+
+ if (view)
+ bridged_view_.reset([[BridgedContentView alloc] initWithView:view]);
+ [window_ setContentView:bridged_view_];
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698