Chromium Code Reviews| 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" |
|
Andre
2014/06/11 18:02:52
Is this for DCHECK?
Seems inconsistent with Bridge
tapted
2014/06/12 09:13:12
Yep it's for the DCHECK. logging.h slips in easily
|
| +#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 |