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

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

Issue 10065027: Fix downloads page drag/drop in WIN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (mime_type.empty()) 383 if (mime_type.empty())
384 net::GetMimeTypeFromFile(full_path, &mime_type); 384 net::GetMimeTypeFromFile(full_path, &mime_type);
385 385
386 // Add URL so that we can load supported files when dragged to WebContents. 386 // Add URL so that we can load supported files when dragged to WebContents.
387 if (net::IsSupportedMimeType(mime_type)) { 387 if (net::IsSupportedMimeType(mime_type)) {
388 data.SetURL(net::FilePathToFileURL(full_path), 388 data.SetURL(net::FilePathToFileURL(full_path),
389 download->GetFileNameToReportUser().LossyDisplayName()); 389 download->GetFileNameToReportUser().LossyDisplayName());
390 } 390 }
391 391
392 #if !defined(TOOLKIT_GTK) 392 #if !defined(TOOLKIT_GTK)
393 #if defined(USE_AURA)
393 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); 394 views::Widget* widget = views::Widget::GetWidgetForNativeView(view);
394 // TODO(varunjain): Widget should not be NULL here. But its causing the crash
395 // in http://code.google.com/p/chromium/issues/detail?id=120430 Find out why.
396 if (!widget || !widget->native_widget())
397 return;
398
399 gfx::Point location = gfx::Screen::GetCursorScreenPoint(); 395 gfx::Point location = gfx::Screen::GetCursorScreenPoint();
400 // We do not care about notifying the DragItemView on completion of drag. So 396 // We do not care about notifying the DragItemView on completion of drag. So
401 // we pass NULL to RunShellDrag for the source view. 397 // we pass NULL to RunShellDrag for the source view.
402 widget->RunShellDrag(NULL, data, location, 398 widget->RunShellDrag(NULL, data, location,
403 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); 399 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK);
400 #else // We are on WIN without AURA
401 // We cannot use Widget::RunShellDrag on WIN since the |view| is backed by a
402 // TabContentsViewWin, not a NativeWidgetWin.
403 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource);
404 // Run the drag and drop loop
405 DWORD effects;
406 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
407 drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
408 #endif
404 409
405 #else 410 #else
406 GtkWidget* root = gtk_widget_get_toplevel(view); 411 GtkWidget* root = gtk_widget_get_toplevel(view);
407 if (!root) 412 if (!root)
408 return; 413 return;
409 414
410 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>( 415 views::NativeWidgetGtk* widget = static_cast<views::NativeWidgetGtk*>(
411 views::Widget::GetWidgetForNativeView(root)->native_widget()); 416 views::Widget::GetWidgetForNativeView(root)->native_widget());
412 if (!widget) 417 if (!widget)
413 return; 418 return;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 UMA_HISTOGRAM_ENUMERATION( 642 UMA_HISTOGRAM_ENUMERATION(
638 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 643 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
639 } 644 }
640 645
641 void RecordDownloadSource(ChromeDownloadSource source) { 646 void RecordDownloadSource(ChromeDownloadSource source) {
642 UMA_HISTOGRAM_ENUMERATION( 647 UMA_HISTOGRAM_ENUMERATION(
643 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 648 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
644 } 649 }
645 650
646 } // namespace download_util 651 } // 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