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

Side by Side Diff: base/clipboard_win.cc

Issue 10895: Add Terminate() to the Process object, have RenderProcessHost use this to avo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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/gfx/platform_canvas_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Many of these functions are based on those found in 5 // Many of these functions are based on those found in
6 // webkit/port/platform/PasteboardWin.cpp 6 // webkit/port/platform/PasteboardWin.cpp
7 7
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 Clipboard::~Clipboard() { 141 Clipboard::~Clipboard() {
142 ::DestroyWindow(clipboard_owner_); 142 ::DestroyWindow(clipboard_owner_);
143 clipboard_owner_ = NULL; 143 clipboard_owner_ = NULL;
144 } 144 }
145 145
146 void Clipboard::WriteObjects(const ObjectMap& objects) { 146 void Clipboard::WriteObjects(const ObjectMap& objects) {
147 WriteObjects(objects, NULL); 147 WriteObjects(objects, NULL);
148 } 148 }
149 149
150 void Clipboard::WriteObjects(const ObjectMap& objects, ProcessHandle process) { 150 void Clipboard::WriteObjects(const ObjectMap& objects,
151 base::ProcessHandle process) {
151 ScopedClipboard clipboard; 152 ScopedClipboard clipboard;
152 if (!clipboard.Acquire(clipboard_owner_)) 153 if (!clipboard.Acquire(clipboard_owner_))
153 return; 154 return;
154 155
155 ::EmptyClipboard(); 156 ::EmptyClipboard();
156 157
157 for (ObjectMap::const_iterator iter = objects.begin(); 158 for (ObjectMap::const_iterator iter = objects.begin();
158 iter != objects.end(); ++iter) { 159 iter != objects.end(); ++iter) {
159 if (iter->first == CBF_SMBITMAP) 160 if (iter->first == CBF_SMBITMAP)
160 WriteBitmapFromSharedMemory(&(iter->second[0].front()), 161 WriteBitmapFromSharedMemory(&(iter->second[0].front()),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Now we have an HBITMAP, we can write it to the clipboard 261 // Now we have an HBITMAP, we can write it to the clipboard
261 WriteBitmapFromHandle(source_hbitmap, *size); 262 WriteBitmapFromHandle(source_hbitmap, *size);
262 } 263 }
263 264
264 ::DeleteObject(source_hbitmap); 265 ::DeleteObject(source_hbitmap);
265 ::ReleaseDC(NULL, dc); 266 ::ReleaseDC(NULL, dc);
266 } 267 }
267 268
268 void Clipboard::WriteBitmapFromSharedMemory(const char* bitmap_data, 269 void Clipboard::WriteBitmapFromSharedMemory(const char* bitmap_data,
269 const char* size_data, 270 const char* size_data,
270 ProcessHandle process) { 271 base::ProcessHandle process) {
271 const SharedMemoryHandle* remote_bitmap_handle = 272 const base::SharedMemoryHandle* remote_bitmap_handle =
272 reinterpret_cast<const SharedMemoryHandle*>(bitmap_data); 273 reinterpret_cast<const base::SharedMemoryHandle*>(bitmap_data);
273 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); 274 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data);
274 275
275 SharedMemory bitmap(*remote_bitmap_handle, false, process); 276 base::SharedMemory bitmap(*remote_bitmap_handle, false, process);
276 277
277 // TODO(darin): share data in gfx/bitmap_header.cc somehow 278 // TODO(darin): share data in gfx/bitmap_header.cc somehow
278 BITMAPINFO bm_info = {0}; 279 BITMAPINFO bm_info = {0};
279 bm_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 280 bm_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
280 bm_info.bmiHeader.biWidth = size->width(); 281 bm_info.bmiHeader.biWidth = size->width();
281 bm_info.bmiHeader.biHeight = -size->height(); // Sets the vertical orientatio n 282 bm_info.bmiHeader.biHeight = -size->height(); // Sets the vertical orientatio n
282 bm_info.bmiHeader.biPlanes = 1; 283 bm_info.bmiHeader.biPlanes = 1;
283 bm_info.bmiHeader.biBitCount = 32; 284 bm_info.bmiHeader.biBitCount = 32;
284 bm_info.bmiHeader.biCompression = BI_RGB; 285 bm_info.bmiHeader.biCompression = BI_RGB;
285 286
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 return ClipboardUtil::GetWebKitSmartPasteFormat()->cfFormat; 695 return ClipboardUtil::GetWebKitSmartPasteFormat()->cfFormat;
695 } 696 }
696 697
697 // static 698 // static
698 void Clipboard::FreeData(FormatType format, HANDLE data) { 699 void Clipboard::FreeData(FormatType format, HANDLE data) {
699 if (format == CF_BITMAP) 700 if (format == CF_BITMAP)
700 ::DeleteObject(static_cast<HBITMAP>(data)); 701 ::DeleteObject(static_cast<HBITMAP>(data));
701 else 702 else
702 ::GlobalFree(data); 703 ::GlobalFree(data);
703 } 704 }
OLDNEW
« no previous file with comments | « base/clipboard.h ('k') | base/gfx/platform_canvas_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698