Automated Commit: Committing new LKGM version 7479.0.0 for chromeos.
[chromium-blink-merge.git] / ui / views / cocoa / widget_owner_nswindow_adapter.h
blob6d5517edca581630e38c2de9c9bbd5e956ac6dd8
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_COCOA_WIDGET_OWNER_NSWINDOW_ADAPTER_H_
6 #define UI_VIEWS_COCOA_WIDGET_OWNER_NSWINDOW_ADAPTER_H_
8 #import "base/mac/scoped_nsobject.h"
9 #import "ui/views/cocoa/bridged_native_widget_owner.h"
11 @class NSView;
12 @class NSWindow;
13 @class WidgetOwnerNSWindowAdapterBridge;
15 namespace views {
17 // An adapter that allows a views::Widget to be owned by an NSWindow that is not
18 // backed by another BridgedNativeWidget.
19 class WidgetOwnerNSWindowAdapter : public BridgedNativeWidgetOwner {
20 public:
21 // Create an adapter that will own |child|, tying its lifetime with the
22 // NSWindow containing |anchor_view|. The object is self-deleting, via a call
23 // to RemoveChildWindow() made in child->OnWindowWillClose().
24 WidgetOwnerNSWindowAdapter(BridgedNativeWidget* child, NSView* anchor_view);
26 // Called when the owning window is closing.
27 void OnWindowWillClose();
29 // Overridden from BridgedNativeWidgetOwner:
30 NSWindow* GetNSWindow() override;
31 gfx::Vector2d GetChildWindowOffset() const override;
32 bool IsVisibleParent() const override;
33 void RemoveChildWindow(BridgedNativeWidget* child) override;
35 private:
36 // Self-deleting.
37 ~WidgetOwnerNSWindowAdapter() override;
39 BridgedNativeWidget* child_; // Weak. Owned by its NativeWidgetMac.
40 base::scoped_nsobject<NSView> anchor_view_;
41 base::scoped_nsobject<NSWindow> anchor_window_;
42 base::scoped_nsobject<WidgetOwnerNSWindowAdapterBridge> observer_bridge_;
44 DISALLOW_COPY_AND_ASSIGN(WidgetOwnerNSWindowAdapter);
47 } // namespace views
49 #endif // UI_VIEWS_COCOA_WIDGET_OWNER_NSWINDOW_ADAPTER_H_