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

Side by Side Diff: content/browser/web_contents/web_drag_dest_win.cc

Issue 11275062: Move content\browser\web_contents to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 1 month 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
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 "content/browser/web_contents/web_drag_dest_win.h" 5 #include "content/browser/web_contents/web_drag_dest_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include "content/browser/renderer_host/render_view_host_impl.h" 10 #include "content/browser/renderer_host/render_view_host_impl.h"
11 #include "content/browser/web_contents/web_drag_utils_win.h" 11 #include "content/browser/web_contents/web_drag_utils_win.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_drag_dest_delegate.h" 13 #include "content/public/browser/web_drag_dest_delegate.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
17 #include "ui/base/clipboard/clipboard_util_win.h" 17 #include "ui/base/clipboard/clipboard_util_win.h"
18 #include "ui/base/dragdrop/os_exchange_data.h" 18 #include "ui/base/dragdrop/os_exchange_data.h"
19 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" 19 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
20 #include "ui/gfx/point.h" 20 #include "ui/gfx/point.h"
21 #include "webkit/glue/webdropdata.h" 21 #include "webkit/glue/webdropdata.h"
22 #include "webkit/glue/window_open_disposition.h" 22 #include "webkit/glue/window_open_disposition.h"
23 23
24 using WebKit::WebDragOperationNone; 24 using WebKit::WebDragOperationNone;
25 using WebKit::WebDragOperationCopy; 25 using WebKit::WebDragOperationCopy;
26 using WebKit::WebDragOperationLink; 26 using WebKit::WebDragOperationLink;
27 using WebKit::WebDragOperationMove; 27 using WebKit::WebDragOperationMove;
28 using WebKit::WebDragOperationGeneric; 28 using WebKit::WebDragOperationGeneric;
29 using content::OpenURLParams;
30 using content::Referrer;
31 using content::WebContents;
32 29
30 namespace content {
33 namespace { 31 namespace {
34 32
35 const unsigned short kHighBitMaskShort = 0x8000; 33 const unsigned short kHighBitMaskShort = 0x8000;
36 34
37 // A helper method for getting the preferred drop effect. 35 // A helper method for getting the preferred drop effect.
38 DWORD GetPreferredDropEffect(DWORD effect) { 36 DWORD GetPreferredDropEffect(DWORD effect) {
39 if (effect & DROPEFFECT_COPY) 37 if (effect & DROPEFFECT_COPY)
40 return DROPEFFECT_COPY; 38 return DROPEFFECT_COPY;
41 if (effect & DROPEFFECT_LINK) 39 if (effect & DROPEFFECT_LINK)
42 return DROPEFFECT_LINK; 40 return DROPEFFECT_LINK;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void OnDragLeave(IDataObject* data_object) { 82 void OnDragLeave(IDataObject* data_object) {
85 } 83 }
86 84
87 DWORD OnDrop(IDataObject* data_object, DWORD effect) { 85 DWORD OnDrop(IDataObject* data_object, DWORD effect) {
88 if (!ui::ClipboardUtil::HasUrl(data_object)) 86 if (!ui::ClipboardUtil::HasUrl(data_object))
89 return DROPEFFECT_NONE; 87 return DROPEFFECT_NONE;
90 88
91 std::wstring url; 89 std::wstring url;
92 std::wstring title; 90 std::wstring title;
93 ui::ClipboardUtil::GetUrl(data_object, &url, &title, true); 91 ui::ClipboardUtil::GetUrl(data_object, &url, &title, true);
94 OpenURLParams params( 92 OpenURLParams params(GURL(url), Referrer(), CURRENT_TAB,
95 GURL(url), Referrer(), CURRENT_TAB, 93 PAGE_TRANSITION_AUTO_BOOKMARK, false);
96 content::PAGE_TRANSITION_AUTO_BOOKMARK, false);
97 web_contents_->OpenURL(params); 94 web_contents_->OpenURL(params);
98 return GetPreferredDropEffect(effect); 95 return GetPreferredDropEffect(effect);
99 } 96 }
100 97
101 private: 98 private:
102 WebContents* web_contents_; 99 WebContents* web_contents_;
103 100
104 DISALLOW_COPY_AND_ASSIGN(InterstitialDropTarget); 101 DISALLOW_COPY_AND_ASSIGN(InterstitialDropTarget);
105 }; 102 };
106 103
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, 137 ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object,
141 &drop_data_->url); 138 &drop_data_->url);
142 139
143 drag_cursor_ = WebDragOperationNone; 140 drag_cursor_ = WebDragOperationNone;
144 141
145 POINT client_pt = cursor_position; 142 POINT client_pt = cursor_position;
146 ScreenToClient(GetHWND(), &client_pt); 143 ScreenToClient(GetHWND(), &client_pt);
147 web_contents_->GetRenderViewHost()->DragTargetDragEnter(*drop_data_, 144 web_contents_->GetRenderViewHost()->DragTargetDragEnter(*drop_data_,
148 gfx::Point(client_pt.x, client_pt.y), 145 gfx::Point(client_pt.x, client_pt.y),
149 gfx::Point(cursor_position.x, cursor_position.y), 146 gfx::Point(cursor_position.x, cursor_position.y),
150 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects), 147 WinDragOpMaskToWebDragOpMask(effects),
151 GetModifierFlags()); 148 GetModifierFlags());
152 149
153 if (delegate_) 150 if (delegate_)
154 delegate_->OnDragEnter(data_object); 151 delegate_->OnDragEnter(data_object);
155 152
156 // We lie here and always return a DROPEFFECT because we don't want to 153 // We lie here and always return a DROPEFFECT because we don't want to
157 // wait for the IPC call to return. 154 // wait for the IPC call to return.
158 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); 155 return WebDragOpToWinDragOp(drag_cursor_);
159 } 156 }
160 157
161 DWORD WebDragDest::OnDragOver(IDataObject* data_object, 158 DWORD WebDragDest::OnDragOver(IDataObject* data_object,
162 DWORD key_state, 159 DWORD key_state,
163 POINT cursor_position, 160 POINT cursor_position,
164 DWORD effects) { 161 DWORD effects) {
165 DCHECK(current_rvh_); 162 DCHECK(current_rvh_);
166 if (current_rvh_ != web_contents_->GetRenderViewHost()) 163 if (current_rvh_ != web_contents_->GetRenderViewHost())
167 OnDragEnter(data_object, key_state, cursor_position, effects); 164 OnDragEnter(data_object, key_state, cursor_position, effects);
168 165
169 if (web_contents_->ShowingInterstitialPage()) 166 if (web_contents_->ShowingInterstitialPage())
170 return interstitial_drop_target_->OnDragOver(data_object, effects); 167 return interstitial_drop_target_->OnDragOver(data_object, effects);
171 168
172 POINT client_pt = cursor_position; 169 POINT client_pt = cursor_position;
173 ScreenToClient(GetHWND(), &client_pt); 170 ScreenToClient(GetHWND(), &client_pt);
174 web_contents_->GetRenderViewHost()->DragTargetDragOver( 171 web_contents_->GetRenderViewHost()->DragTargetDragOver(
175 gfx::Point(client_pt.x, client_pt.y), 172 gfx::Point(client_pt.x, client_pt.y),
176 gfx::Point(cursor_position.x, cursor_position.y), 173 gfx::Point(cursor_position.x, cursor_position.y),
177 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects), 174 WinDragOpMaskToWebDragOpMask(effects),
178 GetModifierFlags()); 175 GetModifierFlags());
179 176
180 if (delegate_) 177 if (delegate_)
181 delegate_->OnDragOver(data_object); 178 delegate_->OnDragOver(data_object);
182 179
183 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); 180 return WebDragOpToWinDragOp(drag_cursor_);
184 } 181 }
185 182
186 void WebDragDest::OnDragLeave(IDataObject* data_object) { 183 void WebDragDest::OnDragLeave(IDataObject* data_object) {
187 DCHECK(current_rvh_); 184 DCHECK(current_rvh_);
188 if (current_rvh_ != web_contents_->GetRenderViewHost()) 185 if (current_rvh_ != web_contents_->GetRenderViewHost())
189 return; 186 return;
190 187
191 if (web_contents_->ShowingInterstitialPage()) { 188 if (web_contents_->ShowingInterstitialPage()) {
192 interstitial_drop_target_->OnDragLeave(data_object); 189 interstitial_drop_target_->OnDragLeave(data_object);
193 } else { 190 } else {
(...skipping 27 matching lines...) Expand all
221 gfx::Point(cursor_position.x, cursor_position.y), 218 gfx::Point(cursor_position.x, cursor_position.y),
222 GetModifierFlags()); 219 GetModifierFlags());
223 220
224 if (delegate_) 221 if (delegate_)
225 delegate_->OnDrop(data_object); 222 delegate_->OnDrop(data_object);
226 223
227 current_rvh_ = NULL; 224 current_rvh_ = NULL;
228 225
229 // This isn't always correct, but at least it's a close approximation. 226 // This isn't always correct, but at least it's a close approximation.
230 // For now, we always map a move to a copy to prevent potential data loss. 227 // For now, we always map a move to a copy to prevent potential data loss.
231 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); 228 DWORD drop_effect = WebDragOpToWinDragOp(drag_cursor_);
232 DWORD result = drop_effect != DROPEFFECT_MOVE ? 229 DWORD result = drop_effect != DROPEFFECT_MOVE ? drop_effect : DROPEFFECT_COPY;
233 drop_effect : DROPEFFECT_COPY;
234 230
235 drop_data_.reset(); 231 drop_data_.reset();
236 return result; 232 return result;
237 } 233 }
234
235 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_drag_dest_win.h ('k') | content/browser/web_contents/web_drag_source_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698