summaryrefslogtreecommitdiffstats
path: root/base/clipboard.cc
blob: 60851e2746c9d1d9b4b32dde974df33c26d93289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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.

#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;

    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;

    case CBF_WEBKIT:
      WriteWebSmartPaste();
      break;

#if defined(OS_WIN) || defined(OS_LINUX)  // This is just a stub on Linux
    case CBF_BITMAP:
      WriteBitmap(&(params[0].front()), &(params[1].front()));
      break;
#endif  // defined(OS_WIN) || defined(OS_LINUX)

    default:
      NOTREACHED();
  }
}