Diff
Modified: trunk/Source/WebKit2/CMakeLists.txt (120962 => 120963)
--- trunk/Source/WebKit2/CMakeLists.txt 2012-06-21 21:15:19 UTC (rev 120962)
+++ trunk/Source/WebKit2/CMakeLists.txt 2012-06-21 21:23:28 UTC (rev 120963)
@@ -279,6 +279,7 @@
UIProcess/API/C/WKHitTestResult.cpp
UIProcess/API/C/WKIconDatabase.cpp
UIProcess/API/C/WKInspector.cpp
+ UIProcess/API/C/WKIntentData.cpp
UIProcess/API/C/WKKeyValueStorageManager.cpp
UIProcess/API/C/WKMediaCacheManager.cpp
UIProcess/API/C/WKNavigationData.cpp
Modified: trunk/Source/WebKit2/ChangeLog (120962 => 120963)
--- trunk/Source/WebKit2/ChangeLog 2012-06-21 21:15:19 UTC (rev 120962)
+++ trunk/Source/WebKit2/ChangeLog 2012-06-21 21:23:28 UTC (rev 120963)
@@ -1,5 +1,35 @@
2012-06-21 Christophe Dumez <[email protected]>
+ [WK2] Add C API to inspect a Web Intent
+ https://bugs.webkit.org/show_bug.cgi?id=89275
+
+ Reviewed by Anders Carlsson.
+
+ Add C API for Web Intent so that it can be queried
+ on client side.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * UIProcess/API/C/WKIntentData.cpp: Copied from Source/WebKit2/UIProcess/WebIntentData.cpp.
+ (WKIntentDataGetTypeID):
+ (WKIntentDataCopyAction):
+ (WKIntentDataCopyType):
+ (WKIntentDataCopyService):
+ (WKIntentDataCopySuggestions):
+ (WKIntentDataCopyExtra):
+ (WKIntentDataCopyExtras):
+ * UIProcess/API/C/WKIntentData.h: Copied from Source/WebKit2/UIProcess/WebIntentData.cpp.
+ * UIProcess/WebIntentData.cpp:
+ (WebKit::WebIntentData::suggestions):
+ (WebKit):
+ (WebKit::WebIntentData::extra):
+ (WebKit::WebIntentData::extras):
+ * UIProcess/WebIntentData.h:
+ (WebIntentData):
+
+2012-06-21 Christophe Dumez <[email protected]>
+
[WK2] Properly encode/decode service in IntentData
https://bugs.webkit.org/show_bug.cgi?id=89460
Modified: trunk/Source/WebKit2/GNUmakefile.list.am (120962 => 120963)
--- trunk/Source/WebKit2/GNUmakefile.list.am 2012-06-21 21:15:19 UTC (rev 120962)
+++ trunk/Source/WebKit2/GNUmakefile.list.am 2012-06-21 21:23:28 UTC (rev 120963)
@@ -63,6 +63,7 @@
$(WebKit2)/UIProcess/API/C/WKGrammarDetail.h \
$(WebKit2)/UIProcess/API/C/WKHitTestResult.h \
$(WebKit2)/UIProcess/API/C/WKInspector.h \
+ $(WebKit2)/UIProcess/API/C/WKIntentData.h \
$(WebKit2)/UIProcess/API/C/WKKeyValueStorageManager.h \
$(WebKit2)/UIProcess/API/C/WKMediaCacheManager.h \
$(WebKit2)/UIProcess/API/C/WKNativeEvent.h \
@@ -532,6 +533,8 @@
Source/WebKit2/UIProcess/API/C/WKIconDatabase.h \
Source/WebKit2/UIProcess/API/C/WKInspector.cpp \
Source/WebKit2/UIProcess/API/C/WKInspector.h \
+ Source/WebKit2/UIProcess/API/C/WKIntentData.cpp \
+ Source/WebKit2/UIProcess/API/C/WKIntentData.h \
Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp \
Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h \
Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp \
Modified: trunk/Source/WebKit2/Target.pri (120962 => 120963)
--- trunk/Source/WebKit2/Target.pri 2012-06-21 21:15:19 UTC (rev 120962)
+++ trunk/Source/WebKit2/Target.pri 2012-06-21 21:23:28 UTC (rev 120963)
@@ -161,6 +161,7 @@
UIProcess/API/C/WKHitTestResult.h \
UIProcess/API/C/WKIconDatabase.h \
UIProcess/API/C/WKInspector.h \
+ UIProcess/API/C/WKIntentData.h \
UIProcess/API/C/WKOpenPanelParameters.h \
UIProcess/API/C/WKOpenPanelResultListener.h \
UIProcess/API/C/WKNavigationData.h \
@@ -519,6 +520,7 @@
UIProcess/API/C/WKHitTestResult.cpp \
UIProcess/API/C/WKIconDatabase.cpp \
UIProcess/API/C/WKInspector.cpp \
+ UIProcess/API/C/WKIntentData.cpp \
UIProcess/API/C/WKNotification.cpp \
UIProcess/API/C/WKNotificationManager.cpp \
UIProcess/API/C/WKNotificationPermissionRequest.cpp \
Copied: trunk/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp (from rev 120962, trunk/Source/WebKit2/UIProcess/WebIntentData.h) (0 => 120963)
--- trunk/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKIntentData.cpp 2012-06-21 21:23:28 UTC (rev 120963)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKIntentData.h"
+
+#include "ImmutableArray.h"
+#include "ImmutableDictionary.h"
+#include "WKAPICast.h"
+
+#if ENABLE(WEB_INTENTS)
+#include "WebIntentData.h"
+#endif
+
+using namespace WebKit;
+
+WKTypeID WKIntentDataGetTypeID()
+{
+#if ENABLE(WEB_INTENTS)
+ return toAPI(WebIntentData::APIType);
+#else
+ return 0;
+#endif
+}
+
+WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+ return toCopiedAPI(toImpl(intentRef)->action());
+#else
+ return 0;
+#endif
+}
+
+WKStringRef WKIntentDataCopyType(WKIntentDataRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+ return toCopiedAPI(toImpl(intentRef)->payloadType());
+#else
+ return 0;
+#endif
+}
+
+WKURLRef WKIntentDataCopyService(WKIntentDataRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+ return toCopiedURLAPI(toImpl(intentRef)->service());
+#else
+ return 0;
+#endif
+}
+
+WKArrayRef WKIntentDataCopySuggestions(WKIntentDataRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+ return toAPI(toImpl(intentRef)->suggestions().leakRef());
+#else
+ return 0;
+#endif
+}
+
+WKStringRef WKIntentDataCopyExtra(WKIntentDataRef intentRef, WKStringRef key)
+{
+#if ENABLE(WEB_INTENTS)
+ return toCopiedAPI(toImpl(intentRef)->extra(toWTFString(key)));
+#else
+ return 0;
+#endif
+}
+
+WKDictionaryRef WKIntentDataCopyExtras(WKIntentDataRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+ return toAPI(toImpl(intentRef)->extras().leakRef());
+#else
+ return 0;
+#endif
+}
Copied: trunk/Source/WebKit2/UIProcess/API/C/WKIntentData.h (from rev 120962, trunk/Source/WebKit2/UIProcess/WebIntentData.cpp) (0 => 120963)
--- trunk/Source/WebKit2/UIProcess/API/C/WKIntentData.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKIntentData.h 2012-06-21 21:23:28 UTC (rev 120963)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKIntentData_h
+#define WKIntentData_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKIntentDataGetTypeID();
+WK_EXPORT WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef);
+WK_EXPORT WKStringRef WKIntentDataCopyType(WKIntentDataRef intentRef);
+WK_EXPORT WKURLRef WKIntentDataCopyService(WKIntentDataRef intentRef);
+WK_EXPORT WKArrayRef WKIntentDataCopySuggestions(WKIntentDataRef intentRef);
+WK_EXPORT WKStringRef WKIntentDataCopyExtra(WKIntentDataRef intentRef, WKStringRef key);
+WK_EXPORT WKDictionaryRef WKIntentDataCopyExtras(WKIntentDataRef intentRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKIntentData_h
Modified: trunk/Source/WebKit2/UIProcess/WebIntentData.cpp (120962 => 120963)
--- trunk/Source/WebKit2/UIProcess/WebIntentData.cpp 2012-06-21 21:15:19 UTC (rev 120962)
+++ trunk/Source/WebKit2/UIProcess/WebIntentData.cpp 2012-06-21 21:23:28 UTC (rev 120963)
@@ -28,6 +28,11 @@
#if ENABLE(WEB_INTENTS)
+#include "ImmutableArray.h"
+#include "ImmutableDictionary.h"
+#include "WebString.h"
+#include "WebURL.h"
+
namespace WebKit {
WebIntentData::WebIntentData(const IntentData& store)
@@ -41,6 +46,29 @@
return WebSerializedScriptValue::adopt(dataCopy);
}
+PassRefPtr<ImmutableArray> WebIntentData::suggestions() const
+{
+ const size_t numSuggestions = m_store.suggestions.size();
+ Vector<RefPtr<APIObject> > wkSuggestions(numSuggestions);
+ for (unsigned i = 0; i < numSuggestions; ++i)
+ wkSuggestions[i] = WebURL::create(m_store.suggestions[i]);
+ return ImmutableArray::adopt(wkSuggestions);
+}
+
+String WebIntentData::extra(const String& key) const
+{
+ return m_store.extras.get(key);
+}
+
+PassRefPtr<ImmutableDictionary> WebIntentData::extras() const
+{
+ ImmutableDictionary::MapType wkExtras;
+ HashMap<String, String>::const_iterator end = m_store.extras.end();
+ for (HashMap<String, String>::const_iterator it = m_store.extras.begin(); it != end; ++it)
+ wkExtras.set(it->first, WebString::create(it->second));
+ return ImmutableDictionary::adopt(wkExtras);
+}
+
} // namespace WebKit
#endif // ENABLE(WEB_INTENTS)
Modified: trunk/Source/WebKit2/UIProcess/WebIntentData.h (120962 => 120963)
--- trunk/Source/WebKit2/UIProcess/WebIntentData.h 2012-06-21 21:15:19 UTC (rev 120962)
+++ trunk/Source/WebKit2/UIProcess/WebIntentData.h 2012-06-21 21:23:28 UTC (rev 120963)
@@ -50,8 +50,10 @@
const String& payloadType() const { return m_store.type; }
const WebCore::KURL& service() const { return m_store.service; }
PassRefPtr<WebSerializedScriptValue> data() const;
- const HashMap<String, String>& extras() const { return m_store.extras; }
- const Vector<WebCore::KURL>& suggestions() const { return m_store.suggestions; }
+ String extra(const String& key) const;
+ PassRefPtr<ImmutableDictionary> extras() const;
+ PassRefPtr<ImmutableArray> suggestions() const;
+
const IntentData& store() const { return m_store; }
private: