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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_mac.h

Issue 8477042: Move Sad Tab implementation out of the TabContentsViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changes for jochen and jam Created 9 years, 1 month 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #if defined(__OBJC__) 9 #if defined(__OBJC__)
10 10
11 #import <Cocoa/Cocoa.h> 11 #import <Cocoa/Cocoa.h>
12 12
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/memory/scoped_nsobject.h" 16 #include "base/memory/scoped_nsobject.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" 18 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
19 #include "content/browser/tab_contents/tab_contents_view.h" 19 #include "content/browser/tab_contents/tab_contents_view.h"
20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h"
22 #include "ui/base/cocoa/base_view.h" 20 #include "ui/base/cocoa/base_view.h"
23 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
24 22
25 @class FocusTracker; 23 @class FocusTracker;
26 class RenderViewContextMenuMac; 24 class RenderViewContextMenuMac;
27 @class SadTabController; 25 @class SadTabController;
28 class SkBitmap; 26 class SkBitmap;
29 class TabContentsViewMac; 27 class TabContentsViewMac;
30 class WebDragBookmarkHandlerMac; 28 class WebDragBookmarkHandlerMac;
31 @class WebDragDest; 29 @class WebDragDest;
32 @class WebDragSource; 30 @class WebDragSource;
33 namespace gfx { 31 namespace gfx {
34 class Point; 32 class Point;
35 } 33 }
36 34
37 @interface TabContentsViewCocoa : BaseView { 35 @interface TabContentsViewCocoa : BaseView {
38 @private 36 @private
39 TabContentsViewMac* tabContentsView_; // WEAK; owns us 37 TabContentsViewMac* tabContentsView_; // WEAK; owns us
40 scoped_nsobject<WebDragSource> dragSource_; 38 scoped_nsobject<WebDragSource> dragSource_;
41 scoped_nsobject<WebDragDest> dragDest_; 39 scoped_nsobject<WebDragDest> dragDest_;
42 scoped_ptr<WebDragBookmarkHandlerMac> bookmarkHandler_; 40 scoped_ptr<WebDragBookmarkHandlerMac> bookmarkHandler_;
43 } 41 }
44 42
45 // Expose this, since sometimes one needs both the NSView and the TabContents. 43 // Expose this, since sometimes one needs both the NSView and the TabContents.
46 - (TabContents*)tabContents; 44 - (TabContents*)tabContents;
47 @end 45 @end
48 46
49 // Mac-specific implementation of the TabContentsView. It owns an NSView that 47 // Mac-specific implementation of the TabContentsView. It owns an NSView that
50 // contains all of the contents of the tab and associated child views. 48 // contains all of the contents of the tab and associated child views.
51 class TabContentsViewMac : public TabContentsView, 49 class TabContentsViewMac : public TabContentsView {
52 public content::NotificationObserver {
53 public: 50 public:
54 // The corresponding TabContents is passed in the constructor, and manages our 51 // The corresponding TabContents is passed in the constructor, and manages our
55 // lifetime. This doesn't need to be the case, but is this way currently 52 // lifetime. This doesn't need to be the case, but is this way currently
56 // because that's what was easiest when they were split. 53 // because that's what was easiest when they were split.
57 explicit TabContentsViewMac(TabContents* web_contents); 54 explicit TabContentsViewMac(TabContents* web_contents);
58 virtual ~TabContentsViewMac(); 55 virtual ~TabContentsViewMac();
59 56
60 // TabContentsView implementation -------------------------------------------- 57 // TabContentsView implementation --------------------------------------------
61 58
62 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; 59 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
(...skipping 10 matching lines...) Expand all
73 virtual void SizeContents(const gfx::Size& size) OVERRIDE; 70 virtual void SizeContents(const gfx::Size& size) OVERRIDE;
74 virtual void Focus() OVERRIDE; 71 virtual void Focus() OVERRIDE;
75 virtual void SetInitialFocus() OVERRIDE; 72 virtual void SetInitialFocus() OVERRIDE;
76 virtual void StoreFocus() OVERRIDE; 73 virtual void StoreFocus() OVERRIDE;
77 virtual void RestoreFocus() OVERRIDE; 74 virtual void RestoreFocus() OVERRIDE;
78 virtual bool IsDoingDrag() const OVERRIDE; 75 virtual bool IsDoingDrag() const OVERRIDE;
79 virtual void CancelDragAndCloseTab() OVERRIDE; 76 virtual void CancelDragAndCloseTab() OVERRIDE;
80 virtual bool IsEventTracking() const OVERRIDE; 77 virtual bool IsEventTracking() const OVERRIDE;
81 virtual void CloseTabAfterEventTracking() OVERRIDE; 78 virtual void CloseTabAfterEventTracking() OVERRIDE;
82 virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE; 79 virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE;
80 virtual void InstallOverlayView(gfx::NativeView view) OVERRIDE;
81 virtual void RemoveOverlayView() OVERRIDE;
83 82
84 // Backend implementation of RenderViewHostDelegate::View. 83 // Backend implementation of RenderViewHostDelegate::View.
85 virtual void CreateNewWindow( 84 virtual void CreateNewWindow(
86 int route_id, 85 int route_id,
87 const ViewHostMsg_CreateWindow_Params& params); 86 const ViewHostMsg_CreateWindow_Params& params);
88 virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); 87 virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type);
89 virtual void CreateNewFullscreenWidget(int route_id); 88 virtual void CreateNewFullscreenWidget(int route_id);
90 virtual void ShowCreatedWindow(int route_id, 89 virtual void ShowCreatedWindow(int route_id,
91 WindowOpenDisposition disposition, 90 WindowOpenDisposition disposition,
92 const gfx::Rect& initial_pos, 91 const gfx::Rect& initial_pos,
93 bool user_gesture); 92 bool user_gesture);
94 virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); 93 virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos);
95 virtual void ShowCreatedFullscreenWidget(int route_id); 94 virtual void ShowCreatedFullscreenWidget(int route_id);
96 virtual void ShowContextMenu(const ContextMenuParams& params); 95 virtual void ShowContextMenu(const ContextMenuParams& params);
97 virtual void ShowPopupMenu(const gfx::Rect& bounds, 96 virtual void ShowPopupMenu(const gfx::Rect& bounds,
98 int item_height, 97 int item_height,
99 double item_font_size, 98 double item_font_size,
100 int selected_item, 99 int selected_item,
101 const std::vector<WebMenuItem>& items, 100 const std::vector<WebMenuItem>& items,
102 bool right_aligned); 101 bool right_aligned);
103 virtual void StartDragging(const WebDropData& drop_data, 102 virtual void StartDragging(const WebDropData& drop_data,
104 WebKit::WebDragOperationsMask allowed_operations, 103 WebKit::WebDragOperationsMask allowed_operations,
105 const SkBitmap& image, 104 const SkBitmap& image,
106 const gfx::Point& image_offset); 105 const gfx::Point& image_offset);
107 virtual void UpdateDragCursor(WebKit::WebDragOperation operation); 106 virtual void UpdateDragCursor(WebKit::WebDragOperation operation);
108 virtual void GotFocus(); 107 virtual void GotFocus();
109 virtual void TakeFocus(bool reverse); 108 virtual void TakeFocus(bool reverse);
110 109
111 // content::NotificationObserver implementation ------------------------------
112
113 virtual void Observe(int type,
114 const content::NotificationSource& source,
115 const content::NotificationDetails& details);
116
117 // A helper method for closing the tab in the 110 // A helper method for closing the tab in the
118 // CloseTabAfterEventTracking() implementation. 111 // CloseTabAfterEventTracking() implementation.
119 void CloseTab(); 112 void CloseTab();
120 113
121 TabContents* tab_contents() { return tab_contents_; } 114 TabContents* tab_contents() { return tab_contents_; }
122 int preferred_width() const { return preferred_width_; } 115 int preferred_width() const { return preferred_width_; }
123 116
124 private: 117 private:
125 // The TabContents whose contents we display. 118 // The TabContents whose contents we display.
126 TabContents* tab_contents_; 119 TabContents* tab_contents_;
127 120
128 // Common implementations of some RenderViewHostDelegate::View methods. 121 // Common implementations of some RenderViewHostDelegate::View methods.
129 RenderViewHostDelegateViewHelper delegate_view_helper_; 122 RenderViewHostDelegateViewHelper delegate_view_helper_;
130 123
131 // The Cocoa NSView that lives in the view hierarchy. 124 // The Cocoa NSView that lives in the view hierarchy.
132 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; 125 scoped_nsobject<TabContentsViewCocoa> cocoa_view_;
133 126
134 // Keeps track of which NSView has focus so we can restore the focus when 127 // Keeps track of which NSView has focus so we can restore the focus when
135 // focus returns. 128 // focus returns.
136 scoped_nsobject<FocusTracker> focus_tracker_; 129 scoped_nsobject<FocusTracker> focus_tracker_;
137 130
138 // Used to get notifications about renderers coming and going.
139 content::NotificationRegistrar registrar_;
140
141 // Used to render the sad tab. This will be non-NULL only when the sad tab is
142 // visible.
143 scoped_nsobject<SadTabController> sad_tab_;
144
145 // The context menu. Callbacks are asynchronous so we need to keep it around. 131 // The context menu. Callbacks are asynchronous so we need to keep it around.
146 scoped_ptr<RenderViewContextMenuMac> context_menu_; 132 scoped_ptr<RenderViewContextMenuMac> context_menu_;
147 133
148 // The page content's intrinsic width. 134 // The page content's intrinsic width.
149 int preferred_width_; 135 int preferred_width_;
150 136
137 // The overlaid view. Owned by the caller of |InstallOverlayView|; this is a
138 // weak reference.
139 NSView* overlaid_view_;
140
151 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); 141 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac);
152 }; 142 };
153 143
154 #endif // __OBJC__ 144 #endif // __OBJC__
155 145
156 // Functions that may be accessed from non-Objective-C C/C++ code. 146 // Functions that may be accessed from non-Objective-C C/C++ code.
157 class TabContents; 147 class TabContents;
158 class TabContentsView; 148 class TabContentsView;
159 149
160 namespace tab_contents_view_mac { 150 namespace tab_contents_view_mac {
161 TabContentsView* CreateTabContentsView(TabContents* tab_contents); 151 TabContentsView* CreateTabContentsView(TabContents* tab_contents);
162 } 152 }
163 153
164 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ 154 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents_view_gtk.cc ('k') | chrome/browser/tab_contents/tab_contents_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698