OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
6 | 6 |
7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "third_party/skia/include/core/SkPath.h" | 55 #include "third_party/skia/include/core/SkPath.h" |
56 #include "third_party/skia/include/core/SkShader.h" | 56 #include "third_party/skia/include/core/SkShader.h" |
57 | 57 |
58 #if defined(TOOLKIT_VIEWS) | 58 #if defined(TOOLKIT_VIEWS) |
59 #include "ui/base/dragdrop/os_exchange_data.h" | 59 #include "ui/base/dragdrop/os_exchange_data.h" |
60 #include "views/drag_utils.h" | 60 #include "views/drag_utils.h" |
61 #endif | 61 #endif |
62 | 62 |
63 #if defined(TOOLKIT_USES_GTK) | 63 #if defined(TOOLKIT_USES_GTK) |
64 #if defined(TOOLKIT_VIEWS) | 64 #if defined(TOOLKIT_VIEWS) |
65 #include "app/drag_drop_types.h" | 65 #include "ui/base/dragdrop/drag_drop_types.h" |
66 #include "views/widget/widget_gtk.h" | 66 #include "views/widget/widget_gtk.h" |
67 #elif defined(TOOLKIT_GTK) | 67 #elif defined(TOOLKIT_GTK) |
68 #include "chrome/browser/gtk/custom_drag.h" | 68 #include "chrome/browser/gtk/custom_drag.h" |
69 #endif // defined(TOOLKIT_GTK) | 69 #endif // defined(TOOLKIT_GTK) |
70 #endif // defined(TOOLKIT_USES_GTK) | 70 #endif // defined(TOOLKIT_USES_GTK) |
71 | 71 |
72 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
73 #include "app/win/drag_source.h" | |
74 #include "app/win/win_util.h" | 73 #include "app/win/win_util.h" |
75 #include "base/win/scoped_comptr.h" | 74 #include "base/win/scoped_comptr.h" |
76 #include "chrome/browser/browser_list.h" | 75 #include "chrome/browser/browser_list.h" |
77 #include "chrome/browser/ui/views/frame/browser_view.h" | 76 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 77 #include "ui/base/dragdrop/drag_source.h" |
78 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 78 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
79 #endif | 79 #endif |
80 | 80 |
81 namespace download_util { | 81 namespace download_util { |
82 | 82 |
83 // How many times to cycle the complete animation. This should be an odd number | 83 // How many times to cycle the complete animation. This should be an odd number |
84 // so that the animation ends faded out. | 84 // so that the animation ends faded out. |
85 static const int kCompleteAnimationCycles = 5; | 85 static const int kCompleteAnimationCycles = 5; |
86 | 86 |
87 // The maximum number of 'uniquified' files we will try to create. | 87 // The maximum number of 'uniquified' files we will try to create. |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 if (mime_type.empty()) | 483 if (mime_type.empty()) |
484 net::GetMimeTypeFromFile(full_path, &mime_type); | 484 net::GetMimeTypeFromFile(full_path, &mime_type); |
485 | 485 |
486 // Add URL so that we can load supported files when dragged to TabContents. | 486 // Add URL so that we can load supported files when dragged to TabContents. |
487 if (net::IsSupportedMimeType(mime_type)) { | 487 if (net::IsSupportedMimeType(mime_type)) { |
488 data.SetURL(GURL(WideToUTF8(full_path.ToWStringHack())), | 488 data.SetURL(GURL(WideToUTF8(full_path.ToWStringHack())), |
489 download->GetFileNameToReportUser().ToWStringHack()); | 489 download->GetFileNameToReportUser().ToWStringHack()); |
490 } | 490 } |
491 | 491 |
492 #if defined(OS_WIN) | 492 #if defined(OS_WIN) |
493 scoped_refptr<app::win::DragSource> drag_source(new app::win::DragSource); | 493 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); |
494 | 494 |
495 // Run the drag and drop loop | 495 // Run the drag and drop loop |
496 DWORD effects; | 496 DWORD effects; |
497 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), | 497 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), |
498 drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); | 498 drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); |
499 #elif defined(TOOLKIT_USES_GTK) | 499 #elif defined(TOOLKIT_USES_GTK) |
500 GtkWidget* root = gtk_widget_get_toplevel(view); | 500 GtkWidget* root = gtk_widget_get_toplevel(view); |
501 if (!root) | 501 if (!root) |
502 return; | 502 return; |
503 views::WidgetGtk* widget = views::WidgetGtk::GetViewForNative(root); | 503 views::WidgetGtk* widget = views::WidgetGtk::GetViewForNative(root); |
504 if (!widget) | 504 if (!widget) |
505 return; | 505 return; |
506 | 506 |
507 widget->DoDrag(data, DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK); | 507 widget->DoDrag(data, |
| 508 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); |
508 #endif // OS_WIN | 509 #endif // OS_WIN |
509 } | 510 } |
510 #elif defined(USE_X11) | 511 #elif defined(USE_X11) |
511 void DragDownload(const DownloadItem* download, | 512 void DragDownload(const DownloadItem* download, |
512 SkBitmap* icon, | 513 SkBitmap* icon, |
513 gfx::NativeView view) { | 514 gfx::NativeView view) { |
514 DownloadItemDrag::BeginDrag(download, icon); | 515 DownloadItemDrag::BeginDrag(download, icon); |
515 } | 516 } |
516 #endif // USE_X11 | 517 #endif // USE_X11 |
517 | 518 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 773 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
773 // Extensions that are not from the gallery are considered dangerous. | 774 // Extensions that are not from the gallery are considered dangerous. |
774 return true; | 775 return true; |
775 } | 776 } |
776 } | 777 } |
777 | 778 |
778 return false; | 779 return false; |
779 } | 780 } |
780 | 781 |
781 } // namespace download_util | 782 } // namespace download_util |
OLD | NEW |