break dependency to struct Ewk_Security_Origin (removed ewk_security_origin.h)
authorSeungSeop Park <sns.park@samsung.com>
Mon, 9 Jun 2014 06:31:31 +0000 (15:31 +0900)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
In Webkit2-efl, the definition for struct _Ewk_Security_Origin is hidden in
ewk_security_origin.cpp, and hence it's safe to redefine it as our need.
This commit redefines it as tizen_webview::Security_Origin class.

In addition,
- added tizen_webview::URL class to remove chromium's internal GURL
  class dependency from tizen_webview::Security_Origin api.
- added a utility functions to convert between GURL and tizen_webview::URL

As a result, following files are added:
- src/tizen_webview/public/tw_security_origin.cc|h
- src/tizen_webview/public/tw_url.cc|h
- src/tizen_webview/tw_misc_utility.cc|h

Issue: CBEFL-92
Change-Id: Ic4d73a0a617b830c638fc2f9e5e701dfc7afbead

Conflicts:
impl/API/ewk_notification_private.h
impl/content_main_delegate_efl.cc

17 files changed:
tizen_src/ewk_api_headers/public/ewk_security_origin.h [deleted file]
tizen_src/ewk_api_headers/public/ewk_view.h
tizen_src/impl/API/ewk_geolocation_private.cc [new file with mode: 0644]
tizen_src/impl/API/ewk_geolocation_private.h
tizen_src/impl/API/ewk_notification_private.cc [new file with mode: 0644]
tizen_src/impl/API/ewk_notification_private.h
tizen_src/impl/browser/notification/notification_controller_efl.cc
tizen_src/impl/chromium-efl.gyp
tizen_src/impl/content_browser_client_efl.cc
tizen_src/impl/eweb_context.cc
tizen_src/impl/eweb_context.h
tizen_src/impl/tizen_webview/public/tw_security_origin.cc [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_security_origin.h [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_url.cc [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_url.h [new file with mode: 0644]
tizen_src/impl/tizen_webview/tw_misc_utility.cc [new file with mode: 0644]
tizen_src/impl/tizen_webview/tw_misc_utility.h [new file with mode: 0644]

diff --git a/tizen_src/ewk_api_headers/public/ewk_security_origin.h b/tizen_src/ewk_api_headers/public/ewk_security_origin.h
deleted file mode 100644 (file)
index ffaf4da..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-   Copyright (C) 2013 Samsung Electronics
-
-    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.
-*/
-
-#ifndef ewk_security_origin_h
-#define ewk_security_origin_h
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct _Ewk_Security_Origin Ewk_Security_Origin;
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif // ewk_security_origin_h
index c9cb76b..16a175e 100644 (file)
 #define ewk_view_h
 
 #include <Evas.h>
-#include "ewk_security_origin.h"
 //#include "ewk_intercept_request.h"
 
+namespace tizen_webview {
+class Security_Origin;
+}
+typedef class tizen_webview::Security_Origin Ewk_Security_Origin;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/tizen_src/impl/API/ewk_geolocation_private.cc b/tizen_src/impl/API/ewk_geolocation_private.cc
new file mode 100644 (file)
index 0000000..f41e2ff
--- /dev/null
@@ -0,0 +1,17 @@
+#include "ewk_geolocation_private.h"
+#include "tizen_webview/public/tw_security_origin.h"
+
+
+_Ewk_Geolocation_Permission_Request::_Ewk_Geolocation_Permission_Request(
+    Evas_Object* ewkView, const char* host, const char* protocol, uint16_t port,
+    base::Callback<void(bool)> inCallback)
+  : ewkView(ewkView)
+  , origin(new tizen_webview::Security_Origin(host, protocol, port))
+  , isDecided(false)
+  , isSuspended(false)
+  , callback(inCallback) {
+}
+
+_Ewk_Geolocation_Permission_Request::~_Ewk_Geolocation_Permission_Request() {
+  delete origin;
+}
index bf9979a..13fb067 100644 (file)
 #include <Evas.h>
 
 #include <base/callback.h>
-
-#include "API/ewk_security_origin_private.h"
+#include "tizen_webview/public/tw_security_origin.h"
 
 // This holds the geolocation permission request data.
 // The callback present is the direct engine callback which need
 // to be called once the permission is determined by app.
 struct _Ewk_Geolocation_Permission_Request {
   Evas_Object* ewkView;
-  _Ewk_Security_Origin* origin;
+  tizen_webview::Security_Origin* origin;
   bool isDecided;
   bool isSuspended;
   base::Callback<void(bool)> callback;
 
-  _Ewk_Geolocation_Permission_Request(Evas_Object* ewkView, const char* host, const char* protocol, uint16_t port, base::Callback<void(bool)> inCallback)
-      : ewkView(ewkView)
-      , origin(new _Ewk_Security_Origin (host, protocol, port))
-      , isDecided(false)
-      , isSuspended(false)
-      , callback(inCallback) {
-  }
-
-  ~_Ewk_Geolocation_Permission_Request() {
-    delete origin;
-  }
+  _Ewk_Geolocation_Permission_Request(Evas_Object* ewkView, const char* host, const char* protocol, uint16_t port, base::Callback<void(bool)> inCallback);
+  ~_Ewk_Geolocation_Permission_Request();
 };
 
 #endif // ewk_geolocation_private_h
diff --git a/tizen_src/impl/API/ewk_notification_private.cc b/tizen_src/impl/API/ewk_notification_private.cc
new file mode 100644 (file)
index 0000000..fab9060
--- /dev/null
@@ -0,0 +1,41 @@
+#include "ewk_notification_private.h"
+#include "tizen_webview/public/tw_security_origin.h"
+
+_Ewk_Notification::_Ewk_Notification(
+    const content::ShowDesktopNotificationHostMsgParams& params)
+  : body(eina_stringshare_add((base::UTF16ToUTF8(params.body)).c_str()))
+  , iconURL(eina_stringshare_add((params.icon_url).spec().c_str()))
+  , replaceID(eina_stringshare_add((base::UTF16ToUTF8(params.replace_id)).c_str()))
+  , title(eina_stringshare_add((base::UTF16ToUTF8(params.title)).c_str()))
+#if 0
+  , notificationID(params.notification_id)
+#else
+#warning "[M37] params.notification_id does not exist"
+  , notificationID(0)
+#endif
+  , securityOrigin(new tizen_webview::Security_Origin(
+      params.origin.host().c_str(), params.origin.scheme().c_str(),
+      atoi(params.origin.port().c_str()))) {
+}
+
+_Ewk_Notification::~_Ewk_Notification() {
+  eina_stringshare_del(body);
+  eina_stringshare_del(iconURL);
+  eina_stringshare_del(replaceID);
+  eina_stringshare_del(title);
+  delete securityOrigin;
+}
+
+_Ewk_Notification_Permission_Request::_Ewk_Notification_Permission_Request(
+    Evas_Object* ewkView, int callback, const GURL& source_origin)
+  : ewkView(ewkView)
+  , origin(new tizen_webview::Security_Origin(source_origin.host().c_str(),
+       source_origin.scheme().c_str(), atoi(source_origin.port().c_str())))
+  , isDecided(false)
+  , isSuspended(false)
+  , callback_context(callback) {
+}
+
+_Ewk_Notification_Permission_Request::~_Ewk_Notification_Permission_Request() {
+  delete origin;
+}
index 3e7dc0c..99e887e 100644 (file)
 
 #include "eweb_view.h"
 #include "eweb_context.h"
-#include "API/ewk_security_origin_private.h"
+
+
+namespace tizen_webview {
+  class Security_Origin;
+}
 
 struct _Ewk_Notification {
   Eina_Stringshare* body;
@@ -37,49 +41,23 @@ struct _Ewk_Notification {
   Eina_Stringshare* replaceID;
   Eina_Stringshare* title;
   uint64_t notificationID;
-  _Ewk_Security_Origin* securityOrigin;
+  tizen_webview::Security_Origin* securityOrigin;
 
-  explicit _Ewk_Notification(const content::ShowDesktopNotificationHostMsgParams& params)
-      : body(eina_stringshare_add((base::UTF16ToUTF8(params.body)).c_str())),
-        iconURL(eina_stringshare_add((params.icon_url).spec().c_str())),
-        replaceID(eina_stringshare_add((base::UTF16ToUTF8(params.replace_id)).c_str())),
-        title(eina_stringshare_add((base::UTF16ToUTF8(params.title)).c_str())),
-#if 0
-        notificationID(params.notification_id),
-##else
-#warning "[M37] params no longer has notification_id in it. Is it actually needed?"
-        notificationID(0),
-#endif
-        securityOrigin(new _Ewk_Security_Origin(params.origin.host().c_str(), params.origin.scheme().c_str(), atoi(params.origin.port().c_str()))) {
-  }
+  explicit _Ewk_Notification(const content::ShowDesktopNotificationHostMsgParams& params);
 
-  ~_Ewk_Notification() {
-    eina_stringshare_del(body);
-    eina_stringshare_del(iconURL);
-    eina_stringshare_del(replaceID);
-    eina_stringshare_del(title);
-    delete securityOrigin;
-  }
+  ~_Ewk_Notification();
 };
 
 struct _Ewk_Notification_Permission_Request {
   Evas_Object* ewkView;
-  _Ewk_Security_Origin* origin;
+  tizen_webview::Security_Origin* origin;
   bool isDecided;
   bool isSuspended;
   int callback_context; // required by content API
 
-  _Ewk_Notification_Permission_Request(Evas_Object* ewkView, int callback, const GURL& source_origin)
-      : ewkView(ewkView),
-        origin(new _Ewk_Security_Origin(source_origin.host().c_str(), source_origin.scheme().c_str(), atoi(source_origin.port().c_str()))),
-        isDecided(false),
-        isSuspended(false),
-        callback_context(callback) {
-  }
+  _Ewk_Notification_Permission_Request(Evas_Object* ewkView, int callback, const GURL& source_origin);
 
-  ~_Ewk_Notification_Permission_Request() {
-    delete origin;
-  }
+  ~_Ewk_Notification_Permission_Request();
 };
 
 #endif // ewk_notification_private_h
index 7d5cff2..9f09798 100644 (file)
 #include "content/browser/renderer_host/render_view_host_impl.h"
 #include "content/public/browser/web_contents.h"
 
-#include "API/ewk_security_origin_private.h"
 #include "API/ewk_notification_private.h"
 #include "eweb_view.h"
 
+#include "tizen_webview/public/tw_security_origin.h"
+#include "tizen_webview/tw_misc_utility.h"
+
+using tizen_webview::Security_Origin;
+using tizen_webview::GetGURL;
+using tizen_webview::GetURL;
+
 namespace content {
 
 NotificationControllerEfl::NotificationControllerEfl()
@@ -100,13 +106,13 @@ void NotificationControllerEfl::RemoveStoredOrigins(Eina_List* origins) {
   Eina_List* origin_iterator = NULL;
   void* origin_data = NULL;
   EINA_LIST_FOREACH(origins, origin_iterator, origin_data) {
-    _Ewk_Security_Origin* origin = static_cast<_Ewk_Security_Origin*>(origin_data);
+    Security_Origin* origin = static_cast<Security_Origin*>(origin_data);
     Eina_List* permission_list_iterator = NULL;
     Eina_List* permission_list_iterator_next = NULL;
     void* permission_data = NULL;
     EINA_LIST_FOREACH_SAFE(ewk_notification_permissions_, permission_list_iterator, permission_list_iterator_next, permission_data) {
       Ewk_Notification_Permission* notification_permission = static_cast<Ewk_Notification_Permission*>(permission_data);
-      if (!strcmp(notification_permission->origin, origin->host)) {
+      if (!strcmp(notification_permission->origin, origin->GetHost())) {
         delete notification_permission;
         ewk_notification_permissions_ = eina_list_remove_list(ewk_notification_permissions_, permission_list_iterator);
       }
index 0e3f2fe..fe42f5c 100644 (file)
       'API/ewk_error_private.h',
       'API/ewk_frame_private.h',
       'API/ewk_frame_private.cc',
+      'API/ewk_geolocation_private.cc',
       'API/ewk_geolocation_private.h',
       'API/ewk_hit_test_private.cc',
       'API/ewk_hit_test_private.h',
       'API/ewk_ipc_message_private.cc',
       'API/ewk_ipc_message_private.h',
+      'API/ewk_notification_private.cc',
       'API/ewk_notification_private.h',
       'API/ewk_policy_decision_private.cc',
       'API/ewk_policy_decision_private.h',
       # tizen_webview
       '<(chrome_src_dir)/tizen_webview/public/tw_custom_handlers.h',
       '<(chrome_src_dir)/tizen_webview/public/tw_custom_handlers.cc',
+      '<(chrome_src_dir)/tizen_webview/public/tw_security_origin.cc',
+      '<(chrome_src_dir)/tizen_webview/public/tw_security_origin.h',
       '<(chrome_src_dir)/tizen_webview/public/tw_touch_point.h',
       '<(chrome_src_dir)/tizen_webview/public/tw_touch_point.cc',
+      '<(chrome_src_dir)/tizen_webview/public/tw_url.cc',
+      '<(chrome_src_dir)/tizen_webview/public/tw_url.h',
+      '<(chrome_src_dir)/tizen_webview/tw_misc_utility.h',
+      '<(chrome_src_dir)/tizen_webview/tw_misc_utility.cc',
       'url_request_context_getter_efl.cc',
       'url_request_context_getter_efl.h',
       'web_contents_delegate_efl.cc',
index bf23ed5..c3e523b 100644 (file)
@@ -37,6 +37,8 @@
 #include "browser/geolocation/location_provider_efl.h"
 #endif
 
+#include "tizen_webview/public/tw_security_origin.h"
+
 using web_contents_utils::WebContentsFromFrameID;
 
 namespace content {
@@ -134,7 +136,7 @@ void ContentBrowserClientEfl::RequestDesktopNotificationPermission(
          delegate->web_view()->evas_object(), callback_context, source_origin);
 
   if (browser_context->GetNotificationController()->
-        IsDefaultAllowed(notification_permission->origin->host)) {
+        IsDefaultAllowed(notification_permission->origin->GetHost())) {
     browser_context->GetNotificationController()->
         SetPermissionForNotification(notification_permission, true);
     delete notification_permission;
index b984f16..4b30faa 100644 (file)
 #include "browser_context_efl.h"
 #include "ewk_global_data.h"
 #include "memory_purger.h"
-#include "API/ewk_security_origin_private.h"
 #include "browser/renderer_host/browsing_data_remover_efl.h"
 #include "browser/vibration/vibration_provider_client.h"
 #include "common/render_messages_efl.h"
 
+#include "tizen_webview/public/tw_security_origin.h"
+#include "tizen_webview/tw_misc_utility.h"
+
 using content::BrowserThread;
 using content::BrowserContext;
 using content::BrowserContextEfl;
@@ -53,6 +55,9 @@ using std::pair;
 using std::map;
 
 using tizen_webview::Cache_Model;
+using tizen_webview::Security_Origin;
+using tizen_webview::GetGURL;
+using tizen_webview::GetURL;
 
 namespace {
 
@@ -76,7 +81,7 @@ public:
     std::vector<content::LocalStorageUsageInfo>::const_iterator it;
 
     for (it = local_storage.begin(); it != local_storage.end(); it++) {
-      _Ewk_Security_Origin* origin = new _Ewk_Security_Origin(it->origin);
+      Security_Origin* origin = new Security_Origin(GetURL(it->origin));
       lorigins = eina_list_append(lorigins, origin);
     }
 
@@ -124,7 +129,7 @@ void OnOriginsWithApplicationCacheObtained(tizen_webview::Web_Application_Cache_
   for (map<GURL, appcache::AppCacheInfoVector>::iterator iter = collection->infos_by_origin.begin();
       iter != collection->infos_by_origin.end();
       ++iter) {
-    _Ewk_Security_Origin* origin = new _Ewk_Security_Origin(iter->first);
+    Security_Origin* origin = new Security_Origin(GetURL(iter->first));
     origins = eina_list_append(origins, origin);
   }
   callback(origins, user_data);
@@ -154,7 +159,7 @@ void OnGetWebDBOrigins(
   for (std::set<GURL>::iterator iter =
          origins_ref.begin();
          iter != origins_ref.end(); ++iter) {
-      _Ewk_Security_Origin* sec_origin = new _Ewk_Security_Origin(*iter);
+      Security_Origin* sec_origin = new Security_Origin(GetURL(*iter));
       origins = eina_list_append(origins, sec_origin);
   }
   BrowserThread::PostTask(BrowserThread::UI,
@@ -179,7 +184,7 @@ void OnGetFileSystemOrigins(
   for (std::set<GURL>::iterator iter =
          origins_ref.begin();
          iter != origins_ref.end(); ++iter) {
-      _Ewk_Security_Origin* sec_origin = new _Ewk_Security_Origin(*iter);
+      Security_Origin* sec_origin = new Security_Origin(GetURL(*iter));
       origins = eina_list_append(origins, sec_origin);
   }
   BrowserThread::PostTask(BrowserThread::UI,
@@ -376,12 +381,12 @@ void EWebContext::DeleteAllApplicationCache() {
   BrowserContext::ForEachStoragePartition(browser_context_.get(), base::Bind(&DeleteApplicationCache));
 }
 
-void EWebContext::DeleteApplicationCacheForSite(const GURL& site) {
+void EWebContext::DeleteApplicationCacheForSite(const tizen_webview::URL& site) {
   content::StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(browser_context_.get(),
-                                                                                    site);
+                                                                                    GetGURL(site));
   partition->ClearDataForOrigin(content::StoragePartition::REMOVE_DATA_MASK_APPCACHE,
                                 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
-                                site,
+                                GetGURL(site),
                                 partition->GetURLRequestContext());
 }
 
@@ -399,7 +404,7 @@ void EWebContext::GetAllOriginsWithApplicationCache(tizen_webview::Web_Applicati
 }
 
 void EWebContext::GetApplicationCacheUsage(
-    const GURL& url,
+    const tizen_webview::URL& url,
     tizen_webview::Web_Application_Cache_Usage_For_Origin_Get_Callback callback,
     void* user_data) {
   content::StoragePartition* partition =
@@ -410,7 +415,7 @@ void EWebContext::GetApplicationCacheUsage(
       FROM_HERE,
       base::Bind(&quota::QuotaManager::GetUsageAndQuota,
                  partition->GetQuotaManager(),
-                 url,
+                 GetGURL(url),
                  quota::kStorageTypeTemporary,
                  base::Bind(&OnTemporaryUsageAndQuotaObtained, callback, user_data)));
 }
@@ -420,11 +425,11 @@ void EWebContext::WebStorageDelete() {
   remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_LOCAL_STORAGE, GURL());
 }
 
-void EWebContext::WebStorageDelete(const GURL& origin) {
+void EWebContext::WebStorageDelete(const tizen_webview::URL& origin) {
   content::StoragePartition* partition =
       BrowserContext::GetStoragePartition(browser_context_.get(), NULL);
 
-  partition->GetDOMStorageContext()->DeleteLocalStorage(origin);
+  partition->GetDOMStorageContext()->DeleteLocalStorage(GetGURL(origin));
 }
 
 void EWebContext::WebStorageOriginsAllGet(tizen_webview::Web_Storage_Origins_Get_Callback callback,
@@ -442,9 +447,9 @@ void EWebContext::IndexedDBDelete() {
   remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_INDEXEDDB, GURL());
 }
 
-void EWebContext::WebDBDelete(const GURL& host) {
+void EWebContext::WebDBDelete(const tizen_webview::URL& host) {
   BrowsingDataRemoverEfl* remover = BrowsingDataRemoverEfl::CreateForUnboundedRange(browser_context_.get());
-  remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_WEBSQL, host);
+  remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_WEBSQL, GetGURL(host));
 }
 
 void EWebContext::GetAllOriginsWithWebDB(tizen_webview::Web_Database_Origins_Get_Callback callback, void* user_data) {
@@ -456,9 +461,9 @@ void EWebContext::GetAllOriginsWithWebDB(tizen_webview::Web_Database_Origins_Get
                  callback, user_data, partition));
 }
 
-void EWebContext::FileSystemDelete(const GURL& host) {
+void EWebContext::FileSystemDelete(const tizen_webview::URL& host) {
   BrowsingDataRemoverEfl* remover = BrowsingDataRemoverEfl::CreateForUnboundedRange(browser_context_.get());
-  remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_FILE_SYSTEMS, host);
+  remover->RemoveImpl(BrowsingDataRemoverEfl::REMOVE_FILE_SYSTEMS, GetGURL(host));
 }
 
 void EWebContext::GetAllOriginsWithFileSystem(tizen_webview::Local_File_System_Origins_Get_Callback callback, void* user_data) const {
@@ -491,3 +496,4 @@ Evas_Object *EWebContext::AddFaviconObject(const char* uri, Evas* canvas) const
 
   return favicon;
 }
+
index 5d412d6..f6dfc5d 100644 (file)
 #include "tizen_webview/public/tw_cache_model.h"
 #include "tizen_webview/public/tw_callbacks.h"
 
+namespace tizen_webview {
+class URL;
+}
+
 typedef std::map<std::string, std::string> HTTPCustomHeadersEflMap;
 
 class CookieManager;
@@ -84,20 +88,20 @@ class EWebContext : public EWebObject {
                                    void* user_data);
   EwkDidStartDownloadCallback* DidStartDownloadCallback();
   void DeleteAllApplicationCache();
-  void DeleteApplicationCacheForSite(const GURL&);
+  void DeleteApplicationCacheForSite(const tizen_webview::URL&);
   void GetAllOriginsWithApplicationCache(tizen_webview::Web_Application_Cache_Origins_Get_Callback callback,
                                          void* user_data);
   void GetApplicationCacheUsage(
-      const GURL& url,
+      const tizen_webview::URL& url,
       tizen_webview::Web_Application_Cache_Usage_For_Origin_Get_Callback callback,
       void* user_data);
   void GetAllOriginsWithWebDB(tizen_webview::Web_Database_Origins_Get_Callback callback, void* user_data);
-  void WebDBDelete(const GURL& host);
+  void WebDBDelete(const tizen_webview::URL& host);
   void IndexedDBDelete();
   void WebStorageDelete();
-  void WebStorageDelete(const GURL& origin);
+  void WebStorageDelete(const tizen_webview::URL& origin);
   void WebStorageOriginsAllGet(tizen_webview::Web_Storage_Origins_Get_Callback callback, void* user_data);
-  void FileSystemDelete(const GURL& host);
+  void FileSystemDelete(const tizen_webview::URL& host);
   void GetAllOriginsWithFileSystem(tizen_webview::Local_File_System_Origins_Get_Callback callback, void* user_data) const;
   bool SetFaviconDatabasePath(const char* path);
   Evas_Object *AddFaviconObject(const char* uri, Evas* canvas) const;
diff --git a/tizen_src/impl/tizen_webview/public/tw_security_origin.cc b/tizen_src/impl/tizen_webview/public/tw_security_origin.cc
new file mode 100644 (file)
index 0000000..3b80cab
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tw_security_origin.h"
+#include "tizen_webview/public/tw_url.h"
+
+namespace tizen_webview {
+
+Security_Origin::Security_Origin(const tizen_webview::URL& url)
+  : host(eina_stringshare_add(url.getHost()))
+  , protocol(eina_stringshare_add(url.getProtocol()))
+  , port(url.getPort()) {
+}
+
+Security_Origin::Security_Origin(const char* host_in, const char* protocol_in, int port_in)
+  : host(eina_stringshare_add(host_in))
+  , protocol(eina_stringshare_add(protocol_in))
+  , port(port_in) {
+}
+
+Security_Origin::~Security_Origin() {
+  eina_stringshare_del(host);
+  eina_stringshare_del(protocol);
+}
+
+tizen_webview::URL Security_Origin::GetURL() const {
+  return tizen_webview::URL(protocol, host, port);
+}
+
+Eina_Stringshare* Security_Origin::GetHost() const {
+  return host;
+}
+
+Eina_Stringshare* Security_Origin::GetProtocol() const {
+  return protocol;
+}
+
+int Security_Origin::GetPort() const {
+  return port;
+}
+
+} // namespace tizen_webview
diff --git a/tizen_src/impl/tizen_webview/public/tw_security_origin.h b/tizen_src/impl/tizen_webview/public/tw_security_origin.h
new file mode 100644 (file)
index 0000000..723328d
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TIZEN_WEBVIEW_PUBLIC_TW_SECURITY_ORIGIN_H_
+#define TIZEN_WEBVIEW_PUBLIC_TW_SECURITY_ORIGIN_H_
+
+#include <Eina.h>
+
+namespace tizen_webview {
+
+class URL;
+
+class Security_Origin {
+ public:
+  Security_Origin(const tizen_webview::URL& url);
+  Security_Origin(const char* host_in, const char* protocol_in, int port_in);
+  ~Security_Origin();
+
+  tizen_webview::URL GetURL() const;
+  Eina_Stringshare* GetHost() const;
+  Eina_Stringshare* GetProtocol() const;
+  int GetPort() const;
+
+ private:
+  Eina_Stringshare* host;
+  Eina_Stringshare* protocol;
+  int port;
+
+  // Just for safety in using Eina_Stringshare, disallow copy constructor and
+  // assignment for now.
+  // TODO: Need to revisit and add proper implementation.
+  Security_Origin(const Security_Origin&);
+  Security_Origin& operator=(const Security_Origin&);
+};
+
+} // namespace tizen_webview
+
+#endif  // TIZEN_WEBVIEW_PUBLIC_TW_SECURITY_ORIGIN_H_
diff --git a/tizen_src/impl/tizen_webview/public/tw_url.cc b/tizen_src/impl/tizen_webview/public/tw_url.cc
new file mode 100644 (file)
index 0000000..72c6f28
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tw_url.h"
+
+namespace tizen_webview {
+
+URL::URL()
+  : protocol()
+  , host()
+  , port(PORT_UNSPECIFIED) { // url_parse::PORT_INVALID
+}
+
+URL::URL(const std::string& host_)
+  : protocol()
+  , host(host_)
+  , port(PORT_UNSPECIFIED) { // url_parse::PORT_INVALID
+}
+
+URL::URL(const std::string& protocol_, const std::string& host_, int port_)
+  : protocol(protocol_)
+  , host(host_)
+  , port(port_) {
+}
+
+} // namespace tizen_webview
diff --git a/tizen_src/impl/tizen_webview/public/tw_url.h b/tizen_src/impl/tizen_webview/public/tw_url.h
new file mode 100644 (file)
index 0000000..909be7a
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TIZEN_WEBVIEW_PUBLIC_TW_URL_H_
+#define TIZEN_WEBVIEW_PUBLIC_TW_URL_H_
+
+#include <string>
+
+namespace tizen_webview {
+
+class URL {
+ public:
+  enum {
+    PORT_UNSPECIFIED = -1,
+    PORT_INVALID = -2
+  };
+
+  URL();
+  explicit URL(const std::string& host_);
+  URL(const std::string& protocol_, const std::string& host_, int port_);
+
+  const char* getProtocol() const { return protocol.c_str(); }
+  const char* getHost() const { return host.c_str(); }
+  int         getPort() const { return port; }
+
+  bool isPortInvalid() const { return port == PORT_INVALID; }
+  bool isPortUnspecified() const { return port == PORT_UNSPECIFIED; }
+
+ private:
+  std::string protocol;
+  std::string host;
+  int port;
+};
+
+} // namespace tizen_webview
+
+#endif  // TIZEN_WEBVIEW_PUBLIC_TW_URL_H_
diff --git a/tizen_src/impl/tizen_webview/tw_misc_utility.cc b/tizen_src/impl/tizen_webview/tw_misc_utility.cc
new file mode 100644 (file)
index 0000000..c055ea4
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tw_misc_utility.h"
+
+#include <sstream>
+
+namespace tizen_webview {
+
+GURL GetGURL(const URL& url) {
+  std::ostringstream ss;
+  ss << url.getProtocol() << "://" << url.getHost();
+  if (!url.isPortUnspecified())
+    ss << ":" << url.getPort();
+  GURL result(ss.str());
+  assert(result.is_valid());
+  return result;
+}
+
+URL GetURL(const GURL& url) {
+  return URL(url.scheme(), url.host(), url.IntPort());
+}
+
+} // namespace tizen_webview
diff --git a/tizen_src/impl/tizen_webview/tw_misc_utility.h b/tizen_src/impl/tizen_webview/tw_misc_utility.h
new file mode 100644 (file)
index 0000000..399a2c4
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TIZEN_WEBVIEW_PUBLIC_TW_MISC_UTILITY_H_
+#define TIZEN_WEBVIEW_PUBLIC_TW_MISC_UTILITY_H_
+
+#include "url/gurl.h"
+#include "tizen_webview/public/tw_url.h"
+
+namespace tizen_webview {
+
+GURL GetGURL(const tizen_webview::URL& url);
+tizen_webview::URL  GetURL(const GURL& url);
+
+} // namespace tizen_webview
+
+#endif  // TIZEN_WEBVIEW_PUBLIC_TW_MISC_UTILITY_H_