| 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> |
| 11 |
| 10 #include "base/gfx/size.h" | 12 #include "base/gfx/size.h" |
| 11 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 12 #include "base/scoped_nsobject.h" | 14 #include "base/scoped_nsobject.h" |
| 13 #include "chrome/browser/cocoa/base_view.h" | 15 #include "chrome/browser/cocoa/base_view.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents_view.h" | 16 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 15 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
| 16 | 18 |
| 19 class FilePath; |
| 17 class FindBarMac; | 20 class FindBarMac; |
| 18 @class SadTabView; | 21 @class SadTabView; |
| 19 class TabContentsViewMac; | 22 class TabContentsViewMac; |
| 23 @class WebDragSource; |
| 20 @class WebDropTarget; | 24 @class WebDropTarget; |
| 21 | 25 |
| 22 @interface TabContentsViewCocoa : BaseView { | 26 @interface TabContentsViewCocoa : BaseView { |
| 23 @private | 27 @private |
| 24 TabContentsViewMac* tabContentsView_; // WEAK; owns us | 28 TabContentsViewMac* tabContentsView_; // WEAK; owns us |
| 29 scoped_nsobject<WebDragSource> dragSource_; |
| 25 scoped_nsobject<WebDropTarget> dropTarget_; | 30 scoped_nsobject<WebDropTarget> dropTarget_; |
| 26 } | 31 } |
| 32 |
| 33 // Expose this, since sometimes one needs both the NSView and the TabContents. |
| 34 - (TabContents*)tabContents; |
| 27 @end | 35 @end |
| 28 | 36 |
| 29 // Mac-specific implementation of the TabContentsView. It owns an NSView that | 37 // Mac-specific implementation of the TabContentsView. It owns an NSView that |
| 30 // contains all of the contents of the tab and associated child views. | 38 // contains all of the contents of the tab and associated child views. |
| 31 class TabContentsViewMac : public TabContentsView, | 39 class TabContentsViewMac : public TabContentsView, |
| 32 public NotificationObserver { | 40 public NotificationObserver { |
| 33 public: | 41 public: |
| 34 // The corresponding TabContents is passed in the constructor, and manages our | 42 // The corresponding TabContents is passed in the constructor, and manages our |
| 35 // lifetime. This doesn't need to be the case, but is this way currently | 43 // lifetime. This doesn't need to be the case, but is this way currently |
| 36 // because that's what was easiest when they were split. | 44 // because that's what was easiest when they were split. |
| 37 explicit TabContentsViewMac(TabContents* web_contents); | 45 explicit TabContentsViewMac(TabContents* web_contents); |
| 38 virtual ~TabContentsViewMac(); | |
| 39 | 46 |
| 40 // TabContentsView implementation -------------------------------------------- | 47 // TabContentsView implementation -------------------------------------------- |
| 41 | 48 |
| 42 virtual void CreateView(); | 49 virtual void CreateView(); |
| 43 virtual RenderWidgetHostView* CreateViewForWidget( | 50 virtual RenderWidgetHostView* CreateViewForWidget( |
| 44 RenderWidgetHost* render_widget_host); | 51 RenderWidgetHost* render_widget_host); |
| 45 virtual gfx::NativeView GetNativeView() const; | 52 virtual gfx::NativeView GetNativeView() const; |
| 46 virtual gfx::NativeView GetContentNativeView() const; | 53 virtual gfx::NativeView GetContentNativeView() const; |
| 47 virtual gfx::NativeWindow GetTopLevelNativeWindow() const; | 54 virtual gfx::NativeWindow GetTopLevelNativeWindow() const; |
| 48 virtual void GetContainerBounds(gfx::Rect* out) const; | 55 virtual void GetContainerBounds(gfx::Rect* out) const; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 virtual void TakeFocus(bool reverse); | 75 virtual void TakeFocus(bool reverse); |
| 69 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 76 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
| 70 | 77 |
| 71 // NotificationObserver implementation --------------------------------------- | 78 // NotificationObserver implementation --------------------------------------- |
| 72 | 79 |
| 73 virtual void Observe(NotificationType type, | 80 virtual void Observe(NotificationType type, |
| 74 const NotificationSource& source, | 81 const NotificationSource& source, |
| 75 const NotificationDetails& details); | 82 const NotificationDetails& details); |
| 76 | 83 |
| 77 private: | 84 private: |
| 78 // Returns a drag pasteboard filled with the appropriate data. The types are | |
| 79 // populated in decending order of richness. | |
| 80 NSPasteboard* FillDragData(const WebDropData& drop_data); | |
| 81 | |
| 82 // The Cocoa NSView that lives in the view hierarchy. | 85 // The Cocoa NSView that lives in the view hierarchy. |
| 83 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; | 86 scoped_nsobject<TabContentsViewCocoa> cocoa_view_; |
| 84 | 87 |
| 85 // The Cocoa NSView to restore the focus to when focus returns. | 88 // The Cocoa NSView to restore the focus to when focus returns. |
| 86 scoped_nsobject<NSView> latent_focus_view_; | 89 scoped_nsobject<NSView> latent_focus_view_; |
| 87 | 90 |
| 88 // Used to get notifications about renderers coming and going. | 91 // Used to get notifications about renderers coming and going. |
| 89 NotificationRegistrar registrar_; | 92 NotificationRegistrar registrar_; |
| 90 | 93 |
| 91 // Used to render the sad tab. This will be non-NULL only when the sad tab is | 94 // Used to render the sad tab. This will be non-NULL only when the sad tab is |
| 92 // visible. | 95 // visible. |
| 93 scoped_nsobject<SadTabView> sad_tab_; | 96 scoped_nsobject<SadTabView> sad_tab_; |
| 94 | 97 |
| 95 // The page content's intrinsic width. | 98 // The page content's intrinsic width. |
| 96 int preferred_width_; | 99 int preferred_width_; |
| 97 | 100 |
| 98 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); | 101 DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ | 104 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_MAC_H_ |
| OLD | NEW |