Title: [114749] trunk/Source/WebKit
Revision
114749
Author
[email protected]
Date
2012-04-20 09:08:08 -0700 (Fri, 20 Apr 2012)

Log Message

[EFL] Add Security Origin API
https://bugs.webkit.org/show_bug.cgi?id=84023

Source/WebKit:

Patch by Thiago Marcos P. Santos <[email protected]> on 2012-04-20
Reviewed by Antonio Gomes.

* PlatformEfl.cmake:

Source/WebKit/efl:

Added an API to get a Security Origin handle from a Ewk_Frame. This is
needed for fine grained security policy. This new API will also allow
to define quota and get usage information of a Web Storage based on its
Security Origin.

Patch by Thiago Marcos P. Santos <[email protected]> on 2012-04-20
Reviewed by Antonio Gomes.

* ewk/EWebKit.h:
* ewk/ewk_frame.cpp:
(ewk_frame_security_origin_get):
* ewk/ewk_frame.h:
* ewk/ewk_security_origin.cpp: Added.
(ewk_security_origin_protocol_get):
(ewk_security_origin_host_get):
(ewk_security_origin_port_get):
(ewk_security_origin_web_database_usage_get):
(ewk_security_origin_web_database_quota_get):
(ewk_security_origin_web_database_quota_set):
(ewk_security_origin_free):
(ewk_security_origin_new):
* ewk/ewk_security_origin.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (114748 => 114749)


--- trunk/Source/WebKit/ChangeLog	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/ChangeLog	2012-04-20 16:08:08 UTC (rev 114749)
@@ -1,3 +1,12 @@
+2012-04-20  Thiago Marcos P. Santos  <[email protected]>
+
+        [EFL] Add Security Origin API
+        https://bugs.webkit.org/show_bug.cgi?id=84023
+
+        Reviewed by Antonio Gomes.
+
+        * PlatformEfl.cmake:
+
 2012-04-10  Patrick Gansterer  <[email protected]>
 
         [CMake] Enable USE_FOLDERS property

Modified: trunk/Source/WebKit/PlatformEfl.cmake (114748 => 114749)


--- trunk/Source/WebKit/PlatformEfl.cmake	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/PlatformEfl.cmake	2012-04-20 16:08:08 UTC (rev 114749)
@@ -101,6 +101,7 @@
     efl/ewk/ewk_js.cpp
     efl/ewk/ewk_main.cpp
     efl/ewk/ewk_network.cpp
+    efl/ewk/ewk_security_origin.cpp
     efl/ewk/ewk_security_policy.cpp
     efl/ewk/ewk_settings.cpp
     efl/ewk/ewk_tiled_backing_store.cpp
@@ -252,6 +253,7 @@
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_logging.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_main.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_network.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_security_origin.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_security_policy.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_settings.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_view.h

Modified: trunk/Source/WebKit/efl/ChangeLog (114748 => 114749)


--- trunk/Source/WebKit/efl/ChangeLog	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-04-20 16:08:08 UTC (rev 114749)
@@ -1,3 +1,30 @@
+2012-04-20  Thiago Marcos P. Santos  <[email protected]>
+
+        [EFL] Add Security Origin API
+        https://bugs.webkit.org/show_bug.cgi?id=84023
+
+        Added an API to get a Security Origin handle from a Ewk_Frame. This is
+        needed for fine grained security policy. This new API will also allow
+        to define quota and get usage information of a Web Storage based on its
+        Security Origin.
+
+        Reviewed by Antonio Gomes.
+
+        * ewk/EWebKit.h:
+        * ewk/ewk_frame.cpp:
+        (ewk_frame_security_origin_get):
+        * ewk/ewk_frame.h:
+        * ewk/ewk_security_origin.cpp: Added.
+        (ewk_security_origin_protocol_get):
+        (ewk_security_origin_host_get):
+        (ewk_security_origin_port_get):
+        (ewk_security_origin_web_database_usage_get):
+        (ewk_security_origin_web_database_quota_get):
+        (ewk_security_origin_web_database_quota_set):
+        (ewk_security_origin_free):
+        (ewk_security_origin_new):
+        * ewk/ewk_security_origin.h: Added.
+
 2012-04-20  Kamil Blank  <[email protected]>
 
         [EFL] Add setting API for author and user styles.

Modified: trunk/Source/WebKit/efl/ewk/EWebKit.h (114748 => 114749)


--- trunk/Source/WebKit/efl/ewk/EWebKit.h	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/efl/ewk/EWebKit.h	2012-04-20 16:08:08 UTC (rev 114749)
@@ -37,6 +37,7 @@
 #include "ewk_js.h"
 #include "ewk_main.h"
 #include "ewk_network.h"
+#include "ewk_security_origin.h"
 #include "ewk_security_policy.h"
 #include "ewk_settings.h"
 #include "ewk_view.h"

Modified: trunk/Source/WebKit/efl/ewk/ewk_frame.cpp (114748 => 114749)


--- trunk/Source/WebKit/efl/ewk/ewk_frame.cpp	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/efl/ewk/ewk_frame.cpp	2012-04-20 16:08:08 UTC (rev 114749)
@@ -285,6 +285,16 @@
     return smartData->view;
 }
 
+Ewk_Security_Origin* ewk_frame_security_origin_get(const Evas_Object *ewkFrame)
+{
+    EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame->document(), 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame->document()->securityOrigin(), 0);
+
+    return ewk_security_origin_new(smartData->frame->document()->securityOrigin());
+}
+
 Eina_Iterator* ewk_frame_children_iterator_new(Evas_Object* ewkFrame)
 {
     EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, 0);

Modified: trunk/Source/WebKit/efl/ewk/ewk_frame.h (114748 => 114749)


--- trunk/Source/WebKit/efl/ewk/ewk_frame.h	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/efl/ewk/ewk_frame.h	2012-04-20 16:08:08 UTC (rev 114749)
@@ -70,6 +70,8 @@
 #ifndef ewk_frame_h
 #define ewk_frame_h
 
+#include "ewk_security_origin.h"
+
 #include <Evas.h>
 
 #ifdef __cplusplus
@@ -221,6 +223,17 @@
 EAPI Evas_Object *ewk_frame_view_get(const Evas_Object *o);
 
 /**
+ * Retrieves the Ewk_Security_Origin of this frame.
+ *
+ * The returned object should be freed by ewk_security_origin_free().
+ *
+ * @param o frame object to get the security origin
+ *
+ * @return security origin object
+ */
+EAPI Ewk_Security_Origin *ewk_frame_security_origin_get(const Evas_Object *o);
+
+/**
  * Returns a new iterator over all direct children frames.
  *
  * Keep frame object intact while iteration happens otherwise frame

Modified: trunk/Source/WebKit/efl/ewk/ewk_private.h (114748 => 114749)


--- trunk/Source/WebKit/efl/ewk/ewk_private.h	2012-04-20 15:45:52 UTC (rev 114748)
+++ trunk/Source/WebKit/efl/ewk/ewk_private.h	2012-04-20 16:08:08 UTC (rev 114749)
@@ -85,6 +85,7 @@
 class GraphicsContext3D;
 class GraphicsLayer;
 #endif
+class SecurityOrigin;
 }
 
 struct Ewk_Window_Object_Cleared_Event {
@@ -255,6 +256,8 @@
 void ewk_view_mixed_content_run_set(Evas_Object* ewkView, bool hasRun);
 void ewk_frame_xss_detected(Evas_Object* ewkFrame, const Ewk_Frame_Xss_Notification* xssInfo);
 
+Ewk_Security_Origin* ewk_security_origin_new(WebCore::SecurityOrigin* origin);
+
 #if USE(ACCELERATED_COMPOSITING)
 bool ewk_view_accelerated_compositing_object_create(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface, const WebCore::IntRect& rect);
 WebCore::GraphicsContext3D* ewk_view_accelerated_compositing_context_get(Evas_Object* ewkView);

Added: trunk/Source/WebKit/efl/ewk/ewk_security_origin.cpp (0 => 114749)


--- trunk/Source/WebKit/efl/ewk/ewk_security_origin.cpp	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_security_origin.cpp	2012-04-20 16:08:08 UTC (rev 114749)
@@ -0,0 +1,109 @@
+/*
+    Copyright (C) 2012 Intel Corporation
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "ewk_security_origin.h"
+
+#include "DatabaseTracker.h"
+#include "SecurityOrigin.h"
+#include "ewk_private.h"
+#include <Eina.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/CString.h>
+
+struct _Ewk_Security_Origin {
+    RefPtr<WebCore::SecurityOrigin> securityOrigin;
+    const char* protocol;
+    const char* host;
+};
+
+const char* ewk_security_origin_protocol_get(Ewk_Security_Origin* origin)
+{
+    if (!origin->protocol)
+        origin->protocol = eina_stringshare_add(origin->securityOrigin->protocol().utf8().data());
+
+    return origin->protocol;
+}
+
+const char* ewk_security_origin_host_get(Ewk_Security_Origin* origin)
+{
+    if (!origin->host)
+        origin->host = eina_stringshare_add(origin->securityOrigin->host().utf8().data());
+
+    return origin->host;
+}
+
+uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin* origin)
+{
+    return origin->securityOrigin->port();
+}
+
+uint64_t ewk_security_origin_web_database_usage_get(const Ewk_Security_Origin* origin)
+{
+#if ENABLE(SQL_DATABASE)
+    return WebCore::DatabaseTracker::tracker().usageForOrigin(origin->securityOrigin.get());
+#else
+    return 0;
+#endif
+}
+
+uint64_t ewk_security_origin_web_database_quota_get(const Ewk_Security_Origin* origin)
+{
+#if ENABLE(SQL_DATABASE)
+    return WebCore::DatabaseTracker::tracker().quotaForOrigin(origin->securityOrigin.get());
+#else
+    return 0;
+#endif
+}
+
+void ewk_security_origin_web_database_quota_set(const Ewk_Security_Origin* origin, uint64_t quota)
+{
+#if ENABLE(SQL_DATABASE)
+    WebCore::DatabaseTracker::tracker().setQuota(origin->securityOrigin.get(), quota);
+#endif
+}
+
+void ewk_security_origin_free(Ewk_Security_Origin* origin)
+{
+    origin->securityOrigin = 0;
+    eina_stringshare_del(origin->host);
+    eina_stringshare_del(origin->protocol);
+
+    delete origin;
+}
+
+/**
+ * @internal
+ * Creates a EWK wrapper for WebCore Security Origin object.
+ *
+ * @param coreOrigin WebCore Security Origin object
+ *
+ * @return a EWK wrapper of WebCore Security Origin object which should be
+ * freed by ewk_security_origin_free()
+ */
+Ewk_Security_Origin* ewk_security_origin_new(WebCore::SecurityOrigin* coreOrigin)
+{
+    Ewk_Security_Origin* origin = new Ewk_Security_Origin;
+
+    origin->securityOrigin = coreOrigin;
+    origin->host = 0;
+    origin->protocol = 0;
+
+    return origin;
+}

Added: trunk/Source/WebKit/efl/ewk/ewk_security_origin.h (0 => 114749)


--- trunk/Source/WebKit/efl/ewk/ewk_security_origin.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_security_origin.h	2012-04-20 16:08:08 UTC (rev 114749)
@@ -0,0 +1,122 @@
+/*
+    Copyright (C) 2012 Intel Corporation
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file    ewk_security_origin.h
+ * @brief   Security Origin API.
+ *
+ * Security Origin is the mechanism that defines the access limits of a website.
+ * Based on information such as domain, protocol and port, you can grant or not
+ * authorization for accessing data and performing certain tasks. Database quota
+ * can also be defined based on the security origin.
+ *
+ * The database related functions will do nothing if WebKit is built without Web
+ * SQL Database support.
+ */
+
+#ifndef ewk_security_origin_h
+#define ewk_security_origin_h
+
+#include <Evas.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _Ewk_Security_Origin Ewk_Security_Origin;
+
+/**
+ * Returns the protocol of the security origin.
+ *
+ * @param o security origin object
+ *
+ * It returns a internal string which should not
+ * be modified. The string is guaranteed to be stringshared.
+ *
+ * @return the protocol scheme
+ */
+EAPI const char  *ewk_security_origin_protocol_get(Ewk_Security_Origin *o);
+
+/**
+ * Returns the host of the security origin.
+ *
+ * It returns a internal string which should not
+ * be modified. The string is guaranteed to be stringshared.
+ *
+ * @param o security origin object
+ *
+ * @return the host domain
+ */
+EAPI const char  *ewk_security_origin_host_get(Ewk_Security_Origin *o);
+
+/**
+ * Returns the port of the security origin.
+ *
+ * @param o security origin object
+ *
+ * @return the port
+ */
+EAPI uint32_t     ewk_security_origin_port_get(const Ewk_Security_Origin *o);
+
+/**
+ * Retrieves the usage of a database for a security origin.
+ *
+ * This function won't work if Web SQL Database was not enabled when
+ * building WebKit and will just return 0.
+ *
+ * @param o security origin object
+ *
+ * @return the usage in bytes
+ */
+EAPI uint64_t     ewk_security_origin_web_database_usage_get(const Ewk_Security_Origin *o);
+
+/**
+ * Retrieves the quota of a database for a security origin.
+ *
+ * This function won't work if Web SQL Database was not enabled when
+ * building WebKit and will just return 0.
+ *
+ * @param o security origin object
+ *
+ * @return the quota in bytes
+ */
+EAPI uint64_t     ewk_security_origin_web_database_quota_get(const Ewk_Security_Origin *o);
+
+/**
+ * Sets the database usage quota for a security origin.
+ *
+ * This function won't work if Web SQL Database was not enabled when
+ * building WebKit.
+ *
+ * @param o security origin object
+ * @param quota the usage quota in bytes
+ */
+EAPI void         ewk_security_origin_web_database_quota_set(const Ewk_Security_Origin *o, uint64_t quota);
+
+/**
+ * Release all resources allocated by a security origin object.
+ *
+ * @param o security origin object
+ */
+EAPI void         ewk_security_origin_free(Ewk_Security_Origin *o);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_security_origin_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to