diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-07 20:28:24 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-07 20:28:24 +0000 |
commit | b85621f02611f379c153d1e95b26c789730d4ef2 (patch) | |
tree | b728a259f80c20af849c4cd58cbaad3043f2c608 /ui | |
parent | c062218b21e639e2c3b8a662ae89e4275bea54aa (diff) | |
download | chromium_src-b85621f02611f379c153d1e95b26c789730d4ef2.zip chromium_src-b85621f02611f379c153d1e95b26c789730d4ef2.tar.gz chromium_src-b85621f02611f379c153d1e95b26c789730d4ef2.tar.bz2 |
OSExchangeData: convert filename-related API to FilePath
BUG=23581
Review URL: http://codereview.chromium.org/6368133
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/dragdrop/os_exchange_data.cc | 8 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data.h | 9 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_gtk.cc | 8 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_gtk.h | 7 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_win.cc | 24 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_win.h | 4 |
6 files changed, 30 insertions, 30 deletions
diff --git a/ui/base/dragdrop/os_exchange_data.cc b/ui/base/dragdrop/os_exchange_data.cc index e5701c3..a655a900 100644 --- a/ui/base/dragdrop/os_exchange_data.cc +++ b/ui/base/dragdrop/os_exchange_data.cc @@ -35,8 +35,8 @@ void OSExchangeData::SetURL(const GURL& url, const std::wstring& title) { provider_->SetURL(url, title); } -void OSExchangeData::SetFilename(const std::wstring& full_path) { - provider_->SetFilename(full_path); +void OSExchangeData::SetFilename(const FilePath& path) { + provider_->SetFilename(path); } void OSExchangeData::SetPickledData(CustomFormat format, const Pickle& data) { @@ -51,8 +51,8 @@ bool OSExchangeData::GetURLAndTitle(GURL* url, std::wstring* title) const { return provider_->GetURLAndTitle(url, title); } -bool OSExchangeData::GetFilename(std::wstring* full_path) const { - return provider_->GetFilename(full_path); +bool OSExchangeData::GetFilename(FilePath* path) const { + return provider_->GetFilename(path); } 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 452252e..f1db906 100644 --- a/ui/base/dragdrop/os_exchange_data.h +++ b/ui/base/dragdrop/os_exchange_data.h @@ -82,12 +82,12 @@ class OSExchangeData { virtual void SetString(const std::wstring& data) = 0; virtual void SetURL(const GURL& url, const std::wstring& title) = 0; - virtual void SetFilename(const std::wstring& full_path) = 0; + virtual void SetFilename(const FilePath& path) = 0; virtual void SetPickledData(CustomFormat format, const Pickle& data) = 0; virtual bool GetString(std::wstring* data) const = 0; virtual bool GetURLAndTitle(GURL* url, std::wstring* title) const = 0; - virtual bool GetFilename(std::wstring* full_path) const = 0; + virtual bool GetFilename(FilePath* path) const = 0; virtual bool GetPickledData(CustomFormat format, Pickle* data) const = 0; virtual bool HasString() const = 0; @@ -137,8 +137,7 @@ class OSExchangeData { // A URL can have an optional title in some exchange formats. void SetURL(const GURL& url, const std::wstring& title); // A full path to a file. - // TODO: convert to Filepath. - void SetFilename(const std::wstring& full_path); + void SetFilename(const FilePath& path); // Adds pickled data of the specified format. void SetPickledData(CustomFormat format, const Pickle& data); @@ -149,7 +148,7 @@ class OSExchangeData { bool GetString(std::wstring* data) const; bool GetURLAndTitle(GURL* url, std::wstring* title) const; // Return the path of a file, if available. - bool GetFilename(std::wstring* full_path) const; + bool GetFilename(FilePath* path) 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_gtk.cc b/ui/base/dragdrop/os_exchange_data_provider_gtk.cc index 892bd48..cc27d05 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_gtk.cc +++ b/ui/base/dragdrop/os_exchange_data_provider_gtk.cc @@ -137,8 +137,8 @@ void OSExchangeDataProviderGtk::SetURL(const GURL& url, formats_ |= OSExchangeData::URL; } -void OSExchangeDataProviderGtk::SetFilename(const std::wstring& full_path) { - filename_ = WideToUTF8(full_path); +void OSExchangeDataProviderGtk::SetFilename(const FilePath& path) { + filename_ = path; formats_ |= OSExchangeData::FILE_NAME; } @@ -170,10 +170,10 @@ bool OSExchangeDataProviderGtk::GetURLAndTitle(GURL* url, return true; } -bool OSExchangeDataProviderGtk::GetFilename(std::wstring* full_path) const { +bool OSExchangeDataProviderGtk::GetFilename(FilePath* path) const { if ((formats_ & OSExchangeData::FILE_NAME) == 0) return false; - *full_path = UTF8ToWide(filename_); + *path = filename_; return true; } diff --git a/ui/base/dragdrop/os_exchange_data_provider_gtk.h b/ui/base/dragdrop/os_exchange_data_provider_gtk.h index e87acac..b90bd89b 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_gtk.h +++ b/ui/base/dragdrop/os_exchange_data_provider_gtk.h @@ -11,6 +11,7 @@ #include <set> #include <string> +#include "base/file_path.h" #include "base/pickle.h" #include "base/string16.h" #include "googleurl/src/gurl.h" @@ -59,12 +60,12 @@ class OSExchangeDataProviderGtk : public OSExchangeData::Provider { // Provider methods. virtual void SetString(const std::wstring& data); virtual void SetURL(const GURL& url, const std::wstring& title); - virtual void SetFilename(const std::wstring& full_path); + virtual void SetFilename(const FilePath& path); virtual void SetPickledData(OSExchangeData::CustomFormat format, const Pickle& data); virtual bool GetString(std::wstring* data) const; virtual bool GetURLAndTitle(GURL* url, std::wstring* title) const; - virtual bool GetFilename(std::wstring* full_path) const; + virtual bool GetFilename(FilePath* path) const; virtual bool GetPickledData(OSExchangeData::CustomFormat format, Pickle* data) const; virtual bool HasString() const; @@ -103,7 +104,7 @@ class OSExchangeDataProviderGtk : public OSExchangeData::Provider { string16 title_; // File name. - std::string filename_; + FilePath filename_; // PICKLED_DATA contents. PickleData pickle_data_; diff --git a/ui/base/dragdrop/os_exchange_data_provider_win.cc b/ui/base/dragdrop/os_exchange_data_provider_win.cc index 22a4e62..fb5c496 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_win.cc +++ b/ui/base/dragdrop/os_exchange_data_provider_win.cc @@ -33,7 +33,7 @@ static void CreateValidFileNameFromTitle(const GURL& url, const std::wstring& title, std::wstring* validated); // Creates a new STGMEDIUM object to hold a file. -static STGMEDIUM* GetStorageForFileName(const std::wstring& full_path); +static STGMEDIUM* GetStorageForFileName(const FilePath& path); // Creates a File Descriptor for the creation of a file to the given URL and // returns a handle to it. static STGMEDIUM* GetStorageForFileDescriptor( @@ -318,8 +318,8 @@ void OSExchangeDataProviderWin::SetURL(const GURL& url, new DataObjectImpl::StoredDataInfo(CF_TEXT, storage)); } -void OSExchangeDataProviderWin::SetFilename(const std::wstring& full_path) { - STGMEDIUM* storage = GetStorageForFileName(full_path); +void OSExchangeDataProviderWin::SetFilename(const FilePath& path) { + STGMEDIUM* storage = GetStorageForFileName(path); DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo(CF_HDROP, storage); data_->contents_.push_back(info); @@ -386,11 +386,11 @@ bool OSExchangeDataProviderWin::GetURLAndTitle(GURL* url, return false; } -bool OSExchangeDataProviderWin::GetFilename(std::wstring* full_path) const { +bool OSExchangeDataProviderWin::GetFilename(FilePath* path) const { std::vector<std::wstring> filenames; bool success = ClipboardUtil::GetFilenames(source_object_, &filenames); if (success) - full_path->assign(filenames[0]); + *path = FilePath(filenames[0]); return success; } @@ -463,7 +463,7 @@ void OSExchangeDataProviderWin::SetDownloadFileInfo( // the delay rendering will be used. STGMEDIUM* storage = NULL; if (!download.filename.empty()) - storage = GetStorageForFileName(download.filename.value()); + storage = GetStorageForFileName(download.filename); // Add CF_HDROP. DataObjectImpl::StoredDataInfo* info = new DataObjectImpl::StoredDataInfo( @@ -583,7 +583,7 @@ void DataObjectImpl::OnDownloadCompleted(const FilePath& file_path) { // Update the storage. (*iter)->owns_medium = true; - (*iter)->medium = GetStorageForFileName(file_path.value()); + (*iter)->medium = GetStorageForFileName(file_path); break; } @@ -862,10 +862,10 @@ static void CreateValidFileNameFromTitle(const GURL& url, *validated += extension; } -static STGMEDIUM* GetStorageForFileName(const std::wstring& full_path) { +static STGMEDIUM* GetStorageForFileName(const FilePath& path) { const size_t kDropSize = sizeof(DROPFILES); const size_t kTotalBytes = - kDropSize + (full_path.length() + 2) * sizeof(wchar_t); + kDropSize + (path.value().length() + 2) * sizeof(wchar_t); HANDLE hdata = GlobalAlloc(GMEM_MOVEABLE, kTotalBytes); base::win::ScopedHGlobal<DROPFILES> locked_mem(hdata); @@ -874,9 +874,9 @@ static STGMEDIUM* GetStorageForFileName(const std::wstring& full_path) { drop_files->fWide = TRUE; wchar_t* data = reinterpret_cast<wchar_t*>( reinterpret_cast<BYTE*>(drop_files) + kDropSize); - const size_t copy_size = (full_path.length() + 1) * sizeof(wchar_t); - memcpy(data, full_path.c_str(), copy_size); - data[full_path.length() + 1] = L'\0'; // Double NULL + const size_t copy_size = (path.value().length() + 1) * sizeof(wchar_t); + memcpy(data, path.value().c_str(), copy_size); + data[path.value().length() + 1] = L'\0'; // Double NULL STGMEDIUM* storage = new STGMEDIUM; storage->tymed = TYMED_HGLOBAL; diff --git a/ui/base/dragdrop/os_exchange_data_provider_win.h b/ui/base/dragdrop/os_exchange_data_provider_win.h index dc888bd..7aba9ca 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_win.h +++ b/ui/base/dragdrop/os_exchange_data_provider_win.h @@ -144,7 +144,7 @@ class OSExchangeDataProviderWin : public OSExchangeData::Provider { // OSExchangeData::Provider methods. virtual void SetString(const std::wstring& data); virtual void SetURL(const GURL& url, const std::wstring& title); - virtual void SetFilename(const std::wstring& full_path); + virtual void SetFilename(const FilePath& path); virtual void SetPickledData(OSExchangeData::CustomFormat format, const Pickle& data); virtual void SetFileContents(const std::wstring& filename, @@ -153,7 +153,7 @@ class OSExchangeDataProviderWin : public OSExchangeData::Provider { virtual bool GetString(std::wstring* data) const; virtual bool GetURLAndTitle(GURL* url, std::wstring* title) const; - virtual bool GetFilename(std::wstring* full_path) const; + virtual bool GetFilename(FilePath* path) const; virtual bool GetPickledData(OSExchangeData::CustomFormat format, Pickle* data) const; virtual bool GetFileContents(std::wstring* filename, |