Added APIs for checking whether frame is main frame when policy decision callback...
authorYuni Jeong <yhnet.jung@samsung.com>
Mon, 3 Sep 2012 08:45:20 +0000 (17:45 +0900)
committerYuni Jeong <yhnet.jung@samsung.com>
Tue, 4 Sep 2012 08:46:38 +0000 (17:46 +0900)
[Title] Added APIs for checking whether frame is main frame when policy decision callback is called.
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] N/A

Change-Id: I90b5cdb182eda4aefff38ce89e2ca7a0097c857c

Source/WebKit2/UIProcess/API/efl/ewk_frame.cpp
Source/WebKit2/UIProcess/API/efl/ewk_frame.h
Source/WebKit2/UIProcess/API/efl/ewk_policy_decision.cpp
Source/WebKit2/UIProcess/API/efl/ewk_policy_decision.h
Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp

index d50dfda..0680f43 100755 (executable)
@@ -85,4 +85,12 @@ Eina_Bool ewk_frame_can_show_mime_type(Ewk_Frame_Ref frame, char* mimeType)
     WKFrameRef wkFrame = static_cast<WKFrameRef>(frame);
     WKRetainPtr<WKStringRef> mimeTypeRef(AdoptWK, WKStringCreateWithUTF8CString(mimeType));
     return WKFrameCanShowMIMEType(wkFrame, mimeTypeRef.get());
     WKFrameRef wkFrame = static_cast<WKFrameRef>(frame);
     WKRetainPtr<WKStringRef> mimeTypeRef(AdoptWK, WKStringCreateWithUTF8CString(mimeType));
     return WKFrameCanShowMIMEType(wkFrame, mimeTypeRef.get());
-}
\ No newline at end of file
+}
+
+Eina_Bool ewk_frame_is_main_frame(Ewk_Frame_Ref frame)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(frame, false);
+
+    WKFrameRef wkFrame = static_cast<WKFrameRef>(frame);
+    return WKFrameIsMainFrame(wkFrame);
+}
index c724d77..c87540f 100755 (executable)
@@ -59,7 +59,7 @@ EAPI Ewk_Frame_Ref ewk_frame_parent_get(Ewk_Frame_Ref frame);
 EAPI Eina_Bool ewk_frame_source_get(Ewk_Frame_Ref frame, Ewk_Frame_Source_Get_Callback callback, void* user_data);
 
 /**
 EAPI Eina_Bool ewk_frame_source_get(Ewk_Frame_Ref frame, Ewk_Frame_Source_Get_Callback callback, void* user_data);
 
 /**
- * Returns that Whether or not a MIME type can be displayed.
+ * Gets whether a MIME type can be displayed in the frame.
  *
  * @param frame frame object
  * @param mime_type a mime type
  *
  * @param frame frame object
  * @param mime_type a mime type
@@ -68,6 +68,15 @@ EAPI Eina_Bool ewk_frame_source_get(Ewk_Frame_Ref frame, Ewk_Frame_Source_Get_Ca
  */
 EAPI Eina_Bool ewk_frame_can_show_mime_type(Ewk_Frame_Ref frame, char* mime_type);
 
  */
 EAPI Eina_Bool ewk_frame_can_show_mime_type(Ewk_Frame_Ref frame, char* mime_type);
 
+/**
+ * Gets whether the frame is main frame.
+ *
+ * @param frame frame object
+ *
+ * @return @c EINA_TRUE if the frame is main frame or @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_frame_is_main_frame(Ewk_Frame_Ref frame);
+
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
index 10e7a22..7a5aa49 100755 (executable)
@@ -45,6 +45,7 @@ struct _Ewk_Policy_Decision {
     Eina_Hash* responseHeaders;
     Ewk_Policy_Decision_Type decisionType;
     Ewk_Policy_Navigation_Type navigationType;
     Eina_Hash* responseHeaders;
     Ewk_Policy_Decision_Type decisionType;
     Ewk_Policy_Navigation_Type navigationType;
+    WKFrameRef frame;
 
     bool isDecided;
     bool isSuspended;
 
     bool isDecided;
     bool isSuspended;
@@ -75,6 +76,8 @@ Ewk_Policy_Decision* ewkPolicyDecisionCreate(WKFramePolicyListenerRef listener,
     policyDecision->decisionType = EWK_POLICY_DECISION_USE;
     policyDecision->navigationType = static_cast<Ewk_Policy_Navigation_Type>(navigationType);
 
     policyDecision->decisionType = EWK_POLICY_DECISION_USE;
     policyDecision->navigationType = static_cast<Ewk_Policy_Navigation_Type>(navigationType);
 
+    policyDecision->frame = frame;
+
     if (response) {
         policyDecision->responseMime = eina_stringshare_add(toImpl(response)->resourceResponse().mimeType().utf8().data());
 
     if (response) {
         policyDecision->responseMime = eina_stringshare_add(toImpl(response)->resourceResponse().mimeType().utf8().data());
 
@@ -248,11 +251,18 @@ Eina_Bool ewk_policy_decision_download(Ewk_Policy_Decision* policyDecision)
     return true;
 }
 
     return true;
 }
 
-Ewk_Policy_Navigation_Type ewk_policy_decision_navigation_type_get(Ewk_Policy_Decision* policy_decision)
+Ewk_Policy_Navigation_Type ewk_policy_decision_navigation_type_get(Ewk_Policy_Decision* policyDecision)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(policyDecision, EWK_POLICY_NAVIGATION_TYPE_OTHER);
+
+    return policyDecision->navigationType;
+}
+
+Ewk_Frame_Ref ewk_policy_decision_frame_get(Ewk_Policy_Decision* policyDecision)
 {
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(policy_decision, EWK_POLICY_NAVIGATION_TYPE_OTHER);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(policyDecision, 0);
 
 
-    return policy_decision->navigationType;
+    return static_cast<Ewk_Frame_Ref>(policyDecision->frame);
 }
 
 #endif // #if OS(TIZEN)
 }
 
 #endif // #if OS(TIZEN)
index dae609b..51cba8f 100755 (executable)
@@ -20,6 +20,7 @@
 #ifndef ewk_policy_decision_h
 #define ewk_policy_decision_h
 
 #ifndef ewk_policy_decision_h
 #define ewk_policy_decision_h
 
+#include "ewk_frame.h"
 #include <Eina.h>
 
 #ifdef __cplusplus
 #include <Eina.h>
 
 #ifdef __cplusplus
@@ -171,6 +172,15 @@ EAPI Eina_Bool ewk_policy_decision_download(Ewk_Policy_Decision* policy_decision
  */
 EAPI Ewk_Policy_Navigation_Type ewk_policy_decision_navigation_type_get(Ewk_Policy_Decision* policy_decision);
 
  */
 EAPI Ewk_Policy_Navigation_Type ewk_policy_decision_navigation_type_get(Ewk_Policy_Decision* policy_decision);
 
+/**
+ * Gets the frame reference from Policy Decision object.
+ *
+ * @param policy_decision policy decsision object
+ *
+ * @return frame reference on success, or NULL on failure
+ */
+EAPI Ewk_Frame_Ref ewk_policy_decision_frame_get(Ewk_Policy_Decision* policy_decision);
+
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
index bae5b87..ed44e3b 100755 (executable)
@@ -34,7 +34,7 @@ using namespace WebKit;
 void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
 {
     Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
 void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
 {
     Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
-    Ewk_Policy_Decision* policyDecision = ewkPolicyDecisionCreate(listener, request, 0, 0, navigationType);
+    Ewk_Policy_Decision* policyDecision = ewkPolicyDecisionCreate(listener, request, frame, 0, navigationType);
     ewkViewPolicyNavigationDecide(ewkView, policyDecision);
 
     if (!ewkPolicyDecisionDecided(policyDecision) && !ewkPolicyDecisionSuspended(policyDecision))
     ewkViewPolicyNavigationDecide(ewkView, policyDecision);
 
     if (!ewkPolicyDecisionDecided(policyDecision) && !ewkPolicyDecisionSuspended(policyDecision))
@@ -44,7 +44,7 @@ void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNa
 void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
 {
     Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
 void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
 {
     Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
-    Ewk_Policy_Decision* policyDecision = ewkPolicyDecisionCreate(listener, request, 0, 0, navigationType);
+    Ewk_Policy_Decision* policyDecision = ewkPolicyDecisionCreate(listener, request, frame, 0, navigationType);
     ewkViewPolicyNewWindowDecide(ewkView, policyDecision);
 
     if (!ewkPolicyDecisionDecided(policyDecision) && !ewkPolicyDecisionSuspended(policyDecision))
     ewkViewPolicyNewWindowDecide(ewkView, policyDecision);
 
     if (!ewkPolicyDecisionDecided(policyDecision) && !ewkPolicyDecisionSuspended(policyDecision))