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

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: more vector use fixes 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 WebContentsDragWin::~WebContentsDragWin() { 149 WebContentsDragWin::~WebContentsDragWin() {
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
151 DCHECK(!drag_drop_thread_.get()); 151 DCHECK(!drag_drop_thread_.get());
152 } 152 }
153 153
154 void WebContentsDragWin::StartDragging(const WebDropData& drop_data, 154 void WebContentsDragWin::StartDragging(const WebDropData& drop_data,
155 WebDragOperationsMask ops, 155 WebDragOperationsMask ops,
156 const gfx::ImageSkia& image, 156 const gfx::ImageSkia& image,
157 const gfx::Point& image_offset) { 157 const gfx::Vector2d& image_offset) {
158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
159 159
160 drag_source_ = new WebDragSource(source_window_, web_contents_); 160 drag_source_ = new WebDragSource(source_window_, web_contents_);
161 161
162 const GURL& page_url = web_contents_->GetURL(); 162 const GURL& page_url = web_contents_->GetURL();
163 const std::string& page_encoding = web_contents_->GetEncoding(); 163 const std::string& page_encoding = web_contents_->GetEncoding();
164 164
165 // If it is not drag-out, do the drag-and-drop in the current UI thread. 165 // If it is not drag-out, do the drag-and-drop in the current UI thread.
166 if (drop_data.download_metadata.empty()) { 166 if (drop_data.download_metadata.empty()) {
167 if (DoDragging(drop_data, ops, page_url, page_encoding, 167 if (DoDragging(drop_data, ops, page_url, page_encoding,
(...skipping 17 matching lines...) Expand all
185 185
186 EnableBackgroundDraggingSupport(drag_drop_thread_->thread_id()); 186 EnableBackgroundDraggingSupport(drag_drop_thread_->thread_id());
187 } 187 }
188 188
189 void WebContentsDragWin::StartBackgroundDragging( 189 void WebContentsDragWin::StartBackgroundDragging(
190 const WebDropData& drop_data, 190 const WebDropData& drop_data,
191 WebDragOperationsMask ops, 191 WebDragOperationsMask ops,
192 const GURL& page_url, 192 const GURL& page_url,
193 const std::string& page_encoding, 193 const std::string& page_encoding,
194 const gfx::ImageSkia& image, 194 const gfx::ImageSkia& image,
195 const gfx::Point& image_offset) { 195 const gfx::Vector2d& image_offset) {
196 drag_drop_thread_id_ = base::PlatformThread::CurrentId(); 196 drag_drop_thread_id_ = base::PlatformThread::CurrentId();
197 197
198 if (DoDragging(drop_data, ops, page_url, page_encoding, 198 if (DoDragging(drop_data, ops, page_url, page_encoding,
199 image, image_offset)) { 199 image, image_offset)) {
200 BrowserThread::PostTask( 200 BrowserThread::PostTask(
201 BrowserThread::UI, 201 BrowserThread::UI,
202 FROM_HERE, 202 FROM_HERE,
203 base::Bind(&WebContentsDragWin::EndDragging, this)); 203 base::Bind(&WebContentsDragWin::EndDragging, this));
204 } else { 204 } else {
205 // When DoDragging returns false, the contents view window is gone and thus 205 // When DoDragging returns false, the contents view window is gone and thus
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 291
292 data->SetURL(drop_data.url, drop_data.url_title); 292 data->SetURL(drop_data.url, drop_data.url_title);
293 } 293 }
294 294
295 bool WebContentsDragWin::DoDragging(const WebDropData& drop_data, 295 bool WebContentsDragWin::DoDragging(const WebDropData& drop_data,
296 WebDragOperationsMask ops, 296 WebDragOperationsMask ops,
297 const GURL& page_url, 297 const GURL& page_url,
298 const std::string& page_encoding, 298 const std::string& page_encoding,
299 const gfx::ImageSkia& image, 299 const gfx::ImageSkia& image,
300 const gfx::Point& image_offset) { 300 const gfx::Vector2d& image_offset) {
301 ui::OSExchangeData data; 301 ui::OSExchangeData data;
302 302
303 if (!drop_data.download_metadata.empty()) { 303 if (!drop_data.download_metadata.empty()) {
304 PrepareDragForDownload(drop_data, &data, page_url, page_encoding); 304 PrepareDragForDownload(drop_data, &data, page_url, page_encoding);
305 305
306 // Set the observer. 306 // Set the observer.
307 ui::OSExchangeDataProviderWin::GetDataObjectImpl(data)->set_observer(this); 307 ui::OSExchangeDataProviderWin::GetDataObjectImpl(data)->set_observer(this);
308 } 308 }
309 309
310 // We set the file contents before the URL because the URL also sets file 310 // 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
411 411
412 // The drag-and-drop thread is only closed after OLE is done with 412 // The drag-and-drop thread is only closed after OLE is done with
413 // DataObjectImpl. 413 // DataObjectImpl.
414 BrowserThread::PostTask( 414 BrowserThread::PostTask(
415 BrowserThread::UI, 415 BrowserThread::UI,
416 FROM_HERE, 416 FROM_HERE,
417 base::Bind(&WebContentsDragWin::CloseThread, this)); 417 base::Bind(&WebContentsDragWin::CloseThread, this));
418 } 418 }
419 419
420 } // namespace content 420 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698