| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/tab_contents/tab_contents_view_helper.h" | 18 #include "content/browser/tab_contents/tab_contents_view_helper.h" |
| 19 #include "content/public/browser/web_contents_view.h" | 19 #include "content/public/browser/web_contents_view.h" |
| 20 #include "ui/base/cocoa/base_view.h" | 20 #include "ui/base/cocoa/base_view.h" |
| 21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 22 | 22 |
| 23 @class FocusTracker; | 23 @class FocusTracker; |
| 24 class RenderViewContextMenuMac; | |
| 25 @class SadTabController; | |
| 26 class SkBitmap; | 24 class SkBitmap; |
| 27 class TabContentsViewMac; | 25 class TabContentsViewMac; |
| 28 class WebDragBookmarkHandlerMac; | |
| 29 @class WebDragDest; | 26 @class WebDragDest; |
| 30 @class WebDragSource; | 27 @class WebDragSource; |
| 28 |
| 29 namespace content { |
| 30 class WebContentsViewMacDelegate; |
| 31 } |
| 32 |
| 31 namespace gfx { | 33 namespace gfx { |
| 32 class Point; | 34 class Point; |
| 33 } | 35 } |
| 34 | 36 |
| 35 @interface TabContentsViewCocoa : BaseView { | 37 @interface TabContentsViewCocoa : BaseView { |
| 36 @private | 38 @private |
| 37 TabContentsViewMac* tabContentsView_; // WEAK; owns us | 39 TabContentsViewMac* tabContentsView_; // WEAK; owns us |
| 38 scoped_nsobject<WebDragSource> dragSource_; | 40 scoped_nsobject<WebDragSource> dragSource_; |
| 39 scoped_nsobject<WebDragDest> dragDest_; | 41 scoped_nsobject<WebDragDest> dragDest_; |
| 40 scoped_ptr<WebDragBookmarkHandlerMac> bookmarkHandler_; | |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Expose this, since sometimes one needs both the NSView and the TabContents. | 44 // Expose this, since sometimes one needs both the NSView and the TabContents. |
| 44 - (TabContents*)tabContents; | 45 - (TabContents*)tabContents; |
| 45 | 46 |
| 46 // Set frame, then notify the RenderWidgetHost that the frame has been changed, | 47 // Set frame, then notify the RenderWidgetHost that the frame has been changed, |
| 47 // but do it in a separate task, using |performSelector:withObject:afterDelay:|. | 48 // but do it in a separate task, using |performSelector:withObject:afterDelay:|. |
| 48 // This stops the flickering issue in http://crbug.com/31970 | 49 // This stops the flickering issue in http://crbug.com/31970 |
| 49 - (void)setFrameWithDeferredUpdate:(NSRect)frame; | 50 - (void)setFrameWithDeferredUpdate:(NSRect)frame; |
| 50 @end | 51 @end |
| 51 | 52 |
| 52 // Mac-specific implementation of the WebContentsView. It owns an NSView that | 53 // Mac-specific implementation of the WebContentsView. It owns an NSView that |
| 53 // contains all of the contents of the tab and associated child views. | 54 // contains all of the contents of the tab and associated child views. |
| 54 class TabContentsViewMac : public content::WebContentsView { | 55 class TabContentsViewMac : public content::WebContentsView { |
| 55 public: | 56 public: |
| 56 // The corresponding TabContents is passed in the constructor, and manages our | 57 // The corresponding TabContents is passed in the constructor, and manages our |
| 57 // lifetime. This doesn't need to be the case, but is this way currently | 58 // lifetime. This doesn't need to be the case, but is this way currently |
| 58 // because that's what was easiest when they were split. | 59 // because that's what was easiest when they were split. |
| 59 // TODO(jam): make this take a WebContents once it's created from content. | 60 // TODO(jam): make this take a WebContents once it's created from content. |
| 60 explicit TabContentsViewMac(content::WebContents* web_contents); | 61 TabContentsViewMac(content::WebContents* web_contents, |
| 62 content::WebContentsViewMacDelegate* delegate); |
| 61 virtual ~TabContentsViewMac(); | 63 virtual ~TabContentsViewMac(); |
| 62 | 64 |
| 63 // WebContentsView implementation -------------------------------------------- | 65 // WebContentsView implementation -------------------------------------------- |
| 64 | 66 |
| 65 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; | 67 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; |
| 66 virtual RenderWidgetHostView* CreateViewForWidget( | 68 virtual RenderWidgetHostView* CreateViewForWidget( |
| 67 RenderWidgetHost* render_widget_host) OVERRIDE; | 69 RenderWidgetHost* render_widget_host) OVERRIDE; |
| 68 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 70 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 69 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; | 71 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; |
| 70 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; | 72 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const gfx::Point& image_offset) OVERRIDE; | 115 const gfx::Point& image_offset) OVERRIDE; |
| 114 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; | 116 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; |
| 115 virtual void GotFocus() OVERRIDE; | 117 virtual void GotFocus() OVERRIDE; |
| 116 virtual void TakeFocus(bool reverse) OVERRIDE; | 118 virtual void TakeFocus(bool reverse) OVERRIDE; |
| 117 | 119 |
| 118 // A helper method for closing the tab in the | 120 // A helper method for closing the tab in the |
| 119 // CloseTabAfterEventTracking() implementation. | 121 // CloseTabAfterEventTracking() implementation. |
| 120 void CloseTab(); | 122 void CloseTab(); |
| 121 | 123 |
| 122 TabContents* tab_contents() { return tab_contents_; } | 124 TabContents* tab_contents() { return tab_contents_; } |
| 125 content::WebContentsViewMacDelegate* delegate() { return delegate_.get(); } |
| 123 | 126 |
| 124 private: | 127 private: |
| 125 // The TabContents whose contents we display. | 128 // The TabContents whose contents we display. |
| 126 TabContents* tab_contents_; | 129 TabContents* tab_contents_; |
| 127 | 130 |
| 128 // Common implementations of some WebContentsView methods. | 131 // Common implementations of some WebContentsView methods. |
| 129 TabContentsViewHelper tab_contents_view_helper_; | 132 TabContentsViewHelper tab_contents_view_helper_; |
| 130 | 133 |
| 131 // The Cocoa NSView that lives in the view hierarchy. | 134 // The Cocoa NSView that lives in the view hierarchy. |
| 132 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; | 135 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; |
| 133 | 136 |
| 134 // Keeps track of which NSView has focus so we can restore the focus when | 137 // Keeps track of which NSView has focus so we can restore the focus when |
| 135 // focus returns. | 138 // focus returns. |
| 136 scoped_nsobject<FocusTracker> focus_tracker_; | 139 scoped_nsobject<FocusTracker> focus_tracker_; |
| 137 | 140 |
| 138 // The context menu. Callbacks are asynchronous so we need to keep it around. | 141 // Our optional delegate. |
| 139 scoped_ptr<RenderViewContextMenuMac> context_menu_; | 142 scoped_ptr<content::WebContentsViewMacDelegate> delegate_; |
| 140 | 143 |
| 141 // The overlaid view. Owned by the caller of |InstallOverlayView|; this is a | 144 // The overlaid view. Owned by the caller of |InstallOverlayView|; this is a |
| 142 // weak reference. | 145 // weak reference. |
| 143 NSView* overlaid_view_; | 146 NSView* overlaid_view_; |
| 144 | 147 |
| 145 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); | 148 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); |
| 146 }; | 149 }; |
| 147 | 150 |
| 148 #endif // __OBJC__ | 151 #endif // __OBJC__ |
| 149 | 152 |
| 150 // Functions that may be accessed from non-Objective-C C/C++ code. | 153 // Functions that may be accessed from non-Objective-C C/C++ code. |
| 151 namespace content { | 154 namespace content { |
| 152 class WebContents; | 155 class WebContents; |
| 153 class WebContentsView; | 156 class WebContentsView; |
| 157 class WebContentsViewMacDelegate; |
| 154 } | 158 } |
| 155 | 159 |
| 156 namespace tab_contents_view_mac { | 160 namespace tab_contents_view_mac { |
| 161 // Creates a TabContentsViewMac. Takes ownership of |delegate|. |
| 157 content::WebContentsView* CreateWebContentsView( | 162 content::WebContentsView* CreateWebContentsView( |
| 158 content::WebContents* web_contents); | 163 content::WebContents* web_contents, |
| 164 content::WebContentsViewMacDelegate* delegate); |
| 159 } | 165 } |
| 160 | 166 |
| 161 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ | 167 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ |
| OLD | NEW |