Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc

Issue 818983002: Revert of Fix crash when the source browser window is deleted during a drag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@drag_drop_end_move_loop2
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h"
6 6
7 #include "base/tracked_objects.h" 7 #include "base/tracked_objects.h"
8 #include "ui/base/dragdrop/drag_drop_types.h" 8 #include "ui/base/dragdrop/drag_drop_types.h"
9 #include "ui/base/dragdrop/drag_source_win.h" 9 #include "ui/base/dragdrop/drag_source_win.h"
10 #include "ui/base/dragdrop/drop_target_event.h" 10 #include "ui/base/dragdrop/drop_target_event.h"
11 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" 11 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
12 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" 12 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h"
13 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" 13 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 DesktopDragDropClientWin::DesktopDragDropClientWin( 17 DesktopDragDropClientWin::DesktopDragDropClientWin(
18 aura::Window* root_window, 18 aura::Window* root_window,
19 HWND window) 19 HWND window)
20 : drag_drop_in_progress_(false), 20 : drag_drop_in_progress_(false),
21 drag_operation_(0), 21 drag_operation_(0) {
22 weak_factory_(this) {
23 drop_target_ = new DesktopDropTargetWin(root_window, window); 22 drop_target_ = new DesktopDropTargetWin(root_window, window);
24 } 23 }
25 24
26 DesktopDragDropClientWin::~DesktopDragDropClientWin() { 25 DesktopDragDropClientWin::~DesktopDragDropClientWin() {
27 if (drag_drop_in_progress_)
28 DragCancel();
29 } 26 }
30 27
31 int DesktopDragDropClientWin::StartDragAndDrop( 28 int DesktopDragDropClientWin::StartDragAndDrop(
32 const ui::OSExchangeData& data, 29 const ui::OSExchangeData& data,
33 aura::Window* root_window, 30 aura::Window* root_window,
34 aura::Window* source_window, 31 aura::Window* source_window,
35 const gfx::Point& root_location, 32 const gfx::Point& root_location,
36 int operation, 33 int operation,
37 ui::DragDropTypes::DragEventSource source) { 34 ui::DragDropTypes::DragEventSource source) {
38 drag_drop_in_progress_ = true; 35 drag_drop_in_progress_ = true;
39 drag_operation_ = operation; 36 drag_operation_ = operation;
40 37
41 base::WeakPtr<DesktopDragDropClientWin> alive(weak_factory_.GetWeakPtr());
42
43 drag_source_ = new ui::DragSourceWin; 38 drag_source_ = new ui::DragSourceWin;
44 scoped_refptr<ui::DragSourceWin> drag_source_copy = drag_source_;
45
46 DWORD effect; 39 DWORD effect;
47 40
48 // Use task stopwatch to exclude the drag-drop time current task, if any. 41 // Use task stopwatch to exclude the drag-drop time current task, if any.
49 tracked_objects::TaskStopwatch stopwatch; 42 tracked_objects::TaskStopwatch stopwatch;
50 stopwatch.Start(); 43 stopwatch.Start();
51 HRESULT result = DoDragDrop( 44 HRESULT result = DoDragDrop(
52 ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(), 45 ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(),
53 ui::DragDropTypes::DragOperationToDropEffect(operation), &effect); 46 ui::DragDropTypes::DragOperationToDropEffect(operation), &effect);
54 stopwatch.Stop(); 47 stopwatch.Stop();
55 48
56 if (alive) 49 drag_drop_in_progress_ = false;
57 drag_drop_in_progress_ = false;
58 50
59 if (result != DRAGDROP_S_DROP) 51 if (result != DRAGDROP_S_DROP)
60 effect = DROPEFFECT_NONE; 52 effect = DROPEFFECT_NONE;
61 53
62 return ui::DragDropTypes::DropEffectToDragOperation(effect); 54 return ui::DragDropTypes::DropEffectToDragOperation(effect);
63 } 55 }
64 56
65 void DesktopDragDropClientWin::DragUpdate(aura::Window* target, 57 void DesktopDragDropClientWin::DragUpdate(aura::Window* target,
66 const ui::LocatedEvent& event) { 58 const ui::LocatedEvent& event) {
67 } 59 }
(...skipping 12 matching lines...) Expand all
80 } 72 }
81 73
82 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) { 74 void DesktopDragDropClientWin::OnNativeWidgetDestroying(HWND window) {
83 if (drop_target_.get()) { 75 if (drop_target_.get()) {
84 RevokeDragDrop(window); 76 RevokeDragDrop(window);
85 drop_target_ = NULL; 77 drop_target_ = NULL;
86 } 78 }
87 } 79 }
88 80
89 } // namespace views 81 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698