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_aura.h" | 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.h" |
6 | 6 |
7 #include "base/event_types.h" | 7 #include "base/event_types.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_aura.h" | |
9 #include "chrome/browser/ui/sad_tab_helper.h" | 10 #include "chrome/browser/ui/sad_tab_helper.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
11 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate .h" | 12 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate .h" |
12 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_view.h" | 16 #include "content/public/browser/web_contents_view.h" |
16 #include "ui/aura/client/drag_drop_client.h" | 17 #include "ui/aura/client/drag_drop_client.h" |
17 #include "ui/aura/client/drag_drop_delegate.h" | 18 #include "ui/aura/client/drag_drop_delegate.h" |
18 #include "ui/aura/event.h" | 19 #include "ui/aura/event.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 NOTIMPLEMENTED() << "Need to animate in"; | 173 NOTIMPLEMENTED() << "Need to animate in"; |
173 #endif | 174 #endif |
174 | 175 |
175 // Hide the widget to prevent it from showing up on the root window. This is | 176 // Hide the widget to prevent it from showing up on the root window. This is |
176 // needed for TabContentses that aren't immediately added to the tabstrip, | 177 // needed for TabContentses that aren't immediately added to the tabstrip, |
177 // e.g. the Instant preview contents. | 178 // e.g. the Instant preview contents. |
178 // TODO(beng): investigate if control-type windows shouldn't be hidden by | 179 // TODO(beng): investigate if control-type windows shouldn't be hidden by |
179 // default if they are created with no parent. Pending oshima's | 180 // default if they are created with no parent. Pending oshima's |
180 // change to reflect Widget types onto a ViewProp. | 181 // change to reflect Widget types onto a ViewProp. |
181 GetWidget()->Hide(); | 182 GetWidget()->Hide(); |
183 | |
184 bookmark_handler_.reset(new WebDragBookmarkHandlerAura()); | |
Ben Goodger (Google)
2012/03/20 17:25:54
hrm. tying the bookmark stuff into here is going t
varunjain
2012/03/20 18:19:16
On other platforms, bookmark handling is hooked to
| |
182 } | 185 } |
183 | 186 |
184 RenderWidgetHostView* NativeTabContentsViewAura::CreateRenderWidgetHostView( | 187 RenderWidgetHostView* NativeTabContentsViewAura::CreateRenderWidgetHostView( |
185 content::RenderWidgetHost* render_widget_host) { | 188 content::RenderWidgetHost* render_widget_host) { |
186 RenderWidgetHostView* view = | 189 RenderWidgetHostView* view = |
187 RenderWidgetHostView::CreateViewForWidget(render_widget_host); | 190 RenderWidgetHostView::CreateViewForWidget(render_widget_host); |
188 | 191 |
189 view->InitAsChild(NULL); | 192 view->InitAsChild(NULL); |
190 GetNativeView()->AddChild(view->GetNativeView()); | 193 GetNativeView()->AddChild(view->GetNativeView()); |
191 view->Show(); | 194 view->Show(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // TODO(oshima): mouse wheel | 289 // TODO(oshima): mouse wheel |
287 break; | 290 break; |
288 } | 291 } |
289 } | 292 } |
290 // Pass all mouse event to renderer. | 293 // Pass all mouse event to renderer. |
291 return views::NativeWidgetAura::OnMouseEvent(event); | 294 return views::NativeWidgetAura::OnMouseEvent(event); |
292 } | 295 } |
293 | 296 |
294 void NativeTabContentsViewAura::OnDragEntered( | 297 void NativeTabContentsViewAura::OnDragEntered( |
295 const aura::DropTargetEvent& event) { | 298 const aura::DropTargetEvent& event) { |
299 bookmark_handler_->DragInitialize(GetWebContents()); | |
300 | |
296 WebDropData drop_data; | 301 WebDropData drop_data; |
297 PrepareWebDropData(&drop_data, event.data()); | 302 PrepareWebDropData(&drop_data, event.data()); |
298 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 303 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
299 | 304 |
300 gfx::Point screen_pt = | 305 gfx::Point screen_pt = |
301 GetNativeView()->GetRootWindow()->last_mouse_location(); | 306 GetNativeView()->GetRootWindow()->last_mouse_location(); |
302 GetWebContents()->GetRenderViewHost()->DragTargetDragEnter( | 307 GetWebContents()->GetRenderViewHost()->DragTargetDragEnter( |
303 drop_data, event.location(), screen_pt, op); | 308 drop_data, event.location(), screen_pt, op); |
309 | |
310 bookmark_handler_->OnDragEnter(event.data()); | |
304 } | 311 } |
305 | 312 |
306 int NativeTabContentsViewAura::OnDragUpdated( | 313 int NativeTabContentsViewAura::OnDragUpdated( |
307 const aura::DropTargetEvent& event) { | 314 const aura::DropTargetEvent& event) { |
308 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 315 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
309 gfx::Point screen_pt = | 316 gfx::Point screen_pt = |
310 GetNativeView()->GetRootWindow()->last_mouse_location(); | 317 GetNativeView()->GetRootWindow()->last_mouse_location(); |
311 GetWebContents()->GetRenderViewHost()->DragTargetDragOver( | 318 GetWebContents()->GetRenderViewHost()->DragTargetDragOver( |
312 event.location(), screen_pt, op); | 319 event.location(), screen_pt, op); |
320 | |
321 bookmark_handler_->OnDragOver(); | |
322 | |
313 return ConvertFromWeb(current_drag_op_); | 323 return ConvertFromWeb(current_drag_op_); |
314 } | 324 } |
315 | 325 |
316 void NativeTabContentsViewAura::OnDragExited() { | 326 void NativeTabContentsViewAura::OnDragExited() { |
317 GetWebContents()->GetRenderViewHost()->DragTargetDragLeave(); | 327 GetWebContents()->GetRenderViewHost()->DragTargetDragLeave(); |
328 bookmark_handler_->OnDragLeave(); | |
318 } | 329 } |
319 | 330 |
320 int NativeTabContentsViewAura::OnPerformDrop( | 331 int NativeTabContentsViewAura::OnPerformDrop( |
321 const aura::DropTargetEvent& event) { | 332 const aura::DropTargetEvent& event) { |
322 GetWebContents()->GetRenderViewHost()->DragTargetDrop( | 333 GetWebContents()->GetRenderViewHost()->DragTargetDrop( |
323 event.location(), | 334 event.location(), |
324 GetNativeView()->GetRootWindow()->last_mouse_location()); | 335 GetNativeView()->GetRootWindow()->last_mouse_location()); |
336 bookmark_handler_->OnDrop(); | |
325 return current_drag_op_; | 337 return current_drag_op_; |
326 } | 338 } |
327 | 339 |
328 //////////////////////////////////////////////////////////////////////////////// | 340 //////////////////////////////////////////////////////////////////////////////// |
329 // NativeTabContentsViewAura, private: | 341 // NativeTabContentsViewAura, private: |
330 | 342 |
331 void NativeTabContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { | 343 void NativeTabContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { |
332 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); | 344 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); |
333 gfx::Point screen_loc = root_window->last_mouse_location(); | 345 gfx::Point screen_loc = root_window->last_mouse_location(); |
334 gfx::Point client_loc = screen_loc; | 346 gfx::Point client_loc = screen_loc; |
335 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); | 347 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); |
336 aura::Window* window = rvh->GetView()->GetNativeView(); | 348 aura::Window* window = rvh->GetView()->GetNativeView(); |
337 aura::Window::ConvertPointToWindow(root_window, window, &client_loc); | 349 aura::Window::ConvertPointToWindow(root_window, window, &client_loc); |
338 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), | 350 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), |
339 screen_loc.y(), ops); | 351 screen_loc.y(), ops); |
340 } | 352 } |
341 | 353 |
342 //////////////////////////////////////////////////////////////////////////////// | 354 //////////////////////////////////////////////////////////////////////////////// |
343 // NativeTabContentsView, public: | 355 // NativeTabContentsView, public: |
344 | 356 |
345 // static | 357 // static |
346 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( | 358 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( |
347 internal::NativeTabContentsViewDelegate* delegate) { | 359 internal::NativeTabContentsViewDelegate* delegate) { |
348 return new NativeTabContentsViewAura(delegate); | 360 return new NativeTabContentsViewAura(delegate); |
349 } | 361 } |
OLD | NEW |