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

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: respond to comments 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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/bridged_native_widget_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8ab8e4aa8b155ff9c6eb3823c36407b01245dcc8
--- /dev/null
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -0,0 +1,43 @@
+// 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]);
+ // Objective C initializers can return nil. However, if |view| is non-NULL
+ // this should be treated as an error and caught early.
+ CHECK(bridged_view_);
+ }
+ [window_ setContentView:bridged_view_];
+}
+
+} // namespace views
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/bridged_native_widget_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698