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

Side by Side Diff: base/clipboard.cc

Issue 159815: Refactor bookmark clipboard code to be cross platform. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix UMR Created 11 years, 4 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/clipboard.h" 5 #include "base/clipboard.h"
6 6
7 #include "base/gfx/size.h" 7 #include "base/gfx/size.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace { 10 namespace {
11 11
12 // A compromised renderer could send us bad data, so validate it. 12 // A compromised renderer could send us bad data, so validate it.
13 bool IsBitmapSafe(const Clipboard::ObjectMapParams& params) { 13 bool IsBitmapSafe(const Clipboard::ObjectMapParams& params) {
14 const gfx::Size* size = 14 const gfx::Size* size =
15 reinterpret_cast<const gfx::Size*>(&(params[1].front())); 15 reinterpret_cast<const gfx::Size*>(&(params[1].front()));
16 return params[0].size() == 16 return params[0].size() ==
17 static_cast<size_t>(size->width() * size->height() * 4); 17 static_cast<size_t>(size->width() * size->height() * 4);
18 } 18 }
19 19
20 } 20 } // namespace
21 21
22 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) { 22 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
23 switch (type) { 23 switch (type) {
24 case CBF_TEXT: 24 case CBF_TEXT:
25 WriteText(&(params[0].front()), params[0].size()); 25 WriteText(&(params[0].front()), params[0].size());
26 break; 26 break;
27 27
28 case CBF_HTML: 28 case CBF_HTML:
29 if (params.size() == 2) 29 if (params.size() == 2)
30 WriteHTML(&(params[0].front()), params[0].size(), 30 WriteHTML(&(params[0].front()), params[0].size(),
(...skipping 19 matching lines...) Expand all
50 case CBF_WEBKIT: 50 case CBF_WEBKIT:
51 WriteWebSmartPaste(); 51 WriteWebSmartPaste();
52 break; 52 break;
53 53
54 #if defined(OS_WIN) || defined(OS_LINUX) 54 #if defined(OS_WIN) || defined(OS_LINUX)
55 case CBF_BITMAP: 55 case CBF_BITMAP:
56 if (!IsBitmapSafe(params)) 56 if (!IsBitmapSafe(params))
57 return; 57 return;
58 WriteBitmap(&(params[0].front()), &(params[1].front())); 58 WriteBitmap(&(params[0].front()), &(params[1].front()));
59 break; 59 break;
60
61 case CBF_DATA:
62 WriteData(&(params[0].front()), params[0].size(),
63 &(params[1].front()), params[1].size());
64 break;
60 #endif // defined(OS_WIN) || defined(OS_LINUX) 65 #endif // defined(OS_WIN) || defined(OS_LINUX)
61 66
62 default: 67 default:
63 NOTREACHED(); 68 NOTREACHED();
64 } 69 }
65 } 70 }
OLDNEW
« no previous file with comments | « base/clipboard.h ('k') | base/clipboard_linux.cc » ('j') | base/clipboard_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698