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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); | 327 UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 Pickle pickle; | 331 Pickle pickle; |
332 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) | 332 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) |
333 ui::ReadCustomDataIntoMap( | 333 ui::ReadCustomDataIntoMap( |
334 pickle.data(), pickle.size(), &drop_data->custom_data); | 334 pickle.data(), pickle.size(), &drop_data->custom_data); |
335 } | 335 } |
336 | 336 |
337 // Utilities to convert between WebKit::WebDragOperationsMask and | 337 // Utilities to convert between blink::WebDragOperationsMask and |
338 // ui::DragDropTypes. | 338 // ui::DragDropTypes. |
339 int ConvertFromWeb(WebKit::WebDragOperationsMask ops) { | 339 int ConvertFromWeb(blink::WebDragOperationsMask ops) { |
340 int drag_op = ui::DragDropTypes::DRAG_NONE; | 340 int drag_op = ui::DragDropTypes::DRAG_NONE; |
341 if (ops & WebKit::WebDragOperationCopy) | 341 if (ops & blink::WebDragOperationCopy) |
342 drag_op |= ui::DragDropTypes::DRAG_COPY; | 342 drag_op |= ui::DragDropTypes::DRAG_COPY; |
343 if (ops & WebKit::WebDragOperationMove) | 343 if (ops & blink::WebDragOperationMove) |
344 drag_op |= ui::DragDropTypes::DRAG_MOVE; | 344 drag_op |= ui::DragDropTypes::DRAG_MOVE; |
345 if (ops & WebKit::WebDragOperationLink) | 345 if (ops & blink::WebDragOperationLink) |
346 drag_op |= ui::DragDropTypes::DRAG_LINK; | 346 drag_op |= ui::DragDropTypes::DRAG_LINK; |
347 return drag_op; | 347 return drag_op; |
348 } | 348 } |
349 | 349 |
350 WebKit::WebDragOperationsMask ConvertToWeb(int drag_op) { | 350 blink::WebDragOperationsMask ConvertToWeb(int drag_op) { |
351 int web_drag_op = WebKit::WebDragOperationNone; | 351 int web_drag_op = blink::WebDragOperationNone; |
352 if (drag_op & ui::DragDropTypes::DRAG_COPY) | 352 if (drag_op & ui::DragDropTypes::DRAG_COPY) |
353 web_drag_op |= WebKit::WebDragOperationCopy; | 353 web_drag_op |= blink::WebDragOperationCopy; |
354 if (drag_op & ui::DragDropTypes::DRAG_MOVE) | 354 if (drag_op & ui::DragDropTypes::DRAG_MOVE) |
355 web_drag_op |= WebKit::WebDragOperationMove; | 355 web_drag_op |= blink::WebDragOperationMove; |
356 if (drag_op & ui::DragDropTypes::DRAG_LINK) | 356 if (drag_op & ui::DragDropTypes::DRAG_LINK) |
357 web_drag_op |= WebKit::WebDragOperationLink; | 357 web_drag_op |= blink::WebDragOperationLink; |
358 return (WebKit::WebDragOperationsMask) web_drag_op; | 358 return (blink::WebDragOperationsMask) web_drag_op; |
359 } | 359 } |
360 | 360 |
361 int ConvertAuraEventFlagsToWebInputEventModifiers(int aura_event_flags) { | 361 int ConvertAuraEventFlagsToWebInputEventModifiers(int aura_event_flags) { |
362 int web_input_event_modifiers = 0; | 362 int web_input_event_modifiers = 0; |
363 if (aura_event_flags & ui::EF_SHIFT_DOWN) | 363 if (aura_event_flags & ui::EF_SHIFT_DOWN) |
364 web_input_event_modifiers |= WebKit::WebInputEvent::ShiftKey; | 364 web_input_event_modifiers |= blink::WebInputEvent::ShiftKey; |
365 if (aura_event_flags & ui::EF_CONTROL_DOWN) | 365 if (aura_event_flags & ui::EF_CONTROL_DOWN) |
366 web_input_event_modifiers |= WebKit::WebInputEvent::ControlKey; | 366 web_input_event_modifiers |= blink::WebInputEvent::ControlKey; |
367 if (aura_event_flags & ui::EF_ALT_DOWN) | 367 if (aura_event_flags & ui::EF_ALT_DOWN) |
368 web_input_event_modifiers |= WebKit::WebInputEvent::AltKey; | 368 web_input_event_modifiers |= blink::WebInputEvent::AltKey; |
369 if (aura_event_flags & ui::EF_COMMAND_DOWN) | 369 if (aura_event_flags & ui::EF_COMMAND_DOWN) |
370 web_input_event_modifiers |= WebKit::WebInputEvent::MetaKey; | 370 web_input_event_modifiers |= blink::WebInputEvent::MetaKey; |
371 return web_input_event_modifiers; | 371 return web_input_event_modifiers; |
372 } | 372 } |
373 | 373 |
374 // A LayerDelegate that paints an image for the layer. | 374 // A LayerDelegate that paints an image for the layer. |
375 class ImageLayerDelegate : public ui::LayerDelegate { | 375 class ImageLayerDelegate : public ui::LayerDelegate { |
376 public: | 376 public: |
377 ImageLayerDelegate() {} | 377 ImageLayerDelegate() {} |
378 | 378 |
379 virtual ~ImageLayerDelegate() {} | 379 virtual ~ImageLayerDelegate() {} |
380 | 380 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 #endif | 812 #endif |
813 | 813 |
814 //////////////////////////////////////////////////////////////////////////////// | 814 //////////////////////////////////////////////////////////////////////////////// |
815 // WebContentsViewAura, public: | 815 // WebContentsViewAura, public: |
816 | 816 |
817 WebContentsViewAura::WebContentsViewAura( | 817 WebContentsViewAura::WebContentsViewAura( |
818 WebContentsImpl* web_contents, | 818 WebContentsImpl* web_contents, |
819 WebContentsViewDelegate* delegate) | 819 WebContentsViewDelegate* delegate) |
820 : web_contents_(web_contents), | 820 : web_contents_(web_contents), |
821 delegate_(delegate), | 821 delegate_(delegate), |
822 current_drag_op_(WebKit::WebDragOperationNone), | 822 current_drag_op_(blink::WebDragOperationNone), |
823 drag_dest_delegate_(NULL), | 823 drag_dest_delegate_(NULL), |
824 current_rvh_for_drag_(NULL), | 824 current_rvh_for_drag_(NULL), |
825 overscroll_change_brightness_(false), | 825 overscroll_change_brightness_(false), |
826 current_overscroll_gesture_(OVERSCROLL_NONE), | 826 current_overscroll_gesture_(OVERSCROLL_NONE), |
827 completed_overscroll_gesture_(OVERSCROLL_NONE), | 827 completed_overscroll_gesture_(OVERSCROLL_NONE), |
828 touch_editable_(TouchEditableImplAura::Create()) { | 828 touch_editable_(TouchEditableImplAura::Create()) { |
829 } | 829 } |
830 | 830 |
831 //////////////////////////////////////////////////////////////////////////////// | 831 //////////////////////////////////////////////////////////////////////////////// |
832 // WebContentsViewAura, private: | 832 // WebContentsViewAura, private: |
(...skipping 24 matching lines...) Expand all Loading... |
857 | 857 |
858 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { | 858 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { |
859 if (web_contents_->GetInterstitialPage()) | 859 if (web_contents_->GetInterstitialPage()) |
860 web_contents_->GetInterstitialPage()->SetSize(size); | 860 web_contents_->GetInterstitialPage()->SetSize(size); |
861 RenderWidgetHostView* rwhv = | 861 RenderWidgetHostView* rwhv = |
862 web_contents_->GetRenderWidgetHostView(); | 862 web_contents_->GetRenderWidgetHostView(); |
863 if (rwhv) | 863 if (rwhv) |
864 rwhv->SetSize(size); | 864 rwhv->SetSize(size); |
865 } | 865 } |
866 | 866 |
867 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { | 867 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { |
868 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 868 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
869 gfx::Point screen_loc = | 869 gfx::Point screen_loc = |
870 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 870 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
871 gfx::Point client_loc = screen_loc; | 871 gfx::Point client_loc = screen_loc; |
872 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 872 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
873 aura::Window* window = rvh->GetView()->GetNativeView(); | 873 aura::Window* window = rvh->GetView()->GetNativeView(); |
874 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); | 874 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); |
875 if (!web_contents_) | 875 if (!web_contents_) |
876 return; | 876 return; |
877 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 877 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 int selected_item, | 1275 int selected_item, |
1276 const std::vector<MenuItem>& items, | 1276 const std::vector<MenuItem>& items, |
1277 bool right_aligned, | 1277 bool right_aligned, |
1278 bool allow_multiple_selection) { | 1278 bool allow_multiple_selection) { |
1279 // External popup menus are only used on Mac and Android. | 1279 // External popup menus are only used on Mac and Android. |
1280 NOTIMPLEMENTED(); | 1280 NOTIMPLEMENTED(); |
1281 } | 1281 } |
1282 | 1282 |
1283 void WebContentsViewAura::StartDragging( | 1283 void WebContentsViewAura::StartDragging( |
1284 const DropData& drop_data, | 1284 const DropData& drop_data, |
1285 WebKit::WebDragOperationsMask operations, | 1285 blink::WebDragOperationsMask operations, |
1286 const gfx::ImageSkia& image, | 1286 const gfx::ImageSkia& image, |
1287 const gfx::Vector2d& image_offset, | 1287 const gfx::Vector2d& image_offset, |
1288 const DragEventSourceInfo& event_info) { | 1288 const DragEventSourceInfo& event_info) { |
1289 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 1289 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
1290 if (!aura::client::GetDragDropClient(root_window)) { | 1290 if (!aura::client::GetDragDropClient(root_window)) { |
1291 web_contents_->SystemDragEnded(); | 1291 web_contents_->SystemDragEnded(); |
1292 return; | 1292 return; |
1293 } | 1293 } |
1294 | 1294 |
1295 if (touch_editable_) | 1295 if (touch_editable_) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 if (!drag_source->window()) { | 1331 if (!drag_source->window()) { |
1332 // Note that in this case, we don't need to call SystemDragEnded() since the | 1332 // Note that in this case, we don't need to call SystemDragEnded() since the |
1333 // renderer is going away. | 1333 // renderer is going away. |
1334 return; | 1334 return; |
1335 } | 1335 } |
1336 | 1336 |
1337 EndDrag(ConvertToWeb(result_op)); | 1337 EndDrag(ConvertToWeb(result_op)); |
1338 web_contents_->SystemDragEnded(); | 1338 web_contents_->SystemDragEnded(); |
1339 } | 1339 } |
1340 | 1340 |
1341 void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) { | 1341 void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) { |
1342 current_drag_op_ = operation; | 1342 current_drag_op_ = operation; |
1343 } | 1343 } |
1344 | 1344 |
1345 void WebContentsViewAura::GotFocus() { | 1345 void WebContentsViewAura::GotFocus() { |
1346 if (web_contents_->GetDelegate()) | 1346 if (web_contents_->GetDelegate()) |
1347 web_contents_->GetDelegate()->WebContentsFocused(web_contents_); | 1347 web_contents_->GetDelegate()->WebContentsFocused(web_contents_); |
1348 } | 1348 } |
1349 | 1349 |
1350 void WebContentsViewAura::TakeFocus(bool reverse) { | 1350 void WebContentsViewAura::TakeFocus(bool reverse) { |
1351 if (web_contents_->GetDelegate() && | 1351 if (web_contents_->GetDelegate() && |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 //////////////////////////////////////////////////////////////////////////////// | 1589 //////////////////////////////////////////////////////////////////////////////// |
1590 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1590 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
1591 | 1591 |
1592 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1592 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
1593 if (drag_dest_delegate_) | 1593 if (drag_dest_delegate_) |
1594 drag_dest_delegate_->DragInitialize(web_contents_); | 1594 drag_dest_delegate_->DragInitialize(web_contents_); |
1595 | 1595 |
1596 current_drop_data_.reset(new DropData()); | 1596 current_drop_data_.reset(new DropData()); |
1597 | 1597 |
1598 PrepareDropData(current_drop_data_.get(), event.data()); | 1598 PrepareDropData(current_drop_data_.get(), event.data()); |
1599 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1599 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
1600 | 1600 |
1601 gfx::Point screen_pt = | 1601 gfx::Point screen_pt = |
1602 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 1602 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
1603 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1603 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
1604 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 1604 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
1605 *current_drop_data_.get(), event.location(), screen_pt, op, | 1605 *current_drop_data_.get(), event.location(), screen_pt, op, |
1606 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1606 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1607 | 1607 |
1608 if (drag_dest_delegate_) { | 1608 if (drag_dest_delegate_) { |
1609 drag_dest_delegate_->OnReceiveDragData(event.data()); | 1609 drag_dest_delegate_->OnReceiveDragData(event.data()); |
1610 drag_dest_delegate_->OnDragEnter(); | 1610 drag_dest_delegate_->OnDragEnter(); |
1611 } | 1611 } |
1612 } | 1612 } |
1613 | 1613 |
1614 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1614 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
1615 DCHECK(current_rvh_for_drag_); | 1615 DCHECK(current_rvh_for_drag_); |
1616 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1616 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
1617 OnDragEntered(event); | 1617 OnDragEntered(event); |
1618 | 1618 |
1619 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1619 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
1620 gfx::Point screen_pt = | 1620 gfx::Point screen_pt = |
1621 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 1621 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
1622 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 1622 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
1623 event.location(), screen_pt, op, | 1623 event.location(), screen_pt, op, |
1624 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1624 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1625 | 1625 |
1626 if (drag_dest_delegate_) | 1626 if (drag_dest_delegate_) |
1627 drag_dest_delegate_->OnDragOver(); | 1627 drag_dest_delegate_->OnDragOver(); |
1628 | 1628 |
1629 return ConvertFromWeb(current_drag_op_); | 1629 return ConvertFromWeb(current_drag_op_); |
(...skipping 20 matching lines...) Expand all Loading... |
1650 event.location(), | 1650 event.location(), |
1651 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1651 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1652 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1652 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1653 if (drag_dest_delegate_) | 1653 if (drag_dest_delegate_) |
1654 drag_dest_delegate_->OnDrop(); | 1654 drag_dest_delegate_->OnDrop(); |
1655 current_drop_data_.reset(); | 1655 current_drop_data_.reset(); |
1656 return current_drag_op_; | 1656 return current_drag_op_; |
1657 } | 1657 } |
1658 | 1658 |
1659 } // namespace content | 1659 } // namespace content |
OLD | NEW |