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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 base::string16 plain_text; | 323 base::string16 plain_text; |
324 data.GetString(&plain_text); | 324 data.GetString(&plain_text); |
325 if (!plain_text.empty()) | 325 if (!plain_text.empty()) |
326 drop_data->text = base::NullableString16(plain_text, false); | 326 drop_data->text = base::NullableString16(plain_text, false); |
327 | 327 |
328 GURL url; | 328 GURL url; |
329 base::string16 url_title; | 329 base::string16 url_title; |
330 data.GetURLAndTitle( | 330 data.GetURLAndTitle( |
331 ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES, &url, &url_title); | 331 ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES, &url, &url_title); |
332 if (url.is_valid()) { | 332 if (url.is_valid()) { |
| 333 drop_data->has_url = true; |
333 drop_data->url = url; | 334 drop_data->url = url; |
334 drop_data->url_title = url_title; | 335 drop_data->url_title = url_title; |
335 } | 336 } |
336 | 337 |
337 base::string16 html; | 338 base::string16 html; |
338 GURL html_base_url; | 339 GURL html_base_url; |
339 data.GetHtml(&html, &html_base_url); | 340 data.GetHtml(&html, &html_base_url); |
340 if (!html.empty()) | 341 if (!html.empty()) |
341 drop_data->html = base::NullableString16(html, false); | 342 drop_data->html = base::NullableString16(html, false); |
342 if (html_base_url.is_valid()) | 343 if (html_base_url.is_valid()) |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 } | 1043 } |
1043 | 1044 |
1044 //////////////////////////////////////////////////////////////////////////////// | 1045 //////////////////////////////////////////////////////////////////////////////// |
1045 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1046 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
1046 | 1047 |
1047 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1048 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
1048 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1049 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
1049 current_drop_data_.reset(new DropData()); | 1050 current_drop_data_.reset(new DropData()); |
1050 | 1051 |
1051 PrepareDropData(current_drop_data_.get(), event.data()); | 1052 PrepareDropData(current_drop_data_.get(), event.data()); |
| 1053 |
| 1054 web_contents_->GetRenderViewHost()->FilterDropData(current_drop_data_.get()); |
| 1055 |
1052 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1056 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
1053 | 1057 |
1054 // Give the delegate an opportunity to cancel the drag. | 1058 // Give the delegate an opportunity to cancel the drag. |
1055 if (web_contents_->GetDelegate() && | 1059 if (web_contents_->GetDelegate() && |
1056 !web_contents_->GetDelegate()->CanDragEnter( | 1060 !web_contents_->GetDelegate()->CanDragEnter( |
1057 web_contents_, *current_drop_data_.get(), op)) { | 1061 web_contents_, *current_drop_data_.get(), op)) { |
1058 current_drop_data_.reset(NULL); | 1062 current_drop_data_.reset(NULL); |
1059 return; | 1063 return; |
1060 } | 1064 } |
1061 | 1065 |
1062 if (drag_dest_delegate_) | 1066 if (drag_dest_delegate_) |
1063 drag_dest_delegate_->DragInitialize(web_contents_); | 1067 drag_dest_delegate_->DragInitialize(web_contents_); |
1064 | 1068 |
1065 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); | 1069 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); |
1066 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 1070 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
1067 *current_drop_data_.get(), event.location(), screen_pt, op, | 1071 *current_drop_data_, event.location(), screen_pt, op, |
1068 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1072 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1069 | 1073 |
1070 if (drag_dest_delegate_) { | 1074 if (drag_dest_delegate_) { |
1071 drag_dest_delegate_->OnReceiveDragData(event.data()); | 1075 drag_dest_delegate_->OnReceiveDragData(event.data()); |
1072 drag_dest_delegate_->OnDragEnter(); | 1076 drag_dest_delegate_->OnDragEnter(); |
1073 } | 1077 } |
1074 } | 1078 } |
1075 | 1079 |
1076 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1080 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
1077 DCHECK(current_rvh_for_drag_); | 1081 DCHECK(current_rvh_for_drag_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 | 1114 |
1111 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1115 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
1112 DCHECK(current_rvh_for_drag_); | 1116 DCHECK(current_rvh_for_drag_); |
1113 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1117 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
1114 OnDragEntered(event); | 1118 OnDragEntered(event); |
1115 | 1119 |
1116 if (!current_drop_data_) | 1120 if (!current_drop_data_) |
1117 return ui::DragDropTypes::DRAG_NONE; | 1121 return ui::DragDropTypes::DRAG_NONE; |
1118 | 1122 |
1119 web_contents_->GetRenderViewHost()->DragTargetDrop( | 1123 web_contents_->GetRenderViewHost()->DragTargetDrop( |
1120 event.location(), display::Screen::GetScreen()->GetCursorScreenPoint(), | 1124 *current_drop_data_, event.location(), |
| 1125 display::Screen::GetScreen()->GetCursorScreenPoint(), |
1121 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1126 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1122 if (drag_dest_delegate_) | 1127 if (drag_dest_delegate_) |
1123 drag_dest_delegate_->OnDrop(); | 1128 drag_dest_delegate_->OnDrop(); |
1124 current_drop_data_.reset(); | 1129 current_drop_data_.reset(); |
1125 return ConvertFromWeb(current_drag_op_); | 1130 return ConvertFromWeb(current_drag_op_); |
1126 } | 1131 } |
1127 | 1132 |
1128 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1133 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
1129 bool visible) { | 1134 bool visible) { |
1130 // Ignore any visibility changes in the hierarchy below. | 1135 // Ignore any visibility changes in the hierarchy below. |
1131 if (window != window_.get() && window_->Contains(window)) | 1136 if (window != window_.get() && window_->Contains(window)) |
1132 return; | 1137 return; |
1133 | 1138 |
1134 web_contents_->UpdateWebContentsVisibility(visible); | 1139 web_contents_->UpdateWebContentsVisibility(visible); |
1135 } | 1140 } |
1136 | 1141 |
1137 } // namespace content | 1142 } // namespace content |
OLD | NEW |