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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/tab_contents/web_drag_utils_win.h" 6 7 #include <oleidl.h> 8 #include "base/logging.h" 9 10 using WebKit::WebDragOperation; 11 using WebKit::WebDragOperationsMask; 12 using WebKit::WebDragOperationNone; 13 using WebKit::WebDragOperationCopy; 14 using WebKit::WebDragOperationLink; 15 using WebKit::WebDragOperationMove; 16 using WebKit::WebDragOperationGeneric; 17 18 namespace web_drag_utils_win { 19 20 WebDragOperation WinDragOpToWebDragOp(DWORD effect) { 21 DCHECK(effect == DROPEFFECT_NONE || effect == DROPEFFECT_COPY || 22 effect == DROPEFFECT_LINK || effect == DROPEFFECT_MOVE); 23 24 return WinDragOpMaskToWebDragOpMask(effect); 25 } 26 27 WebDragOperationsMask WinDragOpMaskToWebDragOpMask(DWORD effects) { 28 WebDragOperationsMask ops = WebDragOperationNone; 29 if (effects & DROPEFFECT_COPY) 30 ops = static_cast<WebDragOperationsMask>(ops | WebDragOperationCopy); 31 if (effects & DROPEFFECT_LINK) 32 ops = static_cast<WebDragOperationsMask>(ops | WebDragOperationLink); 33 if (effects & DROPEFFECT_MOVE) 34 ops = static_cast<WebDragOperationsMask>(ops | WebDragOperationMove | 35 WebDragOperationGeneric); 36 return ops; 37 } 38 39 DWORD WebDragOpToWinDragOp(WebDragOperation op) { 40 DCHECK(op == WebDragOperationNone || 41 op == WebDragOperationCopy || 42 op == WebDragOperationLink || 43 op == WebDragOperationMove || 44 op == (WebDragOperationMove | WebDragOperationGeneric)); 45 46 return WebDragOpMaskToWinDragOpMask(op); 47 } 48 49 DWORD WebDragOpMaskToWinDragOpMask(WebDragOperationsMask ops) { 50 DWORD win_ops = DROPEFFECT_NONE; 51 if (ops & WebDragOperationCopy) 52 win_ops |= DROPEFFECT_COPY; 53 if (ops & WebDragOperationLink) 54 win_ops |= DROPEFFECT_LINK; 55 if (ops & (WebDragOperationMove | WebDragOperationGeneric)) 56 win_ops |= DROPEFFECT_MOVE; 57 return win_ops; 58 } 59 60 } // namespace web_drag_utils_win 61 62