OLD | NEW |
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_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate
.h" | 11 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate
.h" |
12 #include "content/browser/tab_contents/tab_contents_view.h" | 12 #include "content/browser/tab_contents/tab_contents_view.h" |
| 13 #include "views/widget/widget.h" |
13 | 14 |
14 class NativeTabContentsView; | 15 class NativeTabContentsView; |
15 class RenderViewContextMenuViews; | 16 class RenderViewContextMenuViews; |
16 class SadTabView; | 17 class SadTabView; |
17 class SkBitmap; | 18 class SkBitmap; |
18 struct WebDropData; | 19 struct WebDropData; |
19 namespace gfx { | 20 namespace gfx { |
20 class Point; | 21 class Point; |
21 class Size; | 22 class Size; |
22 } | 23 } |
23 namespace views { | 24 namespace views { |
24 class Widget; | 25 class Widget; |
25 } | 26 } |
26 | 27 |
27 // Views-specific implementation of the TabContentsView. | 28 // Views-specific implementation of the TabContentsView. |
28 // TODO(beng): Remove last remnants of Windows-specificity, and make this | 29 // TODO(beng): Remove last remnants of Windows-specificity, and make this |
29 // subclass Widget. | 30 // subclass Widget. |
30 class TabContentsViewViews : public TabContentsView, | 31 class TabContentsViewViews : public views::Widget, |
| 32 public TabContentsView, |
31 public internal::NativeTabContentsViewDelegate { | 33 public internal::NativeTabContentsViewDelegate { |
32 public: | 34 public: |
33 // The corresponding TabContents is passed in the constructor, and manages our | 35 // The corresponding TabContents is passed in the constructor, and manages our |
34 // lifetime. This doesn't need to be the case, but is this way currently | 36 // lifetime. This doesn't need to be the case, but is this way currently |
35 // because that's what was easiest when they were split. | 37 // because that's what was easiest when they were split. |
36 explicit TabContentsViewViews(TabContents* tab_contents); | 38 explicit TabContentsViewViews(TabContents* tab_contents); |
37 virtual ~TabContentsViewViews(); | 39 virtual ~TabContentsViewViews(); |
38 | 40 |
39 // Reset the native parent of this view to NULL. Unparented windows should | 41 // Reset the native parent of this view to NULL. Unparented windows should |
40 // not receive any messages. | 42 // not receive any messages. |
41 virtual void Unparent(); | 43 virtual void Unparent(); |
42 | 44 |
| 45 NativeTabContentsView* native_tab_contents_view() const { |
| 46 return native_tab_contents_view_; |
| 47 } |
| 48 |
43 // Overridden from TabContentsView: | 49 // Overridden from TabContentsView: |
44 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; | 50 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; |
45 virtual RenderWidgetHostView* CreateViewForWidget( | 51 virtual RenderWidgetHostView* CreateViewForWidget( |
46 RenderWidgetHost* render_widget_host) OVERRIDE; | 52 RenderWidgetHost* render_widget_host) OVERRIDE; |
47 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 53 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
48 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; | 54 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; |
49 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; | 55 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; |
50 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; | 56 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; |
51 virtual void SetPageTitle(const std::wstring& title) OVERRIDE; | 57 virtual void SetPageTitle(const std::wstring& title) OVERRIDE; |
52 virtual void OnTabCrashed(base::TerminationStatus status, | 58 virtual void OnTabCrashed(base::TerminationStatus status, |
(...skipping 21 matching lines...) Expand all Loading... |
74 virtual void GotFocus() OVERRIDE; | 80 virtual void GotFocus() OVERRIDE; |
75 virtual void TakeFocus(bool reverse) OVERRIDE; | 81 virtual void TakeFocus(bool reverse) OVERRIDE; |
76 | 82 |
77 private: | 83 private: |
78 // Overridden from internal::NativeTabContentsViewDelegate: | 84 // Overridden from internal::NativeTabContentsViewDelegate: |
79 virtual TabContents* GetTabContents() OVERRIDE; | 85 virtual TabContents* GetTabContents() OVERRIDE; |
80 virtual bool IsShowingSadTab() const OVERRIDE; | 86 virtual bool IsShowingSadTab() const OVERRIDE; |
81 virtual void OnNativeTabContentsViewShown() OVERRIDE; | 87 virtual void OnNativeTabContentsViewShown() OVERRIDE; |
82 virtual void OnNativeTabContentsViewHidden() OVERRIDE; | 88 virtual void OnNativeTabContentsViewHidden() OVERRIDE; |
83 virtual void OnNativeTabContentsViewSized(const gfx::Size& size) OVERRIDE; | 89 virtual void OnNativeTabContentsViewSized(const gfx::Size& size) OVERRIDE; |
84 virtual void OnNativeTabContentsViewWheelZoom(int distance) OVERRIDE; | 90 virtual void OnNativeTabContentsViewWheelZoom(bool zoom_in) OVERRIDE; |
85 virtual void OnNativeTabContentsViewMouseDown() OVERRIDE; | 91 virtual void OnNativeTabContentsViewMouseDown() OVERRIDE; |
86 virtual void OnNativeTabContentsViewMouseMove() OVERRIDE; | 92 virtual void OnNativeTabContentsViewMouseMove(bool motion) OVERRIDE; |
87 virtual void OnNativeTabContentsViewDraggingEnded() OVERRIDE; | 93 virtual void OnNativeTabContentsViewDraggingEnded() OVERRIDE; |
| 94 virtual views::internal::NativeWidgetDelegate* AsNativeWidgetDelegate() |
| 95 OVERRIDE; |
88 | 96 |
89 views::Widget* GetWidget(); | 97 // Overridden from views::Widget: |
90 const views::Widget* GetWidget() const; | 98 virtual views::FocusManager* GetFocusManager() OVERRIDE; |
91 | 99 |
92 // A helper method for closing the tab. | 100 // A helper method for closing the tab. |
93 void CloseTab(); | 101 void CloseTab(); |
94 | 102 |
95 // Windows events ------------------------------------------------------------ | 103 // Windows events ------------------------------------------------------------ |
96 | 104 |
97 // Handles notifying the TabContents and other operations when the window was | 105 // Handles notifying the TabContents and other operations when the window was |
98 // shown or hidden. | 106 // shown or hidden. |
99 void WasHidden(); | 107 void WasHidden(); |
100 void WasShown(); | 108 void WasShown(); |
101 | 109 |
102 // Handles resizing of the contents. This will notify the RenderWidgetHostView | 110 // Handles resizing of the contents. This will notify the RenderWidgetHostView |
103 // of the change, reposition popups, and the find in page bar. | 111 // of the change, reposition popups, and the find in page bar. |
104 void WasSized(const gfx::Size& size); | 112 void WasSized(const gfx::Size& size); |
105 | 113 |
106 // TODO(brettw) comment these. They're confusing. | 114 // TODO(brettw) comment these. They're confusing. |
107 void WheelZoom(int distance); | 115 void WheelZoom(int distance); |
108 | 116 |
109 // --------------------------------------------------------------------------- | 117 // --------------------------------------------------------------------------- |
110 | 118 |
111 scoped_ptr<NativeTabContentsView> native_tab_contents_view_; | 119 NativeTabContentsView* native_tab_contents_view_; |
112 | 120 |
113 // Used to render the sad tab. This will be non-NULL only when the sad tab is | 121 // Used to render the sad tab. This will be non-NULL only when the sad tab is |
114 // visible. | 122 // visible. |
115 SadTabView* sad_tab_; | 123 SadTabView* sad_tab_; |
116 | 124 |
117 // The id used in the ViewStorage to store the last focused view. | 125 // The id used in the ViewStorage to store the last focused view. |
118 int last_focused_view_storage_id_; | 126 int last_focused_view_storage_id_; |
119 | 127 |
120 // The context menu. Callbacks are asynchronous so we need to keep it around. | 128 // The context menu. Callbacks are asynchronous so we need to keep it around. |
121 scoped_ptr<RenderViewContextMenuViews> context_menu_; | 129 scoped_ptr<RenderViewContextMenuViews> context_menu_; |
122 | 130 |
123 // Set to true if we want to close the tab after the system drag operation | 131 // Set to true if we want to close the tab after the system drag operation |
124 // has finished. | 132 // has finished. |
125 bool close_tab_after_drag_ends_; | 133 bool close_tab_after_drag_ends_; |
126 | 134 |
127 // Used to close the tab after the stack has unwound. | 135 // Used to close the tab after the stack has unwound. |
128 base::OneShotTimer<TabContentsViewViews> close_tab_timer_; | 136 base::OneShotTimer<TabContentsViewViews> close_tab_timer_; |
129 | 137 |
| 138 // The FocusManager associated with this tab. Stored as it is not directly |
| 139 // accessible when un-parented. |
| 140 views::FocusManager* focus_manager_; |
| 141 |
130 DISALLOW_COPY_AND_ASSIGN(TabContentsViewViews); | 142 DISALLOW_COPY_AND_ASSIGN(TabContentsViewViews); |
131 }; | 143 }; |
132 | 144 |
133 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ | 145 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ |
OLD | NEW |