| 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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 for (const auto& custom_data_item : drop_data.custom_data) { | 235 for (const auto& custom_data_item : drop_data.custom_data) { |
| 236 metadata.push_back(DropData::Metadata::CreateForMimeType( | 236 metadata.push_back(DropData::Metadata::CreateForMimeType( |
| 237 DropData::Kind::STRING, custom_data_item.first)); | 237 DropData::Kind::STRING, custom_data_item.first)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 return metadata; | 240 return metadata; |
| 241 } | 241 } |
| 242 | 242 |
| 243 base::LazyInstance<RenderWidgetHostImpl::DragStartCallback>::Leaky |
| 244 g_drag_start_callback_for_testing = LAZY_INSTANCE_INITIALIZER; |
| 245 |
| 243 } // namespace | 246 } // namespace |
| 244 | 247 |
| 245 /////////////////////////////////////////////////////////////////////////////// | 248 /////////////////////////////////////////////////////////////////////////////// |
| 246 // RenderWidgetHostImpl | 249 // RenderWidgetHostImpl |
| 247 | 250 |
| 248 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 251 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| 249 RenderProcessHost* process, | 252 RenderProcessHost* process, |
| 250 int32_t routing_id, | 253 int32_t routing_id, |
| 251 bool hidden) | 254 bool hidden) |
| 252 : renderer_initialized_(false), | 255 : renderer_initialized_(false), |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 if (delegate_) | 1498 if (delegate_) |
| 1496 delegate_->FocusedNodeTouched(editable); | 1499 delegate_->FocusedNodeTouched(editable); |
| 1497 } | 1500 } |
| 1498 | 1501 |
| 1499 void RenderWidgetHostImpl::OnStartDragging( | 1502 void RenderWidgetHostImpl::OnStartDragging( |
| 1500 const DropData& drop_data, | 1503 const DropData& drop_data, |
| 1501 blink::WebDragOperationsMask drag_operations_mask, | 1504 blink::WebDragOperationsMask drag_operations_mask, |
| 1502 const SkBitmap& bitmap, | 1505 const SkBitmap& bitmap, |
| 1503 const gfx::Vector2d& bitmap_offset_in_dip, | 1506 const gfx::Vector2d& bitmap_offset_in_dip, |
| 1504 const DragEventSourceInfo& event_info) { | 1507 const DragEventSourceInfo& event_info) { |
| 1508 bool drag_start_handled_by_test = false; |
| 1509 if (!g_drag_start_callback_for_testing.Get().is_null()) { |
| 1510 drag_start_handled_by_test = g_drag_start_callback_for_testing.Get().Run( |
| 1511 drop_data, drag_operations_mask); |
| 1512 } |
| 1513 |
| 1505 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); | 1514 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); |
| 1506 if (!view) { | 1515 if (!view || drag_start_handled_by_test) { |
| 1507 // Need to clear drag and drop state in blink. | 1516 // Need to clear drag and drop state in blink. |
| 1508 DragSourceSystemDragEnded(); | 1517 DragSourceSystemDragEnded(); |
| 1509 return; | 1518 return; |
| 1510 } | 1519 } |
| 1511 | 1520 |
| 1512 DropData filtered_data(drop_data); | 1521 DropData filtered_data(drop_data); |
| 1513 RenderProcessHost* process = GetProcess(); | 1522 RenderProcessHost* process = GetProcess(); |
| 1514 ChildProcessSecurityPolicyImpl* policy = | 1523 ChildProcessSecurityPolicyImpl* policy = |
| 1515 ChildProcessSecurityPolicyImpl::GetInstance(); | 1524 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 1516 | 1525 |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 // Note: We are using the origin URL provided by the sender here. It may be | 2532 // Note: We are using the origin URL provided by the sender here. It may be |
| 2524 // different from the receiver's. | 2533 // different from the receiver's. |
| 2525 file_system_file.url = | 2534 file_system_file.url = |
| 2526 GURL(storage::GetIsolatedFileSystemRootURIString( | 2535 GURL(storage::GetIsolatedFileSystemRootURIString( |
| 2527 file_system_url.origin(), filesystem_id, std::string()) | 2536 file_system_url.origin(), filesystem_id, std::string()) |
| 2528 .append(register_name)); | 2537 .append(register_name)); |
| 2529 file_system_file.filesystem_id = filesystem_id; | 2538 file_system_file.filesystem_id = filesystem_id; |
| 2530 } | 2539 } |
| 2531 } | 2540 } |
| 2532 | 2541 |
| 2542 // static |
| 2543 void RenderWidgetHostImpl::RegisterDragStartCallbackForTesting( |
| 2544 DragStartCallback callback) { |
| 2545 // Prevent attempts to register more than one callback. |
| 2546 DCHECK(callback.is_null() || |
| 2547 g_drag_start_callback_for_testing.Get().is_null()); |
| 2548 |
| 2549 g_drag_start_callback_for_testing.Get() = std::move(callback); |
| 2550 } |
| 2551 |
| 2533 } // namespace content | 2552 } // namespace content |
| OLD | NEW |