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

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 9972017: Merge 132127 - Fix downloads page drag/drop in WIN. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (mime_type.empty()) 390 if (mime_type.empty())
391 net::GetMimeTypeFromFile(full_path, &mime_type); 391 net::GetMimeTypeFromFile(full_path, &mime_type);
392 392
393 // Add URL so that we can load supported files when dragged to WebContents. 393 // Add URL so that we can load supported files when dragged to WebContents.
394 if (net::IsSupportedMimeType(mime_type)) { 394 if (net::IsSupportedMimeType(mime_type)) {
395 data.SetURL(net::FilePathToFileURL(full_path), 395 data.SetURL(net::FilePathToFileURL(full_path),
396 download->GetFileNameToReportUser().LossyDisplayName()); 396 download->GetFileNameToReportUser().LossyDisplayName());
397 } 397 }
398 398
399 #if !defined(TOOLKIT_USES_GTK) 399 #if !defined(TOOLKIT_USES_GTK)
400 #if defined(USE_AURA)
400 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); 401 views::Widget* widget = views::Widget::GetWidgetForNativeView(view);
401 // TODO(varunjain): Widget should not be NULL here. But its causing the crash
402 // in http://code.google.com/p/chromium/issues/detail?id=120430 Find out why.
403 if (!widget || !widget->native_widget())
404 return;
405
406 gfx::Point location = gfx::Screen::GetCursorScreenPoint(); 402 gfx::Point location = gfx::Screen::GetCursorScreenPoint();
407 // We do not care about notifying the DragItemView on completion of drag. So 403 // We do not care about notifying the DragItemView on completion of drag. So
408 // we pass NULL to RunShellDrag for the source view. 404 // we pass NULL to RunShellDrag for the source view.
409 widget->RunShellDrag(NULL, data, location, 405 widget->RunShellDrag(NULL, data, location,
410 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); 406 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK);
407 #else // We are on WIN without AURA
408 // We cannot use Widget::RunShellDrag on WIN since the |view| is backed by a
409 // TabContentsViewWin, not a NativeWidgetWin.
410 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource);
411 // Run the drag and drop loop
412 DWORD effects;
413 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
414 drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
415 #endif
411 416
412 #else 417 #else
413 GtkWidget* root = gtk_widget_get_toplevel(view); 418 GtkWidget* root = gtk_widget_get_toplevel(view);
414 if (!root) 419 if (!root)
415 return; 420 return;
416 421
417 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( 422 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>(
418 views::Widget::GetWidgetForNativeView(root)->native_widget()); 423 views::Widget::GetWidgetForNativeView(root)->native_widget());
419 if (!widget) 424 if (!widget)
420 return; 425 return;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 UMA_HISTOGRAM_ENUMERATION( 646 UMA_HISTOGRAM_ENUMERATION(
642 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 647 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
643 } 648 }
644 649
645 void RecordDownloadSource(ChromeDownloadSource source) { 650 void RecordDownloadSource(ChromeDownloadSource source) {
646 UMA_HISTOGRAM_ENUMERATION( 651 UMA_HISTOGRAM_ENUMERATION(
647 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 652 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
648 } 653 }
649 654
650 } // namespace download_util 655 } // namespace download_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698