OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/ui/cocoa/web_drag_source.h" | 5 #import "chrome/browser/ui/cocoa/web_drag_source.h" |
6 | 6 |
7 #include <limits> | |
jianli
2011/01/12 21:32:27
Why is this include needed in this patch?
gmorrita
2011/01/13 08:34:43
Oops. removed.
| |
8 | |
7 #include "app/mac/nsimage_cache.h" | 9 #include "app/mac/nsimage_cache.h" |
8 #include "base/file_path.h" | 10 #include "base/file_path.h" |
9 #include "base/string_util.h" | 11 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
11 #include "base/task.h" | 13 #include "base/task.h" |
12 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
13 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/download/download_manager.h" | 17 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/download/download_util.h" | 18 #include "chrome/browser/download/download_util.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 offset:NSZeroSize | 248 offset:NSZeroSize |
247 event:dragEvent | 249 event:dragEvent |
248 pasteboard:pasteboard_ | 250 pasteboard:pasteboard_ |
249 source:contentsView_ | 251 source:contentsView_ |
250 slideBack:YES]; | 252 slideBack:YES]; |
251 } | 253 } |
252 | 254 |
253 - (void)endDragAt:(NSPoint)screenPoint | 255 - (void)endDragAt:(NSPoint)screenPoint |
254 operation:(NSDragOperation)operation { | 256 operation:(NSDragOperation)operation { |
255 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); | 257 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); |
256 if (rvh) { | 258 if (rvh && [contentsView_ window]) { |
jianli
2011/01/12 21:32:27
It might be better to check [contentsView_ window]
| |
257 rvh->DragSourceSystemDragEnded(); | 259 rvh->DragSourceSystemDragEnded(); |
258 | 260 |
259 // Convert |screenPoint| to view coordinates and flip it. | 261 // Convert |screenPoint| to view coordinates and flip it. |
260 NSPoint localPoint = [self convertScreenPoint:screenPoint]; | 262 NSPoint localPoint = [self convertScreenPoint:screenPoint]; |
261 NSRect viewFrame = [contentsView_ frame]; | 263 NSRect viewFrame = [contentsView_ frame]; |
262 localPoint.y = viewFrame.size.height - localPoint.y; | 264 localPoint.y = viewFrame.size.height - localPoint.y; |
263 // Flip |screenPoint|. | 265 // Flip |screenPoint|. |
264 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 266 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
265 screenPoint.y = screenFrame.size.height - screenPoint.y; | 267 screenPoint.y = screenFrame.size.height - screenPoint.y; |
266 | 268 |
267 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, | 269 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, |
268 screenPoint.x, screenPoint.y, | 270 screenPoint.x, screenPoint.y, |
269 static_cast<WebKit::WebDragOperation>(operation)); | 271 static_cast<WebKit::WebDragOperation>(operation)); |
270 } | 272 } |
271 | 273 |
272 // Make sure the pasteboard owner isn't us. | 274 // Make sure the pasteboard owner isn't us. |
273 [pasteboard_ declareTypes:[NSArray array] owner:nil]; | 275 [pasteboard_ declareTypes:[NSArray array] owner:nil]; |
274 } | 276 } |
275 | 277 |
276 - (void)moveDragTo:(NSPoint)screenPoint { | 278 - (void)moveDragTo:(NSPoint)screenPoint { |
277 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); | 279 RenderViewHost* rvh = [contentsView_ tabContents]->render_view_host(); |
278 if (rvh) { | 280 if (rvh && [contentsView_ window]) { |
jianli
2011/01/12 21:32:27
ditto.
| |
279 // Convert |screenPoint| to view coordinates and flip it. | 281 // Convert |screenPoint| to view coordinates and flip it. |
280 NSPoint localPoint = [self convertScreenPoint:screenPoint]; | 282 NSPoint localPoint = [self convertScreenPoint:screenPoint]; |
281 NSRect viewFrame = [contentsView_ frame]; | 283 NSRect viewFrame = [contentsView_ frame]; |
282 localPoint.y = viewFrame.size.height - localPoint.y; | 284 localPoint.y = viewFrame.size.height - localPoint.y; |
283 // Flip |screenPoint|. | 285 // Flip |screenPoint|. |
284 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 286 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
285 screenPoint.y = screenFrame.size.height - screenPoint.y; | 287 screenPoint.y = screenFrame.size.height - screenPoint.y; |
286 | 288 |
287 rvh->DragSourceMovedTo(localPoint.x, localPoint.y, | 289 rvh->DragSourceMovedTo(localPoint.x, localPoint.y, |
288 screenPoint.x, screenPoint.y); | 290 screenPoint.x, screenPoint.y); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 | 405 |
404 - (NSImage*)dragImage { | 406 - (NSImage*)dragImage { |
405 if (dragImage_) | 407 if (dragImage_) |
406 return dragImage_; | 408 return dragImage_; |
407 | 409 |
408 // Default to returning a generic image. | 410 // Default to returning a generic image. |
409 return app::mac::GetCachedImageWithName(@"nav.pdf"); | 411 return app::mac::GetCachedImageWithName(@"nav.pdf"); |
410 } | 412 } |
411 | 413 |
412 @end // @implementation WebDragSource (Private) | 414 @end // @implementation WebDragSource (Private) |
OLD | NEW |