summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 21:54:46 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 21:54:46 +0000
commit17ea0ae233fa0deef9df089ccfdf3b0760e8d015 (patch)
treed03e2cd509749dd487ffa70f3d09cba74d852568 /ui
parent01549ced5fff84743d84454723abba51264d70d2 (diff)
downloadchromium_src-17ea0ae233fa0deef9df089ccfdf3b0760e8d015.zip
chromium_src-17ea0ae233fa0deef9df089ccfdf3b0760e8d015.tar.gz
chromium_src-17ea0ae233fa0deef9df089ccfdf3b0760e8d015.tar.bz2
Use FilePaths in content::DropData to avoid redundant conversions.
BUG=none R=jam@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/211383007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/dragdrop/file_info.cc17
-rw-r--r--ui/base/dragdrop/file_info.h25
-rw-r--r--ui/base/dragdrop/os_exchange_data.cc9
-rw-r--r--ui/base/dragdrop/os_exchange_data.h13
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aura.cc7
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aura.h8
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aurax11.cc19
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aurax11.h6
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc3
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_win.cc8
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_win.h6
-rw-r--r--ui/base/ui_base.gyp2
12 files changed, 73 insertions, 50 deletions
diff --git a/ui/base/dragdrop/file_info.cc b/ui/base/dragdrop/file_info.cc
new file mode 100644
index 0000000..e5b894a
--- /dev/null
+++ b/ui/base/dragdrop/file_info.cc
@@ -0,0 +1,17 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/dragdrop/file_info.h"
+
+namespace ui {
+
+FileInfo::FileInfo() {}
+
+FileInfo::FileInfo(const base::FilePath& path,
+ const base::FilePath& display_name)
+ : path(path), display_name(display_name) {}
+
+FileInfo::~FileInfo() {}
+
+} // namespace ui
diff --git a/ui/base/dragdrop/file_info.h b/ui/base/dragdrop/file_info.h
new file mode 100644
index 0000000..6e4f456
--- /dev/null
+++ b/ui/base/dragdrop/file_info.h
@@ -0,0 +1,25 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_DRAGDROP_FILE_INFO_H_
+#define UI_BASE_DRAGDROP_FILE_INFO_H_
+
+#include "base/files/file_path.h"
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
+
+// struct that bundles a file's path with an optional display name.
+struct UI_BASE_EXPORT FileInfo {
+ FileInfo();
+ FileInfo(const base::FilePath& path, const base::FilePath& display_name);
+ ~FileInfo();
+
+ base::FilePath path;
+ base::FilePath display_name; // Optional.
+};
+
+} // namespace ui
+
+#endif // UI_BASE_DRAGDROP_FILE_INFO_H_
diff --git a/ui/base/dragdrop/os_exchange_data.cc b/ui/base/dragdrop/os_exchange_data.cc
index 096d202..64c8093 100644
--- a/ui/base/dragdrop/os_exchange_data.cc
+++ b/ui/base/dragdrop/os_exchange_data.cc
@@ -18,15 +18,6 @@ OSExchangeData::DownloadFileInfo::DownloadFileInfo(
OSExchangeData::DownloadFileInfo::~DownloadFileInfo() {}
-OSExchangeData::FileInfo::FileInfo(
- const base::FilePath& path,
- const base::FilePath& display_name)
- : path(path),
- display_name(display_name) {
-}
-
-OSExchangeData::FileInfo::~FileInfo() {}
-
OSExchangeData::OSExchangeData() : provider_(CreateProvider()) {
}
diff --git a/ui/base/dragdrop/os_exchange_data.h b/ui/base/dragdrop/os_exchange_data.h
index 40cc6a1..5a1cbd5 100644
--- a/ui/base/dragdrop/os_exchange_data.h
+++ b/ui/base/dragdrop/os_exchange_data.h
@@ -33,6 +33,8 @@ class Vector2d;
namespace ui {
+struct FileInfo;
+
///////////////////////////////////////////////////////////////////////////////
//
// OSExchangeData
@@ -82,17 +84,6 @@ class UI_BASE_EXPORT OSExchangeData {
scoped_refptr<DownloadFileProvider> downloader;
};
- // Encapsulates the info about a file.
- struct UI_BASE_EXPORT FileInfo {
- FileInfo(const base::FilePath& path, const base::FilePath& display_name);
- ~FileInfo();
-
- // The path of the file.
- base::FilePath path;
- // The display name of the file. This field is optional.
- base::FilePath display_name;
- };
-
// Provider defines the platform specific part of OSExchangeData that
// interacts with the native system.
class UI_BASE_EXPORT Provider {
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.cc b/ui/base/dragdrop/os_exchange_data_provider_aura.cc
index efe4e42..2a44793 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aura.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aura.cc
@@ -9,6 +9,7 @@
#include "net/base/net_util.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
+#include "ui/base/dragdrop/file_info.h"
namespace ui {
@@ -58,12 +59,12 @@ void OSExchangeDataProviderAura::SetURL(const GURL& url,
void OSExchangeDataProviderAura::SetFilename(const base::FilePath& path) {
filenames_.clear();
- filenames_.push_back(OSExchangeData::FileInfo(path, base::FilePath()));
+ filenames_.push_back(FileInfo(path, base::FilePath()));
formats_ |= OSExchangeData::FILE_NAME;
}
void OSExchangeDataProviderAura::SetFilenames(
- const std::vector<OSExchangeData::FileInfo>& filenames) {
+ const std::vector<FileInfo>& filenames) {
filenames_ = filenames;
formats_ |= OSExchangeData::FILE_NAME;
}
@@ -109,7 +110,7 @@ bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const {
}
bool OSExchangeDataProviderAura::GetFilenames(
- std::vector<OSExchangeData::FileInfo>* filenames) const {
+ std::vector<FileInfo>* filenames) const {
if ((formats_ & OSExchangeData::FILE_NAME) == 0)
return false;
*filenames = filenames_;
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.h b/ui/base/dragdrop/os_exchange_data_provider_aura.h
index 98438bd..e54a2fd 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aura.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_aura.h
@@ -32,8 +32,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAura
virtual void SetString(const base::string16& data) OVERRIDE;
virtual void SetURL(const GURL& url, const base::string16& title) OVERRIDE;
virtual void SetFilename(const base::FilePath& path) OVERRIDE;
- virtual void SetFilenames(
- const std::vector<OSExchangeData::FileInfo>& filenames) OVERRIDE;
+ virtual void SetFilenames(const std::vector<FileInfo>& filenames) OVERRIDE;
virtual void SetPickledData(const OSExchangeData::CustomFormat& format,
const Pickle& data) OVERRIDE;
virtual bool GetString(base::string16* data) const OVERRIDE;
@@ -41,8 +40,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAura
GURL* url,
base::string16* title) const OVERRIDE;
virtual bool GetFilename(base::FilePath* path) const OVERRIDE;
- virtual bool GetFilenames(
- std::vector<OSExchangeData::FileInfo>* filenames) const OVERRIDE;
+ virtual bool GetFilenames(std::vector<FileInfo>* filenames) const OVERRIDE;
virtual bool GetPickledData(const OSExchangeData::CustomFormat& format,
Pickle* data) const OVERRIDE;
virtual bool HasString() const OVERRIDE;
@@ -80,7 +78,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAura
base::string16 title_;
// File name.
- std::vector<OSExchangeData::FileInfo> filenames_;
+ std::vector<FileInfo> filenames_;
// PICKLED_DATA contents.
PickleData pickle_data_;
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
index 47c5dac..2f013ec 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
@@ -12,6 +12,7 @@
#include "net/base/net_util.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
+#include "ui/base/dragdrop/file_info.h"
#include "ui/base/x/selection_utils.h"
#include "ui/base/x/x11_util.h"
@@ -170,16 +171,17 @@ void OSExchangeDataProviderAuraX11::SetURL(const GURL& url,
}
void OSExchangeDataProviderAuraX11::SetFilename(const base::FilePath& path) {
- std::vector<OSExchangeData::FileInfo> data;
- data.push_back(OSExchangeData::FileInfo(path, base::FilePath()));
+ std::vector<FileInfo> data;
+ data.push_back(FileInfo(path, base::FilePath()));
SetFilenames(data);
}
void OSExchangeDataProviderAuraX11::SetFilenames(
- const std::vector<OSExchangeData::FileInfo>& filenames) {
+ const std::vector<FileInfo>& filenames) {
std::vector<std::string> paths;
- for (std::vector<OSExchangeData::FileInfo>::const_iterator it =
- filenames.begin(); it != filenames.end(); ++it) {
+ for (std::vector<FileInfo>::const_iterator it = filenames.begin();
+ it != filenames.end();
+ ++it) {
std::string url_spec = net::FilePathToFileURL(it->path).spec();
if (!url_spec.empty())
paths.push_back(url_spec);
@@ -277,7 +279,7 @@ bool OSExchangeDataProviderAuraX11::GetURLAndTitle(
}
bool OSExchangeDataProviderAuraX11::GetFilename(base::FilePath* path) const {
- std::vector<OSExchangeData::FileInfo> filenames;
+ std::vector<FileInfo> filenames;
if (GetFilenames(&filenames)) {
*path = filenames.front().path;
return true;
@@ -287,7 +289,7 @@ bool OSExchangeDataProviderAuraX11::GetFilename(base::FilePath* path) const {
}
bool OSExchangeDataProviderAuraX11::GetFilenames(
- std::vector<OSExchangeData::FileInfo>* filenames) const {
+ std::vector<FileInfo>* filenames) const {
std::vector< ::Atom> url_atoms = ui::GetURIListAtomsFrom(&atom_cache_);
std::vector< ::Atom> requested_types;
ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types);
@@ -301,8 +303,7 @@ bool OSExchangeDataProviderAuraX11::GetFilenames(
GURL url(*it);
base::FilePath file_path;
if (url.SchemeIsFile() && net::FileURLToFilePath(url, &file_path)) {
- filenames->push_back(OSExchangeData::FileInfo(file_path,
- base::FilePath()));
+ filenames->push_back(FileInfo(file_path, base::FilePath()));
}
}
}
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11.h b/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
index 64cfee1..40c0deb 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
@@ -67,8 +67,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAuraX11
virtual void SetString(const base::string16& data) OVERRIDE;
virtual void SetURL(const GURL& url, const base::string16& title) OVERRIDE;
virtual void SetFilename(const base::FilePath& path) OVERRIDE;
- virtual void SetFilenames(
- const std::vector<OSExchangeData::FileInfo>& filenames) OVERRIDE;
+ virtual void SetFilenames(const std::vector<FileInfo>& filenames) OVERRIDE;
virtual void SetPickledData(const OSExchangeData::CustomFormat& format,
const Pickle& pickle) OVERRIDE;
virtual bool GetString(base::string16* data) const OVERRIDE;
@@ -76,8 +75,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAuraX11
GURL* url,
base::string16* title) const OVERRIDE;
virtual bool GetFilename(base::FilePath* path) const OVERRIDE;
- virtual bool GetFilenames(
- std::vector<OSExchangeData::FileInfo>* filenames) const OVERRIDE;
+ virtual bool GetFilenames(std::vector<FileInfo>* filenames) const OVERRIDE;
virtual bool GetPickledData(const OSExchangeData::CustomFormat& format,
Pickle* pickle) const OVERRIDE;
virtual bool HasString() const OVERRIDE;
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
index b62e0d9..1601007 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
@@ -12,6 +12,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/dragdrop/file_info.h"
#include "url/gurl.h"
const char kFileURL[] = "file:///home/user/file.txt";
@@ -88,7 +89,7 @@ TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) {
EXPECT_TRUE(provider.HasURL(ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES));
// We should only receive the file from GetFilenames().
- std::vector<OSExchangeData::FileInfo> filenames;
+ std::vector<FileInfo> filenames;
EXPECT_TRUE(provider.GetFilenames(&filenames));
ASSERT_EQ(1u, filenames.size());
EXPECT_EQ(kFileName, filenames[0].path.value());
diff --git a/ui/base/dragdrop/os_exchange_data_provider_win.cc b/ui/base/dragdrop/os_exchange_data_provider_win.cc
index 487b6c2..e4f117e 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_win.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_win.cc
@@ -18,6 +18,7 @@
#include "net/base/net_util.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/clipboard_util_win.h"
+#include "ui/base/dragdrop/file_info.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
@@ -352,7 +353,7 @@ void OSExchangeDataProviderWin::SetFilename(const base::FilePath& path) {
}
void OSExchangeDataProviderWin::SetFilenames(
- const std::vector<OSExchangeData::FileInfo>& filenames) {
+ const std::vector<FileInfo>& filenames) {
for (size_t i = 0; i < filenames.size(); ++i) {
STGMEDIUM* storage = GetStorageForFileName(filenames[i].path);
DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo(
@@ -439,14 +440,13 @@ bool OSExchangeDataProviderWin::GetFilename(base::FilePath* path) const {
}
bool OSExchangeDataProviderWin::GetFilenames(
- std::vector<OSExchangeData::FileInfo>* filenames) const {
+ std::vector<FileInfo>* filenames) const {
std::vector<base::string16> filenames_local;
bool success = ClipboardUtil::GetFilenames(source_object_, &filenames_local);
if (success) {
for (size_t i = 0; i < filenames_local.size(); ++i)
filenames->push_back(
- OSExchangeData::FileInfo(base::FilePath(filenames_local[i]),
- base::FilePath()));
+ FileInfo(base::FilePath(filenames_local[i]), base::FilePath()));
}
return success;
}
diff --git a/ui/base/dragdrop/os_exchange_data_provider_win.h b/ui/base/dragdrop/os_exchange_data_provider_win.h
index 969fb3a..ffe37e7 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_win.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_win.h
@@ -154,8 +154,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderWin
virtual void SetString(const base::string16& data);
virtual void SetURL(const GURL& url, const base::string16& title);
virtual void SetFilename(const base::FilePath& path);
- virtual void SetFilenames(
- const std::vector<OSExchangeData::FileInfo>& filenames);
+ virtual void SetFilenames(const std::vector<FileInfo>& filenames);
virtual void SetPickledData(const OSExchangeData::CustomFormat& format,
const Pickle& data);
virtual void SetFileContents(const base::FilePath& filename,
@@ -167,8 +166,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderWin
GURL* url,
base::string16* title) const;
virtual bool GetFilename(base::FilePath* path) const;
- virtual bool GetFilenames(
- std::vector<OSExchangeData::FileInfo>* filenames) const;
+ virtual bool GetFilenames(std::vector<FileInfo>* filenames) const;
virtual bool GetPickledData(const OSExchangeData::CustomFormat& format,
Pickle* data) const;
virtual bool GetFileContents(base::FilePath* filename,
diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp
index f14593a..16737cb 100644
--- a/ui/base/ui_base.gyp
+++ b/ui/base/ui_base.gyp
@@ -160,6 +160,8 @@
'dragdrop/drop_target_event.h',
'dragdrop/drop_target_win.cc',
'dragdrop/drop_target_win.h',
+ 'dragdrop/file_info.cc',
+ 'dragdrop/file_info.h',
'dragdrop/gtk_dnd_util.cc',
'dragdrop/gtk_dnd_util.h',
'dragdrop/os_exchange_data.cc',