| OLD | NEW | 
|---|
| 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 "base/clipboard.h" | 8 #include "base/clipboard.h" | 
| 9 | 9 | 
| 10 #include <shlobj.h> | 10 #include <shlobj.h> | 
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 202   std::string bookmark(title_data, title_len); | 202   std::string bookmark(title_data, title_len); | 
| 203   bookmark.append(1, L'\n'); | 203   bookmark.append(1, L'\n'); | 
| 204   bookmark.append(url_data, url_len); | 204   bookmark.append(url_data, url_len); | 
| 205 | 205 | 
| 206   string16 wide_bookmark = UTF8ToWide(bookmark); | 206   string16 wide_bookmark = UTF8ToWide(bookmark); | 
| 207   HGLOBAL glob = CreateGlobalData(wide_bookmark); | 207   HGLOBAL glob = CreateGlobalData(wide_bookmark); | 
| 208 | 208 | 
| 209   WriteToClipboard(StringToInt(GetUrlWFormatType()), glob); | 209   WriteToClipboard(StringToInt(GetUrlWFormatType()), glob); | 
| 210 } | 210 } | 
| 211 | 211 | 
| 212 void Clipboard::WriteHyperlink(const char* title_data, |  | 
| 213                                size_t title_len, |  | 
| 214                                const char* url_data, |  | 
| 215                                size_t url_len) { |  | 
| 216   // Store as a bookmark. |  | 
| 217   WriteBookmark(title_data, title_len, url_data, url_len); |  | 
| 218 |  | 
| 219   std::string title(title_data, title_len), |  | 
| 220       url(url_data, url_len), |  | 
| 221       link("<a href=\""); |  | 
| 222 |  | 
| 223   // Construct the hyperlink. |  | 
| 224   link.append(url); |  | 
| 225   link.append("\">"); |  | 
| 226   link.append(title); |  | 
| 227   link.append("</a>"); |  | 
| 228 |  | 
| 229   // Store hyperlink as html. |  | 
| 230   WriteHTML(link.c_str(), link.size(), NULL, 0); |  | 
| 231 } |  | 
| 232 |  | 
| 233 void Clipboard::WriteWebSmartPaste() { | 212 void Clipboard::WriteWebSmartPaste() { | 
| 234   DCHECK(clipboard_owner_); | 213   DCHECK(clipboard_owner_); | 
| 235   ::SetClipboardData(StringToInt(GetWebKitSmartPasteFormatType()), NULL); | 214   ::SetClipboardData(StringToInt(GetWebKitSmartPasteFormatType()), NULL); | 
| 236 } | 215 } | 
| 237 | 216 | 
| 238 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { | 217 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { | 
| 239   const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); | 218   const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); | 
| 240   HDC dc = ::GetDC(NULL); | 219   HDC dc = ::GetDC(NULL); | 
| 241 | 220 | 
| 242   // This doesn't actually cost us a memcpy when the bitmap comes from the | 221   // This doesn't actually cost us a memcpy when the bitmap comes from the | 
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 698 HWND Clipboard::GetClipboardWindow() const { | 677 HWND Clipboard::GetClipboardWindow() const { | 
| 699   if (!clipboard_owner_ && create_window_) { | 678   if (!clipboard_owner_ && create_window_) { | 
| 700     clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", | 679     clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", | 
| 701                                       L"ClipboardOwnerWindow", | 680                                       L"ClipboardOwnerWindow", | 
| 702                                       0, 0, 0, 0, 0, | 681                                       0, 0, 0, 0, 0, | 
| 703                                       HWND_MESSAGE, | 682                                       HWND_MESSAGE, | 
| 704                                       0, 0, 0); | 683                                       0, 0, 0); | 
| 705   } | 684   } | 
| 706   return clipboard_owner_; | 685   return clipboard_owner_; | 
| 707 } | 686 } | 
| OLD | NEW | 
|---|