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

Side by Side Diff: base/base_drop_target.cc

Issue 351029: Support dragging a virtual file out of the browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « base/base_drop_target.h ('k') | base/file_util.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/base_drop_target.h" 5 #include "base/base_drop_target.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 /////////////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////////////
12 12
13 IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL; 13 IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL;
14 int32 BaseDropTarget::drag_identity_ = 0; 14 int32 BaseDropTarget::drag_identity_ = 0;
15 15
16 BaseDropTarget::BaseDropTarget(HWND hwnd) 16 BaseDropTarget::BaseDropTarget(HWND hwnd)
17 : hwnd_(hwnd), 17 : hwnd_(hwnd),
18 suspend_(false), 18 suspended_(false),
19 ref_count_(0) { 19 ref_count_(0) {
20 DCHECK(hwnd); 20 DCHECK(hwnd);
21 HRESULT result = RegisterDragDrop(hwnd, this); 21 HRESULT result = RegisterDragDrop(hwnd, this);
22 DCHECK(SUCCEEDED(result)); 22 DCHECK(SUCCEEDED(result));
23 } 23 }
24 24
25 BaseDropTarget::~BaseDropTarget() { 25 BaseDropTarget::~BaseDropTarget() {
26 } 26 }
27 27
28 // static 28 // static
(...skipping 14 matching lines...) Expand all
43 POINTL cursor_position, 43 POINTL cursor_position,
44 DWORD* effect) { 44 DWORD* effect) {
45 // Tell the helper that we entered so it can update the drag image. 45 // Tell the helper that we entered so it can update the drag image.
46 IDropTargetHelper* drop_helper = DropHelper(); 46 IDropTargetHelper* drop_helper = DropHelper();
47 if (drop_helper) { 47 if (drop_helper) {
48 drop_helper->DragEnter(GetHWND(), data_object, 48 drop_helper->DragEnter(GetHWND(), data_object,
49 reinterpret_cast<POINT*>(&cursor_position), *effect); 49 reinterpret_cast<POINT*>(&cursor_position), *effect);
50 } 50 }
51 51
52 // You can't drag and drop within the same HWND. 52 // You can't drag and drop within the same HWND.
53 if (suspend_) { 53 if (suspended_) {
54 *effect = DROPEFFECT_NONE; 54 *effect = DROPEFFECT_NONE;
55 return S_OK; 55 return S_OK;
56 } 56 }
57 57
58 // Update the drag identity, skipping 0. 58 // Update the drag identity, skipping 0.
59 if (++drag_identity_ == 0) 59 if (++drag_identity_ == 0)
60 ++drag_identity_; 60 ++drag_identity_;
61 61
62 current_data_object_ = data_object; 62 current_data_object_ = data_object;
63 POINT screen_pt = { cursor_position.x, cursor_position.y }; 63 POINT screen_pt = { cursor_position.x, cursor_position.y };
64 *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect); 64 *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect);
65 return S_OK; 65 return S_OK;
66 } 66 }
67 67
68 HRESULT BaseDropTarget::DragOver(DWORD key_state, 68 HRESULT BaseDropTarget::DragOver(DWORD key_state,
69 POINTL cursor_position, 69 POINTL cursor_position,
70 DWORD* effect) { 70 DWORD* effect) {
71 // Tell the helper that we moved over it so it can update the drag image. 71 // Tell the helper that we moved over it so it can update the drag image.
72 IDropTargetHelper* drop_helper = DropHelper(); 72 IDropTargetHelper* drop_helper = DropHelper();
73 if (drop_helper) 73 if (drop_helper)
74 drop_helper->DragOver(reinterpret_cast<POINT*>(&cursor_position), *effect); 74 drop_helper->DragOver(reinterpret_cast<POINT*>(&cursor_position), *effect);
75 75
76 if (suspend_) { 76 if (suspended_) {
77 *effect = DROPEFFECT_NONE; 77 *effect = DROPEFFECT_NONE;
78 return S_OK; 78 return S_OK;
79 } 79 }
80 80
81 POINT screen_pt = { cursor_position.x, cursor_position.y }; 81 POINT screen_pt = { cursor_position.x, cursor_position.y };
82 *effect = OnDragOver(current_data_object_, key_state, screen_pt, *effect); 82 *effect = OnDragOver(current_data_object_, key_state, screen_pt, *effect);
83 return S_OK; 83 return S_OK;
84 } 84 }
85 85
86 HRESULT BaseDropTarget::DragLeave() { 86 HRESULT BaseDropTarget::DragLeave() {
87 // Tell the helper that we moved out of it so it can update the drag image. 87 // Tell the helper that we moved out of it so it can update the drag image.
88 IDropTargetHelper* drop_helper = DropHelper(); 88 IDropTargetHelper* drop_helper = DropHelper();
89 if (drop_helper) 89 if (drop_helper)
90 drop_helper->DragLeave(); 90 drop_helper->DragLeave();
91 91
92 if (suspended_)
93 return S_OK;
94
92 OnDragLeave(current_data_object_); 95 OnDragLeave(current_data_object_);
93 96
94 current_data_object_ = NULL; 97 current_data_object_ = NULL;
95 return S_OK; 98 return S_OK;
96 } 99 }
97 100
98 HRESULT BaseDropTarget::Drop(IDataObject* data_object, 101 HRESULT BaseDropTarget::Drop(IDataObject* data_object,
99 DWORD key_state, 102 DWORD key_state,
100 POINTL cursor_position, 103 POINTL cursor_position,
101 DWORD* effect) { 104 DWORD* effect) {
102 // Tell the helper that we dropped onto it so it can update the drag image. 105 // Tell the helper that we dropped onto it so it can update the drag image.
103 IDropTargetHelper* drop_helper = DropHelper(); 106 IDropTargetHelper* drop_helper = DropHelper();
104 if (drop_helper) { 107 if (drop_helper) {
105 drop_helper->Drop(current_data_object_, 108 drop_helper->Drop(current_data_object_,
106 reinterpret_cast<POINT*>(&cursor_position), *effect); 109 reinterpret_cast<POINT*>(&cursor_position), *effect);
107 } 110 }
108 111
109 if (suspend_) { 112 if (suspended_) {
110 *effect = DROPEFFECT_NONE; 113 *effect = DROPEFFECT_NONE;
111 return S_OK; 114 return S_OK;
112 } 115 }
113 116
114 POINT screen_pt = { cursor_position.x, cursor_position.y }; 117 POINT screen_pt = { cursor_position.x, cursor_position.y };
115 *effect = OnDrop(current_data_object_, key_state, screen_pt, *effect); 118 *effect = OnDrop(current_data_object_, key_state, screen_pt, *effect);
116 return S_OK; 119 return S_OK;
117 } 120 }
118 121
119 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 161
159 void BaseDropTarget::OnDragLeave(IDataObject* data_object) { 162 void BaseDropTarget::OnDragLeave(IDataObject* data_object) {
160 } 163 }
161 164
162 DWORD BaseDropTarget::OnDrop(IDataObject* data_object, 165 DWORD BaseDropTarget::OnDrop(IDataObject* data_object,
163 DWORD key_state, 166 DWORD key_state,
164 POINT cursor_position, 167 POINT cursor_position,
165 DWORD effect) { 168 DWORD effect) {
166 return DROPEFFECT_NONE; 169 return DROPEFFECT_NONE;
167 } 170 }
OLDNEW
« no previous file with comments | « base/base_drop_target.h ('k') | base/file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698