summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks/bookmark_drag_data.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 21:58:18 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 21:58:18 +0000
commit8c3dc79bc13ba84f418d3c135e1bf296a3e29722 (patch)
tree32eb9688d500a90eb74a7c4f8cb5a97e507dd0fc /chrome/browser/bookmarks/bookmark_drag_data.cc
parentabaccb2cb8cff8138e5ea9daf420645e5852c9eb (diff)
downloadchromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.zip
chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.gz
chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.bz2
Refactors OSExchangeData for easier portability.
BUG=none TEST=none Review URL: http://codereview.chromium.org/164401 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_drag_data.cc')
-rw-r--r--chrome/browser/bookmarks/bookmark_drag_data.cc56
1 files changed, 19 insertions, 37 deletions
diff --git a/chrome/browser/bookmarks/bookmark_drag_data.cc b/chrome/browser/bookmarks/bookmark_drag_data.cc
index 0ed2273..47ea0c0 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.cc
+++ b/chrome/browser/bookmarks/bookmark_drag_data.cc
@@ -13,29 +13,9 @@
#include "chrome/common/url_constants.h"
#include "chrome/browser/browser_process.h"
-// TODO(port): Port this file.
-#if defined(TOOLKIT_VIEWS)
-#include "app/os_exchange_data.h"
-#else
-#include "chrome/common/temp_scaffolding_stubs.h"
-#endif
-
const char* BookmarkDragData::kClipboardFormatString =
"chromium/x-bookmark-entries";
-#if defined(OS_WIN)
-static CLIPFORMAT clipboard_format = 0;
-
-static void RegisterFormat() {
- if (clipboard_format == 0) {
- clipboard_format =
- ::RegisterClipboardFormat(ASCIIToWide(
- BookmarkDragData::kClipboardFormatString).c_str());
- DCHECK(clipboard_format);
- }
-}
-#endif
-
BookmarkDragData::Element::Element(const BookmarkNode* node)
: is_url(node->is_url()),
url(node->GetURL()),
@@ -84,6 +64,21 @@ bool BookmarkDragData::Element::ReadFromPickle(Pickle* pickle,
return true;
}
+#if defined(TOOLKIT_VIEWS)
+// static
+OSExchangeData::CustomFormat BookmarkDragData::GetBookmarkCustomFormat() {
+ static OSExchangeData::CustomFormat format;
+ static bool format_valid = false;
+
+ if (!format_valid) {
+ format_valid = true;
+ format = OSExchangeData::RegisterCustomFormat(
+ BookmarkDragData::kClipboardFormatString);
+ }
+ return format;
+}
+#endif
+
BookmarkDragData::BookmarkDragData(const BookmarkNode* node) {
elements.push_back(Element(node));
}
@@ -139,10 +134,8 @@ bool BookmarkDragData::ReadFromClipboard() {
}
#endif // !defined(OS_MACOSX)
-#if defined(OS_WIN)
+#if defined(TOOLKIT_VIEWS)
void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const {
- RegisterFormat();
-
DCHECK(data);
// If there is only one element and it is a URL, write the URL to the
@@ -158,19 +151,17 @@ void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const {
Pickle data_pickle;
WriteToPickle(profile, &data_pickle);
- data->SetPickledData(clipboard_format, data_pickle);
+ data->SetPickledData(GetBookmarkCustomFormat(), data_pickle);
}
bool BookmarkDragData::Read(const OSExchangeData& data) {
- RegisterFormat();
-
elements.clear();
profile_path_.clear();
- if (data.HasFormat(clipboard_format)) {
+ if (data.HasCustomFormat(GetBookmarkCustomFormat())) {
Pickle drag_data_pickle;
- if (data.GetPickledData(clipboard_format, &drag_data_pickle)) {
+ if (data.GetPickledData(GetBookmarkCustomFormat(), &drag_data_pickle)) {
if (!ReadFromPickle(&drag_data_pickle))
return false;
}
@@ -186,15 +177,6 @@ bool BookmarkDragData::Read(const OSExchangeData& data) {
return is_valid();
}
-#elif defined(TOOLKIT_VIEWS)
-void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const {
- NOTIMPLEMENTED();
-}
-
-bool BookmarkDragData::Read(const OSExchangeData& data) {
- NOTIMPLEMENTED();
- return false;
-}
#endif
void BookmarkDragData::WriteToPickle(Profile* profile, Pickle* pickle) const {