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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.h

Issue 329463002: MacViews: Implement text input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More changes for tapted. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 @class ViewsNSWindowDelegate; 17 @class ViewsNSWindowDelegate;
17 18
18 namespace ui { 19 namespace ui {
19 class InputMethod; 20 class InputMethod;
20 } 21 }
21 22
22 namespace views { 23 namespace views {
23 24
24 class InputMethod; 25 class InputMethod;
25 class NativeWidgetMac; 26 class NativeWidgetMac;
26 class View; 27 class View;
27 28
28 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or 29 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or
29 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the 30 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
30 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. 31 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
31 class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate { 32 class VIEWS_EXPORT BridgedNativeWidget : public internal::InputMethodDelegate,
33 public FocusChangeListener {
32 public: 34 public:
33 // Creates one side of the bridge. |parent| can be NULL in tests. 35 // Creates one side of the bridge. |parent| can be NULL in tests.
34 BridgedNativeWidget(NativeWidgetMac* parent); 36 BridgedNativeWidget(NativeWidgetMac* parent);
35 virtual ~BridgedNativeWidget(); 37 virtual ~BridgedNativeWidget();
36 38
37 // Initialize the bridge, "retains" ownership of |window|. 39 // Initialize the bridge, "retains" ownership of |window|.
38 void Init(base::scoped_nsobject<NSWindow> window); 40 void Init(base::scoped_nsobject<NSWindow> window);
39 41
40 // Set or clears the views::View bridged by the content view. This does NOT 42 // Set or clears the views::View bridged by the content view. This does NOT
41 // take ownership of |view|. 43 // take ownership of |view|.
42 void SetRootView(views::View* view); 44 void SetRootView(views::View* view);
43 45
44 // See widget.h for documentation. 46 // See widget.h for documentation.
45 InputMethod* CreateInputMethod(); 47 InputMethod* CreateInputMethod();
46 ui::InputMethod* GetHostInputMethod(); 48 ui::InputMethod* GetHostInputMethod();
47 49
48 NativeWidgetMac* native_widget_mac() { return native_widget_mac_; } 50 NativeWidgetMac* native_widget_mac() { return native_widget_mac_; }
49 BridgedContentView* ns_view() { return bridged_view_; } 51 BridgedContentView* ns_view() { return bridged_view_; }
50 NSWindow* ns_window() { return window_; } 52 NSWindow* ns_window() { return window_; }
51 53
52 // Overridden from internal::InputMethodDelegate: 54 // Overridden from internal::InputMethodDelegate:
53 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; 55 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
54 56
55 private: 57 private:
56 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. 58 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this.
57 base::scoped_nsobject<NSWindow> window_; 59 base::scoped_nsobject<NSWindow> window_;
58 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; 60 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
59 base::scoped_nsobject<BridgedContentView> bridged_view_; 61 base::scoped_nsobject<BridgedContentView> bridged_view_;
60 scoped_ptr<ui::InputMethod> input_method_; 62 scoped_ptr<ui::InputMethod> input_method_;
63 FocusManager* focus_manager_; // Weak. Owned by our Widget.
64 // Will be NULL if native_widget_mac_ is NULL.
65
66 // Overridden from FocusChangeListener:
67 virtual void OnWillChangeFocus(View* focused_before,
68 View* focused_now) OVERRIDE;
69 virtual void OnDidChangeFocus(View* focused_before,
70 View* focused_now) OVERRIDE;
61 71
62 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); 72 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget);
63 }; 73 };
64 74
65 } // namespace views 75 } // namespace views
66 76
67 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 77 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698