OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 5 #ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
6 #define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 6 #define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #import "ui/views/focus/focus_manager.h" |
12 #include "ui/views/ime/input_method_delegate.h" | 13 #include "ui/views/ime/input_method_delegate.h" |
13 #include "ui/views/views_export.h" | 14 #include "ui/views/views_export.h" |
14 | 15 |
15 @class BridgedContentView; | 16 @class BridgedContentView; |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 class InputMethod; | 19 class InputMethod; |
19 } | 20 } |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 | 23 |
23 class InputMethod; | 24 class InputMethod; |
24 class View; | 25 class View; |
25 | 26 |
26 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or | 27 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or |
27 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the | 28 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the |
28 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. | 29 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. |
29 class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate { | 30 class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate, |
30 | 31 public FocusChangeListener { |
31 public: | 32 public: |
32 BridgedNativeWidget(); | 33 BridgedNativeWidget(); |
33 virtual ~BridgedNativeWidget(); | 34 virtual ~BridgedNativeWidget(); |
34 | 35 |
35 // Initialize the bridge, "retains" ownership of |window|. | 36 // Initialize the bridge, "retains" ownership of |window|. |
36 void Init(base::scoped_nsobject<NSWindow> window); | 37 void Init(base::scoped_nsobject<NSWindow> window); |
37 | 38 |
38 // Set or clears the views::View bridged by the content view. This does NOT | 39 // Set or clears the views::View bridged by the content view. This does NOT |
39 // take ownership of |view|. | 40 // take ownership of |view|. |
40 void SetRootView(views::View* view); | 41 void SetRootView(views::View* view); |
41 | 42 |
42 // See widget.h for documentation. | 43 // See widget.h for documentation. |
43 InputMethod* CreateInputMethod(); | 44 InputMethod* CreateInputMethod(); |
44 ui::InputMethod* GetHostInputMethod(); | 45 ui::InputMethod* GetHostInputMethod(); |
45 | 46 |
46 BridgedContentView* ns_view() { return bridged_view_; } | 47 BridgedContentView* ns_view() { return bridged_view_; } |
47 NSWindow* ns_window() { return window_; } | 48 NSWindow* ns_window() { return window_; } |
48 | 49 |
49 // Overridden from internal::InputMethodDelegate: | 50 // Overridden from internal::InputMethodDelegate: |
50 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; | 51 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; |
51 | 52 |
52 private: | 53 private: |
53 base::scoped_nsobject<NSWindow> window_; | 54 base::scoped_nsobject<NSWindow> window_; |
54 base::scoped_nsobject<BridgedContentView> bridged_view_; | 55 base::scoped_nsobject<BridgedContentView> bridged_view_; |
55 scoped_ptr<ui::InputMethod> input_method_; | 56 scoped_ptr<ui::InputMethod> input_method_; |
56 | 57 |
| 58 // Overridden from FocusChangeListener: |
| 59 virtual void OnWillChangeFocus(View* focused_before, |
| 60 View* focused_now) OVERRIDE; |
| 61 virtual void OnDidChangeFocus(View* focused_before, |
| 62 View* focused_now) OVERRIDE; |
| 63 |
57 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); | 64 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); |
58 }; | 65 }; |
59 | 66 |
60 } // namespace views | 67 } // namespace views |
61 | 68 |
62 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 69 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
OLD | NEW |