diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 22:32:14 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 22:32:14 +0000 |
commit | e376aa74c136126e808c5865ef0cf24ed2a999f7 (patch) | |
tree | 7ed827aa673771bb3544d413e3481c703d85ead9 | |
parent | 7ea7b4d941823d799fd6e0c1d8bee537c624425a (diff) | |
download | chromium_src-e376aa74c136126e808c5865ef0cf24ed2a999f7.zip chromium_src-e376aa74c136126e808c5865ef0cf24ed2a999f7.tar.gz chromium_src-e376aa74c136126e808c5865ef0cf24ed2a999f7.tar.bz2 |
Remove Clipboard::WriteFile{,s} which is unused on mac and windows and unimplemented on linux.
BUG=18037
TEST=trybots
Review URL: http://codereview.chromium.org/292018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31148 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | app/clipboard/clipboard.cc | 4 | ||||
-rw-r--r-- | app/clipboard/clipboard.h | 2 | ||||
-rw-r--r-- | app/clipboard/clipboard_linux.cc | 4 | ||||
-rw-r--r-- | app/clipboard/clipboard_mac.mm | 25 | ||||
-rw-r--r-- | app/clipboard/clipboard_unittest.cc | 57 | ||||
-rw-r--r-- | app/clipboard/clipboard_win.cc | 23 | ||||
-rw-r--r-- | app/clipboard/scoped_clipboard_writer.cc | 38 | ||||
-rw-r--r-- | app/clipboard/scoped_clipboard_writer.h | 4 |
8 files changed, 0 insertions, 157 deletions
diff --git a/app/clipboard/clipboard.cc b/app/clipboard/clipboard.cc index 0b5d919..9c13010 100644 --- a/app/clipboard/clipboard.cc +++ b/app/clipboard/clipboard.cc @@ -38,10 +38,6 @@ void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) { &(params[1].front()), params[1].size()); break; - case CBF_FILES: - WriteFiles(&(params[0].front()), params[0].size()); - break; - case CBF_WEBKIT: WriteWebSmartPaste(); break; diff --git a/app/clipboard/clipboard.h b/app/clipboard/clipboard.h index 61e8b96..80a35e6 100644 --- a/app/clipboard/clipboard.h +++ b/app/clipboard/clipboard.h @@ -191,8 +191,6 @@ class Clipboard { void WriteWebSmartPaste(); - void WriteFiles(const char* file_data, size_t file_len); - void WriteBitmap(const char* pixel_data, const char* size_data); #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_FREEBSD) diff --git a/app/clipboard/clipboard_linux.cc b/app/clipboard/clipboard_linux.cc index 4e2a241..f06b9b2 100644 --- a/app/clipboard/clipboard_linux.cc +++ b/app/clipboard/clipboard_linux.cc @@ -204,10 +204,6 @@ void Clipboard::WriteBookmark(const char* title_data, size_t title_len, InsertMapping(kMimeURI, data, url_len + 1); } -void Clipboard::WriteFiles(const char* file_data, size_t file_len) { - NOTIMPLEMENTED(); -} - void Clipboard::WriteData(const char* format_name, size_t format_len, const char* data_data, size_t data_len) { char* data = new char[data_len]; diff --git a/app/clipboard/clipboard_mac.mm b/app/clipboard/clipboard_mac.mm index 990f5d0..ae3f1fe 100644 --- a/app/clipboard/clipboard_mac.mm +++ b/app/clipboard/clipboard_mac.mm @@ -98,31 +98,6 @@ void Clipboard::WriteBookmark(const char* title_data, [pb setString:title forType:kUTTypeURLName]; } -void Clipboard::WriteFiles(const char* file_data, size_t file_len) { - NSMutableArray* fileList = [NSMutableArray arrayWithCapacity:1]; - - // Offset of current filename from start of file_data array. - size_t current_filename_offset = 0; - - // file_data is double null terminated (see table at top of clipboard.h). - // So this loop can ignore the second null terminator, thus file_len - 1. - // TODO(playmobil): If we need a loop like this on other platforms then split - // this out into a common function that outputs a std::vector<const char*>. - for (size_t i = 0; i < file_len - 1; ++i) { - if (file_data[i] == '\0') { - const char* filename = &file_data[current_filename_offset]; - [fileList addObject:[NSString stringWithUTF8String:filename]]; - - current_filename_offset = i + 1; - continue; - } - } - - NSPasteboard* pb = GetPasteboard(); - [pb addTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil]; - [pb setPropertyList:fileList forType:NSFilenamesPboardType]; -} - void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); diff --git a/app/clipboard/clipboard_unittest.cc b/app/clipboard/clipboard_unittest.cc index e4f288a..84cc69c 100644 --- a/app/clipboard/clipboard_unittest.cc +++ b/app/clipboard/clipboard_unittest.cc @@ -170,63 +170,6 @@ TEST_F(ClipboardTest, MultiFormatTest) { EXPECT_EQ(UTF16ToUTF8(text), ascii_text); } -// TODO(estade): Port the following tests (decide what targets we use for files) -#if !defined(OS_LINUX) -// Files for this test don't actually need to exist on the file system, just -// don't try to use a non-existent file you've retrieved from the clipboard. -TEST_F(ClipboardTest, FileTest) { - Clipboard clipboard; -#if defined(OS_WIN) - FilePath file(L"C:\\Downloads\\My Downloads\\A Special File.txt"); -#elif defined(OS_MACOSX) - // OS X will print a warning message if we stick a non-existant file on the - // clipboard. - FilePath file("/usr/bin/make"); -#endif // defined(OS_MACOSX) - - { - ScopedClipboardWriter clipboard_writer(&clipboard); - clipboard_writer.WriteFile(file); - } - - FilePath out_file; - clipboard.ReadFile(&out_file); - EXPECT_EQ(file.value(), out_file.value()); -} - -TEST_F(ClipboardTest, MultipleFilesTest) { - Clipboard clipboard; - -#if defined(OS_WIN) - FilePath file1(L"C:\\Downloads\\My Downloads\\File 1.exe"); - FilePath file2(L"C:\\Downloads\\My Downloads\\File 2.pdf"); - FilePath file3(L"C:\\Downloads\\My Downloads\\File 3.doc"); -#elif defined(OS_MACOSX) - // OS X will print a warning message if we stick a non-existant file on the - // clipboard. - FilePath file1("/usr/bin/make"); - FilePath file2("/usr/bin/man"); - FilePath file3("/usr/bin/perl"); -#endif // defined(OS_MACOSX) - std::vector<FilePath> files; - files.push_back(file1); - files.push_back(file2); - files.push_back(file3); - - { - ScopedClipboardWriter clipboard_writer(&clipboard); - clipboard_writer.WriteFiles(files); - } - - std::vector<FilePath> out_files; - clipboard.ReadFiles(&out_files); - - EXPECT_EQ(files.size(), out_files.size()); - for (size_t i = 0; i < out_files.size(); ++i) - EXPECT_EQ(files[i].value(), out_files[i].value()); -} -#endif // !defined(OS_LINUX) - TEST_F(ClipboardTest, URLTest) { Clipboard clipboard; diff --git a/app/clipboard/clipboard_win.cc b/app/clipboard/clipboard_win.cc index 288c820..9074fc5 100644 --- a/app/clipboard/clipboard_win.cc +++ b/app/clipboard/clipboard_win.cc @@ -329,29 +329,6 @@ void Clipboard::WriteBitmapFromHandle(HBITMAP source_hbitmap, WriteToClipboard(CF_BITMAP, hbitmap); } -// Write a file or set of files to the clipboard in HDROP format. When the user -// invokes a paste command (in a Windows explorer shell, for example), the files -// will be copied to the paste location. -void Clipboard::WriteFiles(const char* file_data, size_t file_len) { - // Calculate the amount of space we'll need store the strings and - // a DROPFILES struct. - size_t bytes = sizeof(DROPFILES) + file_len; - - HANDLE hdata = ::GlobalAlloc(GMEM_MOVEABLE, bytes); - if (!hdata) - return; - - char* data = static_cast<char*>(::GlobalLock(hdata)); - DROPFILES* drop_files = reinterpret_cast<DROPFILES*>(data); - drop_files->pFiles = sizeof(DROPFILES); - drop_files->fWide = TRUE; - - memcpy(data + sizeof(DROPFILES), file_data, file_len); - - ::GlobalUnlock(hdata); - WriteToClipboard(CF_HDROP, hdata); -} - void Clipboard::WriteData(const char* format_name, size_t format_len, const char* data_data, size_t data_len) { std::string format(format_name, format_len); diff --git a/app/clipboard/scoped_clipboard_writer.cc b/app/clipboard/scoped_clipboard_writer.cc index 8c51afe..ec9dd0a 100644 --- a/app/clipboard/scoped_clipboard_writer.cc +++ b/app/clipboard/scoped_clipboard_writer.cc @@ -79,44 +79,6 @@ void ScopedClipboardWriter::WriteHyperlink(const std::string& anchor_text, WriteHTML(UTF8ToUTF16(html), std::string()); } -void ScopedClipboardWriter::WriteFile(const FilePath& file) { - WriteFiles(std::vector<FilePath>(1, file)); -} - -// Save the filenames as a string separated by nulls and terminated with an -// extra null. -void ScopedClipboardWriter::WriteFiles(const std::vector<FilePath>& files) { - if (files.empty()) - return; - - Clipboard::ObjectMapParam parameter; - - for (std::vector<FilePath>::const_iterator iter = files.begin(); - iter != files.end(); ++iter) { - FilePath filepath = *iter; - FilePath::StringType filename = filepath.value(); - - size_t data_length = filename.length() * sizeof(FilePath::CharType); - const char* data = reinterpret_cast<const char*>(filename.data()); - const char* data_end = data + data_length; - - for (const char* ch = data; ch < data_end; ++ch) - parameter.push_back(*ch); - - // NUL-terminate the string. - for (size_t i = 0; i < sizeof(FilePath::CharType); ++i) - parameter.push_back('\0'); - } - - // NUL-terminate the string list. - for (size_t i = 0; i < sizeof(FilePath::CharType); ++i) - parameter.push_back('\0'); - - Clipboard::ObjectMapParams parameters; - parameters.push_back(parameter); - objects_[Clipboard::CBF_FILES] = parameters; -} - void ScopedClipboardWriter::WriteWebSmartPaste() { objects_[Clipboard::CBF_WEBKIT] = Clipboard::ObjectMapParams(); } diff --git a/app/clipboard/scoped_clipboard_writer.h b/app/clipboard/scoped_clipboard_writer.h index 4876a00..2dc30ea 100644 --- a/app/clipboard/scoped_clipboard_writer.h +++ b/app/clipboard/scoped_clipboard_writer.h @@ -50,10 +50,6 @@ class ScopedClipboardWriter { // be escaped prior to being passed in. void WriteHyperlink(const std::string& anchor_text, const std::string& url); - // Adds a file or group of files to the clipboard. - void WriteFile(const FilePath& file); - void WriteFiles(const std::vector<FilePath>& files); - // Used by WebKit to determine whether WebKit wrote the clipboard last void WriteWebSmartPaste(); |