Make EwkFaviconDatabase per EWebContext
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 17 Aug 2015 11:47:49 +0000 (13:47 +0200)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
EwkFaviconDatabase implementation is unsafe and does not allow
ewk_favicon_database_* api implementation.

Associate EwkFaviconDatabase with EWebContext class.

Original beta/m42_2311_t patch:
- http://165.213.202.130/gerrit/#/c/85277/

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=14805

Reviewed by: a.renevier, d.waslicki, g.czajkowski

Change-Id: I2df25d877bd958a8f3a8a3f3298069c2f4e62557
Signed-off-by: Marcin Niesluchowski <m.niesluchow@samsung.com>
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_context.h
tizen_src/ewk/efl_integration/private/ewk_context_private.cc
tizen_src/ewk/efl_integration/private/ewk_context_private.h
tizen_src/ewk/efl_integration/private/ewk_favicon_database_private.h
tizen_src/ewk/efl_integration/public/ewk_context.cc

index 5a5b284..9fa0d57 100644 (file)
@@ -37,6 +37,7 @@
 #include "browser/vibration/vibration_provider_client.h"
 #include "components/password_manager/core/browser/password_manager.h"
 #include "content/common/render_messages_efl.h"
+#include "private/ewk_favicon_database_private.h"
 #include "private/ewk_security_origin_private.h"
 #include "wrt/wrt_widget_host.h"
 
@@ -248,6 +249,7 @@ EWebContext::EWebContext(bool incognito, const std::string& injectedBundlePath)
   // Notification Service gets init in BrowserMainRunner init,
   // so cache manager can register for notifications only after that.
   web_cache_manager_.reset(new WebCacheManagerEfl(browser_context_.get()));
+  ewk_favicon_database_.reset(new EwkFaviconDatabase(this));
   notification_cb_.reset(
       new EWebContextNotificationCallback(nullptr, nullptr, nullptr, nullptr));
   tizen_extensible_.reset(TizenExtensible::create());
@@ -492,10 +494,6 @@ bool EWebContext::SetFaviconDatabasePath(const base::FilePath& path) {
   return FaviconDatabase::Instance()->SetPath(path);
 }
 
-FaviconDatabase* EWebContext::GetFaviconDatabase() {
-  return FaviconDatabase::Instance();
-}
-
 Evas_Object *EWebContext::AddFaviconObject(const char* uri, Evas* canvas) const {
   if (uri == NULL || canvas == NULL) {
     return NULL;
index 2787880..a976497 100644 (file)
@@ -17,7 +17,7 @@
 class CookieManager;
 class Ewk_Wrt_Message_Data;
 class TizenExtensible;
-class FaviconDatabase;
+class EwkFaviconDatabase;
 
 namespace content {
 class BrowserContextEfl;
@@ -142,7 +142,9 @@ class EWebContext {
 
   void ClearCandidateData();
   void ClearPasswordData();
-  FaviconDatabase* GetFaviconDatabase();
+  EwkFaviconDatabase* GetFaviconDatabase() const {
+    return ewk_favicon_database_.get();
+  }
 
   unsigned int InspectorServerStart(unsigned int port);
   bool InspectorServerStop();
@@ -177,6 +179,7 @@ class EWebContext {
   scoped_ptr<content::BrowserContextEfl> browser_context_;
   scoped_ptr<Ewk_Cookie_Manager> ewk_cookie_manager_;
   scoped_ptr<TizenExtensible> tizen_extensible_;
+  scoped_ptr<EwkFaviconDatabase> ewk_favicon_database_;
   std::string proxy_uri_;
   std::string injected_bundle_path_;
   // widget info
index 0ff548b..1320bd6 100644 (file)
@@ -227,7 +227,7 @@ bool Ewk_Context::SetFaviconDatabasePath(const base::FilePath& path) {
   return impl->SetFaviconDatabasePath(path);
 }
 
-FaviconDatabase* Ewk_Context::GetFaviconDatabase() {
+EwkFaviconDatabase* Ewk_Context::GetFaviconDatabase() const {
   return impl->GetFaviconDatabase();
 }
 
index 75441c6..006cc4e 100644 (file)
@@ -16,7 +16,7 @@
 class CookieManager;
 class Ewk_Cookie_Manager;
 class EWebContext;
-class FaviconDatabase;
+class EwkFaviconDatabase;
 class GURL;
 
 namespace content {
@@ -122,7 +122,7 @@ struct Ewk_Context : public base::RefCounted<Ewk_Context> {
 
   // Note: Do not use outside chromium
   EWebContext* GetImpl() { return impl; }
-  FaviconDatabase* GetFaviconDatabase();
+  EwkFaviconDatabase* GetFaviconDatabase() const;
 
   unsigned int InspectorServerStart(unsigned int port) const;
   bool InspectorServerStop() const;
index 52087c7..585bfec 100644 (file)
@@ -5,38 +5,14 @@
 #ifndef ewk_favicon_database_private_h
 #define ewk_favicon_database_private_h
 
-#include <Evas.h>
+class EWebContext;
 
-#include "browser/favicon/favicon_database.h"
-#include "private/ewk_context_private.h"
-
-struct EwkFaviconDatabase {
+class EwkFaviconDatabase {
  public:
-  static EwkFaviconDatabase *Instance()
-  {
-    static EwkFaviconDatabase database;
-    return &database;
-  }
-
-  EwkFaviconDatabase()
-  :favicon_database(NULL)
-  {
-  }
-
-  ~EwkFaviconDatabase()
-  {
-    if (favicon_database)
-      delete favicon_database;
-    favicon_database = NULL;
-  }
+  explicit EwkFaviconDatabase(EWebContext* eweb_context)
+    : eweb_context_(eweb_context) {}
 
-  void InitEwkFaviconDatabase(const Ewk_Context* ewkContext)
-  {
-    if (!favicon_database)
-      favicon_database = const_cast<Ewk_Context*>(ewkContext)->GetFaviconDatabase();
-    return;
-  }
  private:
-  FaviconDatabase* favicon_database;
+  EWebContext* eweb_context_;
 };
 #endif // ewk_favicon_database_private_h
index 1e08154..66f2bf7 100644 (file)
@@ -550,9 +550,7 @@ Ewk_Application_Cache_Manager* ewk_context_application_cache_manager_get(const E
 Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext)
 {
   EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
-  Ewk_Favicon_Database *favicon_database = Ewk_Favicon_Database::Instance();
-  favicon_database->InitEwkFaviconDatabase(ewkContext);
-  return favicon_database;
+  return ewkContext->GetFaviconDatabase();
 }
 
 void ewk_context_resource_cache_clear(Ewk_Context* ewkContext)