OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Mac-specific implementation of the TabContentsView. It owns an NSView that | 38 // Mac-specific implementation of the TabContentsView. It owns an NSView that |
39 // contains all of the contents of the tab and associated child views. | 39 // contains all of the contents of the tab and associated child views. |
40 class TabContentsViewMac : public TabContentsView, | 40 class TabContentsViewMac : public TabContentsView, |
41 public NotificationObserver { | 41 public NotificationObserver { |
42 public: | 42 public: |
43 // The corresponding TabContents is passed in the constructor, and manages our | 43 // The corresponding TabContents is passed in the constructor, and manages our |
44 // lifetime. This doesn't need to be the case, but is this way currently | 44 // lifetime. This doesn't need to be the case, but is this way currently |
45 // because that's what was easiest when they were split. | 45 // because that's what was easiest when they were split. |
46 explicit TabContentsViewMac(TabContents* web_contents); | 46 explicit TabContentsViewMac(TabContents* web_contents); |
| 47 virtual ~TabContentsViewMac(); |
47 | 48 |
48 // TabContentsView implementation -------------------------------------------- | 49 // TabContentsView implementation -------------------------------------------- |
49 | 50 |
50 virtual void CreateView(const gfx::Size& initial_size); | 51 virtual void CreateView(const gfx::Size& initial_size); |
51 virtual RenderWidgetHostView* CreateViewForWidget( | 52 virtual RenderWidgetHostView* CreateViewForWidget( |
52 RenderWidgetHost* render_widget_host); | 53 RenderWidgetHost* render_widget_host); |
53 virtual gfx::NativeView GetNativeView() const; | 54 virtual gfx::NativeView GetNativeView() const; |
54 virtual gfx::NativeView GetContentNativeView() const; | 55 virtual gfx::NativeView GetContentNativeView() const; |
55 virtual gfx::NativeWindow GetTopLevelNativeWindow() const; | 56 virtual gfx::NativeWindow GetTopLevelNativeWindow() const; |
56 virtual void GetContainerBounds(gfx::Rect* out) const; | 57 virtual void GetContainerBounds(gfx::Rect* out) const; |
57 virtual void RenderViewCreated(RenderViewHost* host); | 58 virtual void RenderViewCreated(RenderViewHost* host); |
58 virtual void SetPageTitle(const std::wstring& title); | 59 virtual void SetPageTitle(const std::wstring& title); |
59 virtual void OnTabCrashed(); | 60 virtual void OnTabCrashed(); |
60 virtual void SizeContents(const gfx::Size& size); | 61 virtual void SizeContents(const gfx::Size& size); |
61 virtual void Focus(); | 62 virtual void Focus(); |
62 virtual void SetInitialFocus(); | 63 virtual void SetInitialFocus(); |
63 virtual void StoreFocus(); | 64 virtual void StoreFocus(); |
64 virtual void RestoreFocus(); | 65 virtual void RestoreFocus(); |
65 virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, | 66 virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, |
66 bool activatable); | 67 bool activatable); |
67 virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, | 68 virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, |
68 const gfx::Rect& initial_pos); | 69 const gfx::Rect& initial_pos); |
| 70 virtual bool IsEventTracking() const; |
| 71 virtual void CloseTabAfterEventTracking(); |
69 | 72 |
70 // Backend implementation of RenderViewHostDelegate::View. | 73 // Backend implementation of RenderViewHostDelegate::View. |
71 virtual void ShowContextMenu(const ContextMenuParams& params); | 74 virtual void ShowContextMenu(const ContextMenuParams& params); |
72 virtual void StartDragging(const WebDropData& drop_data, | 75 virtual void StartDragging(const WebDropData& drop_data, |
73 WebKit::WebDragOperationsMask allowed_operations); | 76 WebKit::WebDragOperationsMask allowed_operations); |
74 virtual void UpdateDragCursor(WebKit::WebDragOperation operation); | 77 virtual void UpdateDragCursor(WebKit::WebDragOperation operation); |
75 virtual void GotFocus(); | 78 virtual void GotFocus(); |
76 virtual void TakeFocus(bool reverse); | 79 virtual void TakeFocus(bool reverse); |
77 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 80 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
78 | 81 |
79 // NotificationObserver implementation --------------------------------------- | 82 // NotificationObserver implementation --------------------------------------- |
80 | 83 |
81 virtual void Observe(NotificationType type, | 84 virtual void Observe(NotificationType type, |
82 const NotificationSource& source, | 85 const NotificationSource& source, |
83 const NotificationDetails& details); | 86 const NotificationDetails& details); |
84 | 87 |
| 88 // A helper method for closing the tab in the |
| 89 // CloseTabAfterEventTracking() implementation. |
| 90 void CloseTab(); |
| 91 |
85 private: | 92 private: |
86 // The Cocoa NSView that lives in the view hierarchy. | 93 // The Cocoa NSView that lives in the view hierarchy. |
87 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; | 94 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; |
88 | 95 |
89 // Keeps track of which NSView has focus so we can restore the focus when | 96 // Keeps track of which NSView has focus so we can restore the focus when |
90 // focus returns. | 97 // focus returns. |
91 scoped_nsobject<FocusTracker> focus_tracker_; | 98 scoped_nsobject<FocusTracker> focus_tracker_; |
92 | 99 |
93 // Used to get notifications about renderers coming and going. | 100 // Used to get notifications about renderers coming and going. |
94 NotificationRegistrar registrar_; | 101 NotificationRegistrar registrar_; |
95 | 102 |
96 // Used to render the sad tab. This will be non-NULL only when the sad tab is | 103 // Used to render the sad tab. This will be non-NULL only when the sad tab is |
97 // visible. | 104 // visible. |
98 scoped_nsobject<SadTabView> sad_tab_; | 105 scoped_nsobject<SadTabView> sad_tab_; |
99 | 106 |
100 // The page content's intrinsic width. | 107 // The page content's intrinsic width. |
101 int preferred_width_; | 108 int preferred_width_; |
102 | 109 |
103 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); | 110 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); |
104 }; | 111 }; |
105 | 112 |
106 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ | 113 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ |
OLD | NEW |