summaryrefslogtreecommitdiffstats
path: root/ui/base/dragdrop
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 07:07:54 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 07:07:54 +0000
commitad688f24f2931740f5c570b1ed89ae628950a857 (patch)
tree0e82a57225d135b72c4051b5f57b46c07a0b070d /ui/base/dragdrop
parent294987d4e9a4c6bcd748d2b30ee8a8f39fa179a6 (diff)
downloadchromium_src-ad688f24f2931740f5c570b1ed89ae628950a857.zip
chromium_src-ad688f24f2931740f5c570b1ed89ae628950a857.tar.gz
chromium_src-ad688f24f2931740f5c570b1ed89ae628950a857.tar.bz2
Add plumbing for file display names for drag and drop
On HTML5 file system, the real path names are human-unreadable hence we should propagate human-readable display names when performing drag-and-drop. WebKit patch was in http://trac.webkit.org/changeset/116186 FWIW, I originally added display_names to WebDropData but the resulting code was not desirable: - checking if the size of |display_names| match with |file_names| is not clean (parallel arrays like these are not good in general) - adding GetDisplayNames/SetDisplayNames() to every Provider implementation looked more complicated than changing the existing GetFilenames/SetFilenames() to take a struct. BUG=chromium-os:30419,chromium-os:30665 TEST=confirm that the correct file name is shown by the steps described in crosbug.co/30665 Review URL: https://chromiumcodereview.appspot.com/10382056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/dragdrop')
-rw-r--r--ui/base/dragdrop/os_exchange_data.cc19
-rw-r--r--ui/base/dragdrop/os_exchange_data.h25
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aura.cc12
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aura.h8
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_gtk.h6
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_win.h6
6 files changed, 54 insertions, 22 deletions
diff --git a/ui/base/dragdrop/os_exchange_data.cc b/ui/base/dragdrop/os_exchange_data.cc
index c0b066c..12eddeb 100644
--- a/ui/base/dragdrop/os_exchange_data.cc
+++ b/ui/base/dragdrop/os_exchange_data.cc
@@ -18,6 +18,15 @@ OSExchangeData::DownloadFileInfo::DownloadFileInfo(
OSExchangeData::DownloadFileInfo::~DownloadFileInfo() {}
+OSExchangeData::FileInfo::FileInfo(
+ const FilePath& path,
+ const FilePath& display_name)
+ : path(path),
+ display_name(display_name) {
+}
+
+OSExchangeData::FileInfo::~FileInfo() {}
+
OSExchangeData::OSExchangeData() : provider_(CreateProvider()) {
}
@@ -39,8 +48,9 @@ void OSExchangeData::SetFilename(const FilePath& path) {
provider_->SetFilename(path);
}
-void OSExchangeData::SetFilenames(const std::vector<FilePath>& paths) {
- provider_->SetFilenames(paths);
+void OSExchangeData::SetFilenames(
+ const std::vector<FileInfo>& filenames) {
+ provider_->SetFilenames(filenames);
}
void OSExchangeData::SetPickledData(CustomFormat format, const Pickle& data) {
@@ -59,8 +69,9 @@ bool OSExchangeData::GetFilename(FilePath* path) const {
return provider_->GetFilename(path);
}
-bool OSExchangeData::GetFilenames(std::vector<FilePath>* paths) const {
- return provider_->GetFilenames(paths);
+bool OSExchangeData::GetFilenames(
+ std::vector<FileInfo>* filenames) const {
+ return provider_->GetFilenames(filenames);
}
bool OSExchangeData::GetPickledData(CustomFormat format, Pickle* data) const {
diff --git a/ui/base/dragdrop/os_exchange_data.h b/ui/base/dragdrop/os_exchange_data.h
index 9ec452d..702a8ab 100644
--- a/ui/base/dragdrop/os_exchange_data.h
+++ b/ui/base/dragdrop/os_exchange_data.h
@@ -86,6 +86,17 @@ class UI_EXPORT OSExchangeData {
scoped_refptr<DownloadFileProvider> downloader;
};
+ // Encapsulates the info about a file.
+ struct UI_EXPORT FileInfo {
+ FileInfo(const FilePath& path, const FilePath& display_name);
+ ~FileInfo();
+
+ // The path of the file.
+ FilePath path;
+ // The display name of the file. This field is optional.
+ FilePath display_name;
+ };
+
// Provider defines the platform specific part of OSExchangeData that
// interacts with the native system.
class UI_EXPORT Provider {
@@ -96,13 +107,15 @@ class UI_EXPORT OSExchangeData {
virtual void SetString(const string16& data) = 0;
virtual void SetURL(const GURL& url, const string16& title) = 0;
virtual void SetFilename(const FilePath& path) = 0;
- virtual void SetFilenames(const std::vector<FilePath>& paths) = 0;
+ virtual void SetFilenames(
+ const std::vector<FileInfo>& file_names) = 0;
virtual void SetPickledData(CustomFormat format, const Pickle& data) = 0;
virtual bool GetString(string16* data) const = 0;
virtual bool GetURLAndTitle(GURL* url, string16* title) const = 0;
virtual bool GetFilename(FilePath* path) const = 0;
- virtual bool GetFilenames(std::vector<FilePath>* paths) const = 0;
+ virtual bool GetFilenames(
+ std::vector<FileInfo>* file_names) const = 0;
virtual bool GetPickledData(CustomFormat format, Pickle* data) const = 0;
virtual bool HasString() const = 0;
@@ -156,8 +169,9 @@ class UI_EXPORT OSExchangeData {
void SetURL(const GURL& url, const string16& title);
// A full path to a file.
void SetFilename(const FilePath& path);
- // Full path to one or more files.
- void SetFilenames(const std::vector<FilePath>& paths);
+ // Full path to one or more files. See also SetFilenames() in Provider.
+ void SetFilenames(
+ const std::vector<FileInfo>& file_names);
// Adds pickled data of the specified format.
void SetPickledData(CustomFormat format, const Pickle& data);
@@ -169,7 +183,8 @@ class UI_EXPORT OSExchangeData {
bool GetURLAndTitle(GURL* url, string16* title) const;
// Return the path of a file, if available.
bool GetFilename(FilePath* path) const;
- bool GetFilenames(std::vector<FilePath>* paths) const;
+ bool GetFilenames(
+ std::vector<FileInfo>* file_names) const;
bool GetPickledData(CustomFormat format, Pickle* data) const;
// Test whether or not data of certain types is present, without actually
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.cc b/ui/base/dragdrop/os_exchange_data_provider_aura.cc
index be2570b..8d6e2fc 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aura.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aura.cc
@@ -30,13 +30,13 @@ void OSExchangeDataProviderAura::SetURL(const GURL& url,
void OSExchangeDataProviderAura::SetFilename(const FilePath& path) {
filenames_.clear();
- filenames_.push_back(path);
+ filenames_.push_back(OSExchangeData::FileInfo(path, FilePath()));
formats_ |= OSExchangeData::FILE_NAME;
}
void OSExchangeDataProviderAura::SetFilenames(
- const std::vector<FilePath>& paths) {
- filenames_ = paths;
+ const std::vector<OSExchangeData::FileInfo>& filenames) {
+ filenames_ = filenames;
formats_ |= OSExchangeData::FILE_NAME;
}
@@ -73,15 +73,15 @@ bool OSExchangeDataProviderAura::GetFilename(FilePath* path) const {
if ((formats_ & OSExchangeData::FILE_NAME) == 0)
return false;
DCHECK(!filenames_.empty());
- *path = filenames_[0];
+ *path = filenames_[0].path;
return true;
}
bool OSExchangeDataProviderAura::GetFilenames(
- std::vector<FilePath>* paths) const {
+ std::vector<OSExchangeData::FileInfo>* filenames) const {
if ((formats_ & OSExchangeData::FILE_NAME) == 0)
return false;
- *paths = filenames_;
+ *filenames = filenames_;
return true;
}
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.h b/ui/base/dragdrop/os_exchange_data_provider_aura.h
index ad5c312..0758a7a 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aura.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_aura.h
@@ -29,13 +29,15 @@ class UI_EXPORT OSExchangeDataProviderAura : public OSExchangeData::Provider {
virtual void SetString(const string16& data) OVERRIDE;
virtual void SetURL(const GURL& url, const string16& title) OVERRIDE;
virtual void SetFilename(const FilePath& path) OVERRIDE;
- virtual void SetFilenames(const std::vector<FilePath>& paths) OVERRIDE;
+ virtual void SetFilenames(
+ const std::vector<OSExchangeData::FileInfo>& filenames) OVERRIDE;
virtual void SetPickledData(OSExchangeData::CustomFormat format,
const Pickle& data) OVERRIDE;
virtual bool GetString(string16* data) const OVERRIDE;
virtual bool GetURLAndTitle(GURL* url, string16* title) const OVERRIDE;
virtual bool GetFilename(FilePath* path) const OVERRIDE;
- virtual bool GetFilenames(std::vector<FilePath>* paths) const OVERRIDE;
+ virtual bool GetFilenames(
+ std::vector<OSExchangeData::FileInfo>* filenames) const OVERRIDE;
virtual bool GetPickledData(OSExchangeData::CustomFormat format,
Pickle* data) const OVERRIDE;
virtual bool HasString() const OVERRIDE;
@@ -83,7 +85,7 @@ class UI_EXPORT OSExchangeDataProviderAura : public OSExchangeData::Provider {
string16 title_;
// File name.
- std::vector<FilePath> filenames_;
+ std::vector<OSExchangeData::FileInfo> filenames_;
// PICKLED_DATA contents.
PickleData pickle_data_;
diff --git a/ui/base/dragdrop/os_exchange_data_provider_gtk.h b/ui/base/dragdrop/os_exchange_data_provider_gtk.h
index d336499..e43afbe 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_gtk.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_gtk.h
@@ -62,7 +62,8 @@ class UI_EXPORT OSExchangeDataProviderGtk : public OSExchangeData::Provider {
virtual void SetString(const string16& data) OVERRIDE;
virtual void SetURL(const GURL& url, const string16& title) OVERRIDE;
virtual void SetFilename(const FilePath& path) OVERRIDE;
- virtual void SetFilenames(const std::vector<FilePath>& path) OVERRIDE {
+ virtual void SetFilenames(
+ const std::vector<OSExchangeData::FileInfo>& filenames) OVERRIDE {
NOTREACHED();
}
virtual void SetPickledData(OSExchangeData::CustomFormat format,
@@ -70,7 +71,8 @@ class UI_EXPORT OSExchangeDataProviderGtk : public OSExchangeData::Provider {
virtual bool GetString(string16* data) const OVERRIDE;
virtual bool GetURLAndTitle(GURL* url, string16* title) const OVERRIDE;
virtual bool GetFilename(FilePath* path) const OVERRIDE;
- virtual bool GetFilenames(std::vector<FilePath>* paths) const OVERRIDE {
+ virtual bool GetFilenames(
+ std::vector<OSExchangeData::FileInfo>* filenames) const OVERRIDE {
NOTREACHED();
return false;
}
diff --git a/ui/base/dragdrop/os_exchange_data_provider_win.h b/ui/base/dragdrop/os_exchange_data_provider_win.h
index f48a70a..760719f 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_win.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_win.h
@@ -152,7 +152,8 @@ class UI_EXPORT OSExchangeDataProviderWin : public OSExchangeData::Provider {
virtual void SetString(const string16& data);
virtual void SetURL(const GURL& url, const string16& title);
virtual void SetFilename(const FilePath& path);
- virtual void SetFilenames(const std::vector<FilePath>& paths) {
+ virtual void SetFilenames(
+ const std::vector<OSExchangeData::FileInfo>& filenames) {
NOTREACHED();
}
virtual void SetPickledData(OSExchangeData::CustomFormat format,
@@ -164,7 +165,8 @@ class UI_EXPORT OSExchangeDataProviderWin : public OSExchangeData::Provider {
virtual bool GetString(string16* data) const;
virtual bool GetURLAndTitle(GURL* url, string16* title) const;
virtual bool GetFilename(FilePath* path) const;
- virtual bool GetFilenames(std::vector<FilePath>* paths) const {
+ virtual bool GetFilenames(
+ std::vector<OSExchangeData::FileInfo>* filenames) const {
NOTREACHED();
return false;
}