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

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

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup 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_contents_drag_win.h" 5 #include "content/browser/web_contents/web_contents_drag_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 WebContentsDragWin::~WebContentsDragWin() { 150 WebContentsDragWin::~WebContentsDragWin() {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
152 DCHECK(!drag_drop_thread_.get()); 152 DCHECK(!drag_drop_thread_.get());
153 } 153 }
154 154
155 void WebContentsDragWin::StartDragging(const WebDropData& drop_data, 155 void WebContentsDragWin::StartDragging(const WebDropData& drop_data,
156 WebDragOperationsMask ops, 156 WebDragOperationsMask ops,
157 const gfx::ImageSkia& image, 157 const gfx::ImageSkia& image,
158 const gfx::Point& image_offset) { 158 const gfx::Vector2d& image_offset) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
160 160
161 drag_source_ = new WebDragSource(source_window_, web_contents_); 161 drag_source_ = new WebDragSource(source_window_, web_contents_);
162 162
163 const GURL& page_url = web_contents_->GetURL(); 163 const GURL& page_url = web_contents_->GetURL();
164 const std::string& page_encoding = web_contents_->GetEncoding(); 164 const std::string& page_encoding = web_contents_->GetEncoding();
165 165
166 // If it is not drag-out, do the drag-and-drop in the current UI thread. 166 // If it is not drag-out, do the drag-and-drop in the current UI thread.
167 if (drop_data.download_metadata.empty()) { 167 if (drop_data.download_metadata.empty()) {
168 if (DoDragging(drop_data, ops, page_url, page_encoding, 168 if (DoDragging(drop_data, ops, page_url, page_encoding,
(...skipping 17 matching lines...) Expand all
186 186
187 EnableBackgroundDraggingSupport(drag_drop_thread_->thread_id()); 187 EnableBackgroundDraggingSupport(drag_drop_thread_->thread_id());
188 } 188 }
189 189
190 void WebContentsDragWin::StartBackgroundDragging( 190 void WebContentsDragWin::StartBackgroundDragging(
191 const WebDropData& drop_data, 191 const WebDropData& drop_data,
192 WebDragOperationsMask ops, 192 WebDragOperationsMask ops,
193 const GURL& page_url, 193 const GURL& page_url,
194 const std::string& page_encoding, 194 const std::string& page_encoding,
195 const gfx::ImageSkia& image, 195 const gfx::ImageSkia& image,
196 const gfx::Point& image_offset) { 196 const gfx::Vector2d& image_offset) {
197 drag_drop_thread_id_ = base::PlatformThread::CurrentId(); 197 drag_drop_thread_id_ = base::PlatformThread::CurrentId();
198 198
199 if (DoDragging(drop_data, ops, page_url, page_encoding, 199 if (DoDragging(drop_data, ops, page_url, page_encoding,
200 image, image_offset)) { 200 image, image_offset)) {
201 BrowserThread::PostTask( 201 BrowserThread::PostTask(
202 BrowserThread::UI, 202 BrowserThread::UI,
203 FROM_HERE, 203 FROM_HERE,
204 base::Bind(&WebContentsDragWin::EndDragging, this)); 204 base::Bind(&WebContentsDragWin::EndDragging, this));
205 } else { 205 } else {
206 // When DoDragging returns false, the contents view window is gone and thus 206 // When DoDragging returns false, the contents view window is gone and thus
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 301 }
302 302
303 data->SetURL(drop_data.url, drop_data.url_title); 303 data->SetURL(drop_data.url, drop_data.url_title);
304 } 304 }
305 305
306 bool WebContentsDragWin::DoDragging(const WebDropData& drop_data, 306 bool WebContentsDragWin::DoDragging(const WebDropData& drop_data,
307 WebDragOperationsMask ops, 307 WebDragOperationsMask ops,
308 const GURL& page_url, 308 const GURL& page_url,
309 const std::string& page_encoding, 309 const std::string& page_encoding,
310 const gfx::ImageSkia& image, 310 const gfx::ImageSkia& image,
311 const gfx::Point& image_offset) { 311 const gfx::Vector2d& image_offset) {
312 ui::OSExchangeData data; 312 ui::OSExchangeData data;
313 313
314 if (!drop_data.download_metadata.empty()) { 314 if (!drop_data.download_metadata.empty()) {
315 PrepareDragForDownload(drop_data, &data, page_url, page_encoding); 315 PrepareDragForDownload(drop_data, &data, page_url, page_encoding);
316 316
317 // Set the observer. 317 // Set the observer.
318 ui::OSExchangeDataProviderWin::GetDataObjectImpl(data)->set_observer(this); 318 ui::OSExchangeDataProviderWin::GetDataObjectImpl(data)->set_observer(this);
319 } 319 }
320 320
321 // We set the file contents before the URL because the URL also sets file 321 // We set the file contents before the URL because the URL also sets file
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 // The drag-and-drop thread is only closed after OLE is done with 423 // The drag-and-drop thread is only closed after OLE is done with
424 // DataObjectImpl. 424 // DataObjectImpl.
425 BrowserThread::PostTask( 425 BrowserThread::PostTask(
426 BrowserThread::UI, 426 BrowserThread::UI,
427 FROM_HERE, 427 FROM_HERE,
428 base::Bind(&WebContentsDragWin::CloseThread, this)); 428 base::Bind(&WebContentsDragWin::CloseThread, this));
429 } 429 }
430 430
431 } // namespace content 431 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698