1/* 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef ClipboardMac_h 27#define ClipboardMac_h 28 29#include "CachedResourceClient.h" 30#include "Clipboard.h" 31#include <wtf/RetainPtr.h> 32 33#ifdef __OBJC__ 34@class NSImage; 35@class NSPasteboard; 36#else 37class NSImage; 38class NSPasteboard; 39#endif 40 41namespace WebCore { 42 43class Frame; 44class FileList; 45 46class ClipboardMac : public Clipboard, public CachedResourceClient { 47 WTF_MAKE_FAST_ALLOCATED; 48public: 49 static PassRefPtr<ClipboardMac> create(ClipboardType clipboardType, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame* frame) 50 { 51 return adoptRef(new ClipboardMac(clipboardType, pasteboard, policy, frame)); 52 } 53 54 virtual ~ClipboardMac(); 55 56 void clearData(const String& type); 57 void clearAllData(); 58 String getData(const String& type, bool& success) const; 59 bool setData(const String& type, const String& data); 60 61 virtual bool hasData(); 62 63 // extensions beyond IE's API 64 virtual HashSet<String> types() const; 65 virtual PassRefPtr<FileList> files() const; 66 67 void setDragImage(CachedImage*, const IntPoint&); 68 void setDragImageElement(Node *, const IntPoint&); 69 70 virtual DragImageRef createDragImage(IntPoint& dragLoc) const; 71#if ENABLE(DRAG_SUPPORT) 72 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*); 73#endif 74 virtual void writeRange(Range*, Frame* frame); 75 virtual void writeURL(const KURL&, const String&, Frame* frame); 76 virtual void writePlainText(const String&); 77 78 // Methods for getting info in Cocoa's type system 79 NSImage *dragNSImage(NSPoint&) const; // loc converted from dragLoc, based on whole image size 80 NSPasteboard *pasteboard() { return m_pasteboard.get(); } 81 82private: 83 ClipboardMac(ClipboardType, NSPasteboard *, ClipboardAccessPolicy, Frame*); 84 85 void setDragImage(CachedImage*, Node*, const IntPoint&); 86 87 RetainPtr<NSPasteboard> m_pasteboard; 88 int m_changeCount; 89 Frame* m_frame; // used on the source side to generate dragging images 90}; 91 92} 93 94#endif 95