summaryrefslogtreecommitdiffstats
path: root/base/clipboard.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 01:34:30 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 01:34:30 +0000
commit3ee3ffd1d79a0c1544f3bfd70c7de7606df9482f (patch)
tree0943a0925f5974478463e5d00886be29109858e6 /base/clipboard.cc
parent38733063b7e1cf0b6e67c0b590773ff4f1aaa18d (diff)
downloadchromium_src-3ee3ffd1d79a0c1544f3bfd70c7de7606df9482f.zip
chromium_src-3ee3ffd1d79a0c1544f3bfd70c7de7606df9482f.tar.gz
chromium_src-3ee3ffd1d79a0c1544f3bfd70c7de7606df9482f.tar.bz2
Rewrote the clipboard API to be more concurrent. Added a helper class to make it more foolproof. Updated all clients and unittests. Mac port by jeremy@chromium.org
Review URL: http://codereview.chromium.org/9154 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/clipboard.cc')
-rw-r--r--base/clipboard.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/base/clipboard.cc b/base/clipboard.cc
new file mode 100644
index 0000000..d3ec589
--- /dev/null
+++ b/base/clipboard.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2006-2008 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.
+
+// Many of these functions are based on those found in
+// webkit/port/platform/PasteboardWin.cpp
+
+#include "base/clipboard.h"
+
+#include "base/logging.h"
+
+void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
+ switch (type) {
+ case CBF_TEXT:
+ WriteText(&(params[0].front()), params[0].size());
+ break;
+
+ case CBF_HTML:
+ if (params.size() == 2)
+ WriteHTML(&(params[0].front()), params[0].size(),
+ &(params[1].front()), params[1].size());
+ else
+ WriteHTML(&(params[0].front()), params[0].size(), NULL, 0);
+ break;
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ case CBF_BOOKMARK:
+ WriteBookmark(&(params[0].front()), params[0].size(),
+ &(params[1].front()), params[1].size());
+ break;
+
+ case CBF_LINK:
+ WriteHyperlink(&(params[0].front()), params[0].size(),
+ &(params[1].front()), params[1].size());
+ break;
+
+ case CBF_FILES:
+ WriteFiles(&(params[0].front()), params[0].size());
+ break;
+#endif // defined(OS_WIN) || defined(OS_MACOSX)
+
+#if defined(OS_WIN)
+ case CBF_WEBKIT:
+ WriteWebSmartPaste();
+ break;
+
+ case CBF_BITMAP:
+ WriteBitmap(&(params[0].front()), &(params[1].front()));
+ break;
+#endif // defined(OS_WIN)
+
+ default:
+ NOTREACHED();
+ }
+}