| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/clipboard/clipboard.h" | 8 #include "app/clipboard/clipboard.h" |
| 9 | 9 |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| 11 #include <shellapi.h> | 11 #include <shellapi.h> |
| 12 | 12 |
| 13 #include "app/clipboard/clipboard_util_win.h" | 13 #include "app/clipboard/clipboard_util_win.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/lock.h" | |
| 16 #include "base/logging.h" | 15 #include "base/logging.h" |
| 17 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 18 #include "base/shared_memory.h" | 17 #include "base/shared_memory.h" |
| 19 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 20 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 21 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 22 #include "gfx/size.h" | 21 #include "gfx/size.h" |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 ::GlobalAlloc(GMEM_MOVEABLE, ((str.size() + 1) * sizeof(charT))); | 119 ::GlobalAlloc(GMEM_MOVEABLE, ((str.size() + 1) * sizeof(charT))); |
| 121 if (data) { | 120 if (data) { |
| 122 charT* raw_data = static_cast<charT*>(::GlobalLock(data)); | 121 charT* raw_data = static_cast<charT*>(::GlobalLock(data)); |
| 123 memcpy(raw_data, str.data(), str.size() * sizeof(charT)); | 122 memcpy(raw_data, str.data(), str.size() * sizeof(charT)); |
| 124 raw_data[str.size()] = '\0'; | 123 raw_data[str.size()] = '\0'; |
| 125 ::GlobalUnlock(data); | 124 ::GlobalUnlock(data); |
| 126 } | 125 } |
| 127 return data; | 126 return data; |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 } // namespace | 129 } // namespace |
| 131 | 130 |
| 132 Clipboard::Clipboard() : create_window_(false) { | 131 Clipboard::Clipboard() : create_window_(false) { |
| 133 if (MessageLoop::current()->type() == MessageLoop::TYPE_UI) { | 132 if (MessageLoop::current()->type() == MessageLoop::TYPE_UI) { |
| 134 // Make a dummy HWND to be the clipboard's owner. | 133 // Make a dummy HWND to be the clipboard's owner. |
| 135 WNDCLASSEX wcex = {0}; | 134 WNDCLASSEX wcex = {0}; |
| 136 wcex.cbSize = sizeof(WNDCLASSEX); | 135 wcex.cbSize = sizeof(WNDCLASSEX); |
| 137 wcex.lpfnWndProc = ClipboardOwnerWndProc; | 136 wcex.lpfnWndProc = ClipboardOwnerWndProc; |
| 138 wcex.hInstance = GetModuleHandle(NULL); | 137 wcex.hInstance = GetModuleHandle(NULL); |
| 139 wcex.lpszClassName = L"ClipboardOwnerWindowClass"; | 138 wcex.lpszClassName = L"ClipboardOwnerWindowClass"; |
| 140 ::RegisterClassEx(&wcex); | 139 ::RegisterClassEx(&wcex); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 HWND Clipboard::GetClipboardWindow() const { | 593 HWND Clipboard::GetClipboardWindow() const { |
| 595 if (!clipboard_owner_ && create_window_) { | 594 if (!clipboard_owner_ && create_window_) { |
| 596 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", | 595 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", |
| 597 L"ClipboardOwnerWindow", | 596 L"ClipboardOwnerWindow", |
| 598 0, 0, 0, 0, 0, | 597 0, 0, 0, 0, 0, |
| 599 HWND_MESSAGE, | 598 HWND_MESSAGE, |
| 600 0, 0, 0); | 599 0, 0, 0); |
| 601 } | 600 } |
| 602 return clipboard_owner_; | 601 return clipboard_owner_; |
| 603 } | 602 } |
| OLD | NEW |