Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: base/clipboard.cc

Issue 260003: Move the clipboard stuff out of base and into app/clipboard. I renamed... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/clipboard.h ('k') | base/clipboard_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/clipboard.h"
6
7 #include "base/gfx/size.h"
8 #include "base/logging.h"
9
10 namespace {
11
12 // A compromised renderer could send us bad data, so validate it.
13 bool IsBitmapSafe(const Clipboard::ObjectMapParams& params) {
14 const gfx::Size* size =
15 reinterpret_cast<const gfx::Size*>(&(params[1].front()));
16 return params[0].size() ==
17 static_cast<size_t>(size->width() * size->height() * 4);
18 }
19
20 } // namespace
21
22 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
23 switch (type) {
24 case CBF_TEXT:
25 WriteText(&(params[0].front()), params[0].size());
26 break;
27
28 case CBF_HTML:
29 if (params.size() == 2)
30 WriteHTML(&(params[0].front()), params[0].size(),
31 &(params[1].front()), params[1].size());
32 else
33 WriteHTML(&(params[0].front()), params[0].size(), NULL, 0);
34 break;
35
36 case CBF_BOOKMARK:
37 WriteBookmark(&(params[0].front()), params[0].size(),
38 &(params[1].front()), params[1].size());
39 break;
40
41 case CBF_FILES:
42 WriteFiles(&(params[0].front()), params[0].size());
43 break;
44
45 case CBF_WEBKIT:
46 WriteWebSmartPaste();
47 break;
48
49 #if defined(OS_WIN) || defined(OS_LINUX)
50 case CBF_BITMAP:
51 if (!IsBitmapSafe(params))
52 return;
53 WriteBitmap(&(params[0].front()), &(params[1].front()));
54 break;
55
56 case CBF_DATA:
57 WriteData(&(params[0].front()), params[0].size(),
58 &(params[1].front()), params[1].size());
59 break;
60 #endif // defined(OS_WIN) || defined(OS_LINUX)
61
62 default:
63 NOTREACHED();
64 }
65 }
OLDNEW
« no previous file with comments | « base/clipboard.h ('k') | base/clipboard_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698