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

Unified Diff: components/test_runner/event_sender.cc

Issue 2674953003: Only generate suggested filenames when actually dragging an image. (Closed)
Patch Set: rebase Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/event_sender.cc
diff --git a/components/test_runner/event_sender.cc b/components/test_runner/event_sender.cc
index 4be39cdd67434d18aa901e847fdf320786aee1f7..01f8a5e9e7d593961184f118d51b18e0decd777a 100644
--- a/components/test_runner/event_sender.cc
+++ b/components/test_runner/event_sender.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
+#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string16.h"
@@ -26,6 +27,8 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
+#include "net/base/filename_util.h"
+#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h"
#include "third_party/WebKit/public/platform/WebGestureEvent.h"
#include "third_party/WebKit/public/platform/WebKeyboardEvent.h"
@@ -62,6 +65,7 @@ using blink::WebPointerProperties;
using blink::WebString;
using blink::WebTouchEvent;
using blink::WebTouchPoint;
+using blink::WebURL;
using blink::WebVector;
using blink::WebView;
@@ -1890,16 +1894,28 @@ void EventSender::DumpFilenameBeingDragged() {
if (current_drag_data_.isNull())
return;
- WebString filename;
WebVector<WebDragData::Item> items = current_drag_data_.items();
for (size_t i = 0; i < items.size(); ++i) {
if (items[i].storageType == WebDragData::Item::StorageTypeBinaryData) {
- filename = items[i].title;
- break;
+ WebURL url = items[i].binaryDataSourceURL;
+ WebString filename_extension = items[i].binaryDataFilenameExtension;
+ WebString content_disposition = items[i].binaryDataContentDisposition;
+ base::FilePath filename =
+ net::GenerateFileName(url, content_disposition.utf8(),
+ std::string(), // referrer_charset
+ std::string(), // suggested_name
+ std::string(), // mime_type
+ std::string()); // default_name
+#if defined(OS_WIN)
+ filename = filename.ReplaceExtension(filename_extension.utf16());
+#else
+ filename = filename.ReplaceExtension(filename_extension.utf8());
+#endif
+ delegate()->PrintMessage(std::string("Filename being dragged: ") +
+ filename.AsUTF8Unsafe() + "\n");
+ return;
}
}
- delegate()->PrintMessage(std::string("Filename being dragged: ") +
- filename.utf8().data() + "\n");
}
void EventSender::GestureFlingCancel() {
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698