2 * Copyright (C) 2012 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ClipboardHelper_h
27 #define ClipboardHelper_h
29 #include <wtf/Deque.h>
30 #include <wtf/PassOwnPtr.h>
31 #include <wtf/RefCounted.h>
32 #include <wtf/text/CString.h>
33 #include <wtf/text/WTFString.h>
35 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
43 typedef void (*ClipboardDataResultFunction)(const String&, const String&, void*);
45 class ClipboardCallback : public RefCounted<ClipboardCallback> {
48 static PassRefPtr<ClipboardCallback> create(void* context, ClipboardDataResultFunction callback)
50 return adoptRef(new ClipboardCallback(context, callback));
58 void performCallback(const String& data, const String& type)
61 m_callback(data, type, m_context);
66 ClipboardCallback(void* context, ClipboardDataResultFunction callback)
68 , m_callback(callback)
73 ClipboardDataResultFunction m_callback;
77 class ClipboardHelper {
79 static PassOwnPtr<ClipboardHelper> create(Evas_Object* ewkView, PageClientImpl* pageClient)
81 return adoptPtr(new ClipboardHelper(ewkView, pageClient));
87 SelectionTypeSecondary,
89 SelectionTypeClipboard
92 static int numberOfItems();
94 void setData(const String& data, const String& type);
95 void requestData(void* context, ClipboardDataResultFunction, SelectionType type = SelectionTypeClipboard);
99 void processResult(const String& data, const String& type);
101 PageClientImpl* pageClient() { return m_pageClient; }
103 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
104 void openClipboardWindow(bool isRichEditable);
105 bool isClipboardWindowOpened();
106 void connectClipboardWindow();
107 void clearClipboardSelectionClearHandler();
108 Evas_Object* ewkView() { return m_ewkView; }
112 ClipboardHelper(Evas_Object* ewkView, PageClientImpl* pageClient)
114 , m_pageClient(pageClient)
115 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
116 , m_selectionClearHandler(0)
121 Evas_Object* m_ewkView;
122 PageClientImpl* m_pageClient;
124 Deque<RefPtr<ClipboardCallback> > m_callbackQueue;
125 Mutex m_callbackQueueLock;
127 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
128 Ecore_Event_Handler* m_selectionClearHandler;
133 } // namespace WebKit
135 #endif // ClipboardHelper_h