From ef05386d4f3cdb5c9e368e5b61305a292fcc26a7 Mon Sep 17 00:00:00 2001 From: Arnaud Renevier Date: Wed, 11 Mar 2015 15:25:09 -0700 Subject: [PATCH] Remove tw_security_origin.h Use _Ewk_Security_Origin struct directly instead of tizen_webview::Security_Origin Change-Id: I44c08d968288af28edd14e60834eb1236a024d8c Signed-off-by: Arnaud Renevier --- .../notification/notification_controller_efl.cc | 6 +- .../efl_integration/content_browser_client_efl.cc | 2 - tizen_src/ewk/efl_integration/efl_integration.gypi | 2 - tizen_src/ewk/efl_integration/eweb_context.cc | 12 ++-- .../private/ewk_geolocation_private.cc | 4 +- .../private/ewk_geolocation_private.h | 7 ++- .../private/ewk_notification_private.cc | 8 +-- .../private/ewk_notification_private.h | 10 ++-- .../private/ewk_security_origin_private.cc | 54 ++++++++++++++++++ .../private/ewk_security_origin_private.h | 25 ++++++++- .../ewk/efl_integration/public/ewk_context.cc | 1 - .../efl_integration/public/ewk_security_origin.cc | 2 +- .../tizen_webview/public/tw_callbacks.h | 9 ++- .../tizen_webview/public/tw_security_origin.cc | 65 ---------------------- .../tizen_webview/public/tw_security_origin.h | 42 -------------- 15 files changed, 104 insertions(+), 145 deletions(-) delete mode 100644 tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.cc delete mode 100644 tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.h diff --git a/tizen_src/ewk/efl_integration/browser/notification/notification_controller_efl.cc b/tizen_src/ewk/efl_integration/browser/notification/notification_controller_efl.cc index 8eedcf3..14472cb 100644 --- a/tizen_src/ewk/efl_integration/browser/notification/notification_controller_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/notification/notification_controller_efl.cc @@ -11,9 +11,8 @@ #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/public/browser/web_contents.h" #include "private/ewk_notification_private.h" -#include "tizen_webview/public/tw_security_origin.h" +#include "private/ewk_security_origin_private.h" -using tizen_webview::Security_Origin; using web_contents_utils::WebViewFromWebContents; namespace content { @@ -120,8 +119,7 @@ void NotificationControllerEfl::RemovePermissions(Eina_List* origins) { void* data = NULL; base::AutoLock locker(permissions_mutex_); EINA_LIST_FOREACH(origins, list, data) { - tizen_webview::Security_Origin* origin = - static_cast(data); + _Ewk_Security_Origin* origin = static_cast<_Ewk_Security_Origin*>(data); permissions_map_.erase(origin->GetURL()); } } diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index 45ce932..9c23e13 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -38,9 +38,7 @@ #include "browser/notification/notification_controller_efl.h" #include "private/ewk_notification_private.h" -#include "tizen_webview/public/tw_security_origin.h" -using tizen_webview::Security_Origin; using web_contents_utils::WebContentsFromFrameID; using web_contents_utils::WebContentsFromViewID; using web_contents_utils::WebViewFromWebContents; diff --git a/tizen_src/ewk/efl_integration/efl_integration.gypi b/tizen_src/ewk/efl_integration/efl_integration.gypi index e1aa2b3..8100738 100644 --- a/tizen_src/ewk/efl_integration/efl_integration.gypi +++ b/tizen_src/ewk/efl_integration/efl_integration.gypi @@ -438,7 +438,6 @@ 'tizen_webview/public/tw_frame.h', 'tizen_webview/public/tw_webview_delegate.h', 'tizen_webview/public/tw_context_menu_controller.h', - 'tizen_webview/public/tw_security_origin.cc', 'tizen_webview/public/tw_selection_controller.h', 'tizen_webview/public/tw_selection_controller.cc', 'tizen_webview/public/tw_hit_test.h', @@ -450,7 +449,6 @@ #'tizen_webview/public/tw_webview_evas_event_handler.cc', 'tizen_webview/public/tw_webview.h', 'tizen_webview/public/tw_hit_test.cc', - 'tizen_webview/public/tw_security_origin.h', 'tizen_webview/public/tw_webview.cc', 'tizen_webview/public/tw_web_context.cc', 'tizen_webview/public/tw_error.h', diff --git a/tizen_src/ewk/efl_integration/eweb_context.cc b/tizen_src/ewk/efl_integration/eweb_context.cc index 7be5aeb..3e937e9 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.cc +++ b/tizen_src/ewk/efl_integration/eweb_context.cc @@ -35,8 +35,7 @@ #include "browser/browsing_data_remover_efl.h" #include "browser/vibration/vibration_provider_client.h" #include "content/common/render_messages_efl.h" - -#include "tizen_webview/public/tw_security_origin.h" +#include "private/ewk_security_origin_private.h" #include "wrt/wrt_widget_host.h" @@ -49,7 +48,6 @@ using std::pair; using std::map; using tizen_webview::Cache_Model; -using tizen_webview::Security_Origin; EWebContext* EWebContext::default_context_ = NULL; @@ -75,7 +73,7 @@ public: std::vector::const_iterator it; for (it = local_storage.begin(); it != local_storage.end(); it++) { - Security_Origin* origin = new Security_Origin(it->origin); + _Ewk_Security_Origin* origin = new _Ewk_Security_Origin(it->origin); lorigins = eina_list_append(lorigins, origin); } @@ -105,7 +103,7 @@ void OnOriginsWithApplicationCacheObtained(tizen_webview::Web_Application_Cache_ for (map::iterator iter = collection->infos_by_origin.begin(); iter != collection->infos_by_origin.end(); ++iter) { - Security_Origin* origin = new Security_Origin(iter->first); + _Ewk_Security_Origin* origin = new _Ewk_Security_Origin(iter->first); origins = eina_list_append(origins, origin); } callback(origins, user_data); @@ -135,7 +133,7 @@ void OnGetWebDBOrigins( for (std::set::iterator iter = origins_ref.begin(); iter != origins_ref.end(); ++iter) { - Security_Origin* sec_origin = new Security_Origin(*iter); + _Ewk_Security_Origin* sec_origin = new _Ewk_Security_Origin(*iter); origins = eina_list_append(origins, sec_origin); } BrowserThread::PostTask(BrowserThread::UI, @@ -160,7 +158,7 @@ void OnGetFileSystemOrigins( for (std::set::iterator iter = origins_ref.begin(); iter != origins_ref.end(); ++iter) { - Security_Origin* sec_origin = new Security_Origin(*iter); + _Ewk_Security_Origin* sec_origin = new _Ewk_Security_Origin(*iter); origins = eina_list_append(origins, sec_origin); } BrowserThread::PostTask(BrowserThread::UI, diff --git a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc index c210b72..c7f5ca3 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ewk_geolocation_private.h" -#include "tizen_webview/public/tw_security_origin.h" +#include "private/ewk_security_origin_private.h" #include @@ -13,7 +13,7 @@ _Ewk_Geolocation_Permission_Request::_Ewk_Geolocation_Permission_Request( const char* host, const char* protocol, uint16_t port, base::Callback callback) : Ewk_Suspendable_Object(callback) - , origin_(new tizen_webview::Security_Origin(host, protocol, port)) { + , origin_(new _Ewk_Security_Origin(host, protocol, port)) { } _Ewk_Geolocation_Permission_Request::~_Ewk_Geolocation_Permission_Request() { diff --git a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h index 54fd995..c04ba8d 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h @@ -7,7 +7,8 @@ #include "base/callback.h" #include "ewk_suspendable_object.h" -#include "tizen_webview/public/tw_security_origin.h" + +class _Ewk_Security_Origin; // This holds the geolocation permission request data. // The callback present is the direct engine callback which need @@ -19,10 +20,10 @@ class _Ewk_Geolocation_Permission_Request : public Ewk_Suspendable_Object{ base::Callback callback); ~_Ewk_Geolocation_Permission_Request(); - tizen_webview::Security_Origin* GetOrigin() const { return origin_; } + _Ewk_Security_Origin* GetOrigin() const { return origin_; } private: - tizen_webview::Security_Origin* origin_; + _Ewk_Security_Origin* origin_; }; #endif // ewk_geolocation_private_h diff --git a/tizen_src/ewk/efl_integration/private/ewk_notification_private.cc b/tizen_src/ewk/efl_integration/private/ewk_notification_private.cc index 293cfdc..ee08dea 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_notification_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_notification_private.cc @@ -20,7 +20,7 @@ Ewk_Notification::Ewk_Notification( , replaceID_(replaceID) , title_(title) , notificationID_(notificationID) - , origin_(new tizen_webview::Security_Origin(origin)) { + , origin_(new _Ewk_Security_Origin(origin)) { } Ewk_Notification::~Ewk_Notification() { @@ -60,7 +60,7 @@ int Ewk_Notification::GetID() const { return notificationID_; } -const tizen_webview::Security_Origin* Ewk_Notification::GetSecurityOrigin() const { +const _Ewk_Security_Origin* Ewk_Notification::GetSecurityOrigin() const { return origin_.get(); } @@ -70,7 +70,7 @@ Ewk_Notification_Permission_Request::Ewk_Notification_Permission_Request( const base::Callback& callback, const GURL& source_origin) : webview_(webview) - , origin_(new tizen_webview::Security_Origin(source_origin)) + , origin_(new _Ewk_Security_Origin(source_origin)) , callback_(callback) , decided_(false) , suspended_(false) @@ -84,7 +84,7 @@ Evas_Object* Ewk_Notification_Permission_Request::GetWebviewEvasObject() const { return webview_; } -const tizen_webview::Security_Origin* Ewk_Notification_Permission_Request::GetSecurityOrigin() const { +const _Ewk_Security_Origin* Ewk_Notification_Permission_Request::GetSecurityOrigin() const { return origin_.get(); } diff --git a/tizen_src/ewk/efl_integration/private/ewk_notification_private.h b/tizen_src/ewk/efl_integration/private/ewk_notification_private.h index 4a33ae0..d75e057 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_notification_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_notification_private.h @@ -10,10 +10,10 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" +#include "private/ewk_security_origin_private.h" #include "third_party/skia/include/core/SkBitmap.h" #include "tizen_webview/public/tw_macro.h" -#include "tizen_webview/public/tw_security_origin.h" class GURL; @@ -32,7 +32,7 @@ struct Ewk_Notification { const char* GetTitle() const; Evas_Object* GetIcon(Evas* evas) const; int GetID() const; - const tizen_webview::Security_Origin* GetSecurityOrigin() const; + const _Ewk_Security_Origin* GetSecurityOrigin() const; private: std::string body_; @@ -40,7 +40,7 @@ struct Ewk_Notification { std::string replaceID_; std::string title_; uint64_t notificationID_; - scoped_ptr origin_; + scoped_ptr<_Ewk_Security_Origin> origin_; DISALLOW_COPY_AND_ASSIGN(Ewk_Notification); @@ -54,7 +54,7 @@ struct Ewk_Notification_Permission_Request { ~Ewk_Notification_Permission_Request(); Evas_Object* GetWebviewEvasObject() const; - const tizen_webview::Security_Origin* GetSecurityOrigin() const; + const _Ewk_Security_Origin* GetSecurityOrigin() const; bool IsDecided() const; bool IsSuspended() const; bool SetSuspend(bool suspend) const; @@ -62,7 +62,7 @@ struct Ewk_Notification_Permission_Request { private: Evas_Object* webview_; - scoped_ptr origin_; + scoped_ptr<_Ewk_Security_Origin> origin_; base::Callback callback_; bool decided_; mutable bool suspended_; diff --git a/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.cc b/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.cc index 63157f9..82f78fb 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.cc @@ -4,3 +4,57 @@ #include "ewk_security_origin_private.h" +#include + +_Ewk_Security_Origin::_Ewk_Security_Origin(const GURL& url) + : url_(url) { + host_ = eina_stringshare_add(url_.host().c_str()); + protocol_ = eina_stringshare_add(url_.scheme().c_str()); +} + +_Ewk_Security_Origin::_Ewk_Security_Origin(const char* host, const char* protocol, int port) { + if (!host) { + url_ = GURL(""); + } else { + std::ostringstream ss; + ss << protocol << "://" << port; + if (port != url::PORT_UNSPECIFIED) { + ss << ":" << port; + } + url_ = GURL(ss.str()); + } + host_ = eina_stringshare_add(url_.host().c_str()); + protocol_ = eina_stringshare_add(url_.scheme().c_str()); +} + +_Ewk_Security_Origin::~_Ewk_Security_Origin() { + eina_stringshare_del(host_); + eina_stringshare_del(protocol_); +} + +GURL _Ewk_Security_Origin::GetURL() const { + return url_; +} + +Eina_Stringshare* _Ewk_Security_Origin::GetHost() const { + return host_; +} + +Eina_Stringshare* _Ewk_Security_Origin::GetProtocol() const { + return protocol_; +} + +int _Ewk_Security_Origin::GetPort() const { + return url_.IntPort(); +} + +_Ewk_Security_Origin* _Ewk_Security_Origin::CreateFromString(const char *url) { + if (!url) + return 0; + + GURL gurl(url); + if (gurl.is_empty() || !gurl.is_valid()) + return 0; + + return new _Ewk_Security_Origin(gurl); +} diff --git a/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.h b/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.h index 42ee835..5e1dbe9 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_security_origin_private.h @@ -12,7 +12,6 @@ #include "base/callback.h" #include "url/gurl.h" -#include // Security Origin Structure struct __Ewk_Security_Origin { @@ -52,8 +51,30 @@ struct __Ewk_Security_Origin { }; // chromium-efl implementation for _Ewk_Security_Origin -struct _Ewk_Security_Origin : tizen_webview::Security_Origin +struct _Ewk_Security_Origin { + public: + _Ewk_Security_Origin(const GURL& url); + _Ewk_Security_Origin(const char* host, const char* protocol, int port); + ~_Ewk_Security_Origin(); + + GURL GetURL() const; + Eina_Stringshare* GetHost() const; + Eina_Stringshare* GetProtocol() const; + int GetPort() const; + + static _Ewk_Security_Origin* CreateFromString(const char* url); + + private: + GURL url_; + Eina_Stringshare* host_; + Eina_Stringshare* protocol_; + + // Just for safety in using Eina_Stringshare, disallow copy constructor and + // assignment for now. + // TODO: Need to revisit and add proper implementation. + _Ewk_Security_Origin(const _Ewk_Security_Origin&); + _Ewk_Security_Origin& operator=(const _Ewk_Security_Origin&); }; #endif // ewk_security_origin_private_h diff --git a/tizen_src/ewk/efl_integration/public/ewk_context.cc b/tizen_src/ewk/efl_integration/public/ewk_context.cc index 91a8911..d77bd19 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_context.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_context.cc @@ -4,7 +4,6 @@ #include "ewk_context.h" -#include #include #include "base/memory/ref_counted.h" diff --git a/tizen_src/ewk/efl_integration/public/ewk_security_origin.cc b/tizen_src/ewk/efl_integration/public/ewk_security_origin.cc index 33d23dc..e5779e9 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_security_origin.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_security_origin.cc @@ -50,6 +50,6 @@ void ewk_security_origin_free(Ewk_Security_Origin *o) Ewk_Security_Origin *ewk_security_origin_new_from_string(const char *url) { - return static_cast(tizen_webview::Security_Origin::CreateFromString(url)); + return static_cast(_Ewk_Security_Origin::CreateFromString(url)); } diff --git a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_callbacks.h b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_callbacks.h index 2866cc7..2611b95 100644 --- a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_callbacks.h +++ b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_callbacks.h @@ -12,7 +12,6 @@ class Ewk_Notification_Permission_Request; namespace tizen_webview { class Hit_Test; -class Security_Origin; // from ewk_context.h typedef void (*Local_File_System_Origins_Get_Callback)(Eina_List *origins, void *user_data); @@ -108,10 +107,10 @@ typedef Eina_Bool (*View_JavaScript_Confirm_Callback)(Evas_Object* o, const char */ typedef Eina_Bool (*View_JavaScript_Prompt_Callback)(Evas_Object* o, const char* message, const char* default_value, void* user_data); //typedef Eina_Bool (*View_Before_Unload_Confirm_Panel_Callback)(Evas_Object* o, const char* message, void* user_data); -//typedef Eina_Bool (*View_Applicacion_Cache_Permission_Callback)(Evas_Object* o, Security_Origin* origin, void* user_data); -//typedef Eina_Bool (*View_Exceeded_Indexed_Database_Quota_Callback)(Evas_Object* o, Security_Origin* origin, long long currentQuota, void* user_data); -//typedef Eina_Bool (*View_Exceeded_Database_Quota_Callback)(Evas_Object* o, Security_Origin* origin, const char* database_name, unsigned long long expectedQuota, void* user_data); -//typedef Eina_Bool (*View_Exceeded_Local_File_System_Quota_Callback)(Evas_Object* o, Security_Origin* origin, long long currentQuota, void* user_data); +//typedef Eina_Bool (*View_Applicacion_Cache_Permission_Callback)(Evas_Object* o, Ewk_Security_Origin* origin, void* user_data); +//typedef Eina_Bool (*View_Exceeded_Indexed_Database_Quota_Callback)(Evas_Object* o, Ewk_Security_Origin* origin, long long currentQuota, void* user_data); +//typedef Eina_Bool (*View_Exceeded_Database_Quota_Callback)(Evas_Object* o, Ewk_Security_Origin* origin, const char* database_name, unsigned long long expectedQuota, void* user_data); +//typedef Eina_Bool (*View_Exceeded_Local_File_System_Quota_Callback)(Evas_Object* o, Ewk_Security_Origin* origin, long long currentQuota, void* user_data); typedef Eina_Bool (*Orientation_Lock_Cb)(Evas_Object* o, Eina_Bool need_lock, int orientation, void* user_data); typedef void (*View_Hit_Test_Request_Callback)(Evas_Object* o, int x, int y, int hit_test_mode, Hit_Test* hit_test, void* user_data); typedef Eina_Bool (*View_Geolocation_Permission_Callback)(Evas_Object* view, void* geolocation_permission_context, void* user_data); diff --git a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.cc b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.cc deleted file mode 100644 index 44fef04..0000000 --- a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. -// Copyright 2014 Samsung Electronics. 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 - -namespace tizen_webview { - -Security_Origin::Security_Origin(const GURL& url) - : url_(url) { - host_ = eina_stringshare_add(url_.host().c_str()); - protocol_ = eina_stringshare_add(url_.scheme().c_str()); -} - -Security_Origin::Security_Origin(const char* host, const char* protocol, int port) { - if (!host) { - url_ = GURL(""); - } else { - std::ostringstream ss; - ss << protocol << "://" << port; - if (port != url::PORT_UNSPECIFIED) { - ss << ":" << port; - } - url_ = GURL(ss.str()); - } - host_ = eina_stringshare_add(url_.host().c_str()); - protocol_ = eina_stringshare_add(url_.scheme().c_str()); -} - -Security_Origin::~Security_Origin() { - eina_stringshare_del(host_); - eina_stringshare_del(protocol_); -} - -GURL Security_Origin::GetURL() const { - return url_; -} - -Eina_Stringshare* Security_Origin::GetHost() const { - return host_; -} - -Eina_Stringshare* Security_Origin::GetProtocol() const { - return protocol_; -} - -int Security_Origin::GetPort() const { - return url_.IntPort(); -} - -Security_Origin* Security_Origin::CreateFromString(const char *url) { - if (!url) - return 0; - - GURL gurl(url); - if (gurl.is_empty() || !gurl.is_valid()) - return 0; - - return new Security_Origin(gurl); -} - -} // namespace tizen_webview diff --git a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.h b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.h deleted file mode 100644 index 30ecc7a..0000000 --- a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_security_origin.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. -// Copyright 2014 Samsung Electronics. 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 - -#include "url/gurl.h" - -namespace tizen_webview { - -class Security_Origin { - public: - Security_Origin(const GURL& url); - Security_Origin(const char* host, const char* protocol, int port); - ~Security_Origin(); - - GURL GetURL() const; - Eina_Stringshare* GetHost() const; - Eina_Stringshare* GetProtocol() const; - int GetPort() const; - - static Security_Origin* CreateFromString(const char* url); - - private: - GURL url_; - Eina_Stringshare* host_; - Eina_Stringshare* protocol_; - - // 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_ -- 2.7.4