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 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h" | 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h" |
6 | 6 |
7 #include "chrome/browser/tab_contents/web_drop_target_win.h" | 7 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h" |
8 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate
.h" | 8 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate
.h" |
9 #include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h" | 9 #include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h" |
| 10 #include "content/browser/tab_contents/web_drag_dest_win.h" |
10 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
12 #include "content/public/browser/web_contents_view.h" | 13 #include "content/public/browser/web_contents_view.h" |
13 #include "ui/views/views_delegate.h" | 14 #include "ui/views/views_delegate.h" |
14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
15 | 16 |
16 using content::RenderWidgetHostView; | 17 using content::RenderWidgetHostView; |
17 using content::WebContents; | 18 using content::WebContents; |
18 | 19 |
19 namespace { | 20 namespace { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 92 |
92 void NativeTabContentsViewWin::InitNativeTabContentsView() { | 93 void NativeTabContentsViewWin::InitNativeTabContentsView() { |
93 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 94 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
94 params.native_widget = this; | 95 params.native_widget = this; |
95 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 96 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
96 params.parent = HiddenTabHostWindow::Instance(); | 97 params.parent = HiddenTabHostWindow::Instance(); |
97 GetWidget()->Init(params); | 98 GetWidget()->Init(params); |
98 | 99 |
99 // Remove the root view drop target so we can register our own. | 100 // Remove the root view drop target so we can register our own. |
100 RevokeDragDrop(GetNativeView()); | 101 RevokeDragDrop(GetNativeView()); |
101 drop_target_ = new WebDropTarget(GetNativeView(), | 102 drag_dest_ = new WebDragDest(GetNativeView(), delegate_->GetWebContents()); |
102 delegate_->GetWebContents()); | 103 bookmark_handler_.reset(new WebDragBookmarkHandlerWin()); |
| 104 drag_dest_->set_delegate(bookmark_handler_.get()); |
103 } | 105 } |
104 | 106 |
105 void NativeTabContentsViewWin::Unparent() { | 107 void NativeTabContentsViewWin::Unparent() { |
106 // Note that we do not DCHECK on focus_manager_ as it may be NULL when used | 108 // Note that we do not DCHECK on focus_manager_ as it may be NULL when used |
107 // with an external tab container. | 109 // with an external tab container. |
108 views::Widget::ReparentNativeView(GetNativeView(), | 110 views::Widget::ReparentNativeView(GetNativeView(), |
109 HiddenTabHostWindow::Instance()); | 111 HiddenTabHostWindow::Instance()); |
110 } | 112 } |
111 | 113 |
112 RenderWidgetHostView* NativeTabContentsViewWin::CreateRenderWidgetHostView( | 114 RenderWidgetHostView* NativeTabContentsViewWin::CreateRenderWidgetHostView( |
(...skipping 27 matching lines...) Expand all Loading... |
140 void NativeTabContentsViewWin::CancelDrag() { | 142 void NativeTabContentsViewWin::CancelDrag() { |
141 drag_handler_->CancelDrag(); | 143 drag_handler_->CancelDrag(); |
142 } | 144 } |
143 | 145 |
144 bool NativeTabContentsViewWin::IsDoingDrag() const { | 146 bool NativeTabContentsViewWin::IsDoingDrag() const { |
145 return drag_handler_.get() != NULL; | 147 return drag_handler_.get() != NULL; |
146 } | 148 } |
147 | 149 |
148 void NativeTabContentsViewWin::SetDragCursor( | 150 void NativeTabContentsViewWin::SetDragCursor( |
149 WebKit::WebDragOperation operation) { | 151 WebKit::WebDragOperation operation) { |
150 drop_target_->set_drag_cursor(operation); | 152 drag_dest_->set_drag_cursor(operation); |
151 } | 153 } |
152 | 154 |
153 views::NativeWidget* NativeTabContentsViewWin::AsNativeWidget() { | 155 views::NativeWidget* NativeTabContentsViewWin::AsNativeWidget() { |
154 return this; | 156 return this; |
155 } | 157 } |
156 | 158 |
157 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
158 // NativeTabContentsViewWin, views::NativeWidgetWin overrides: | 160 // NativeTabContentsViewWin, views::NativeWidgetWin overrides: |
159 | 161 |
160 void NativeTabContentsViewWin::OnDestroy() { | 162 void NativeTabContentsViewWin::OnDestroy() { |
161 if (drop_target_.get()) { | 163 if (drag_dest_.get()) { |
162 RevokeDragDrop(GetNativeView()); | 164 RevokeDragDrop(GetNativeView()); |
163 drop_target_ = NULL; | 165 drag_dest_ = NULL; |
164 } | 166 } |
165 | 167 |
166 NativeWidgetWin::OnDestroy(); | 168 NativeWidgetWin::OnDestroy(); |
167 } | 169 } |
168 | 170 |
169 void NativeTabContentsViewWin::OnHScroll(int scroll_type, | 171 void NativeTabContentsViewWin::OnHScroll(int scroll_type, |
170 short position, | 172 short position, |
171 HWND scrollbar) { | 173 HWND scrollbar) { |
172 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); | 174 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); |
173 } | 175 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 339 } |
338 | 340 |
339 //////////////////////////////////////////////////////////////////////////////// | 341 //////////////////////////////////////////////////////////////////////////////// |
340 // NativeTabContentsView, public: | 342 // NativeTabContentsView, public: |
341 | 343 |
342 // static | 344 // static |
343 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( | 345 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( |
344 internal::NativeTabContentsViewDelegate* delegate) { | 346 internal::NativeTabContentsViewDelegate* delegate) { |
345 return new NativeTabContentsViewWin(delegate); | 347 return new NativeTabContentsViewWin(delegate); |
346 } | 348 } |
OLD | NEW |