Change type of path member of FaviconDatabasePrivate class
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Tue, 17 Nov 2015 11:23:18 +0000 (12:23 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
path member of FaviconDatabasePrivate type changed from
std::string to base::FilePath making it less error-prone.
Proper checks has been added for that type.

Original beta/m42_2311_t patches:
- http://165.213.202.130/gerrit/#/c/85274/
- http://165.213.202.130/gerrit/#/c/85275/

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

Reviewed by: d.waslicki, m.roj, msu.koo

Change-Id: Iec556b76f6eaade557b07d55fc42651c3f0d7f93
Signed-off-by: Marcin Niesluchowski <m.niesluchow@samsung.com>
tizen_src/ewk/efl_integration/browser/favicon/favicon_database.cc
tizen_src/ewk/efl_integration/browser/favicon/favicon_database.h
tizen_src/ewk/efl_integration/browser/favicon/favicon_database_p.h
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/public/ewk_context.cc

index 5b493e5..23ef27f 100644 (file)
@@ -35,13 +35,17 @@ FaviconDatabase::FaviconDatabase()
   : d(new FaviconDatabasePrivate) {
 }
 
-bool FaviconDatabase::SetPath(const std::string &path) {
+bool FaviconDatabase::SetPath(const base::FilePath &path) {
+  if (path.EndsWithSeparator() || path.empty()) {
+    return false;
+  }
+
   base::AutoLock locker(d->mutex);
   if (d->sqlite) {
     return false;
   }
 
-  base::FilePath dir = base::FilePath(path).DirName();
+  base::FilePath dir = path.DirName();
   if (!base::DirectoryExists(dir) && !base::CreateDirectory(dir)) {
     return false;
   }
@@ -179,7 +183,7 @@ bool FaviconDatabase::Open() {
   if (d->sqlite) {
     return true;
   }
-  int result = sqlite3_open(d->path.c_str(), &d->sqlite);
+  int result = sqlite3_open(d->path.value().c_str(), &d->sqlite);
   if (result != SQLITE_OK) {
     LOG(ERROR) << "[FaviconDatabase] :: Error opening SQLite database ("
                << result << ")!";
index 2a4063b..7278602 100644 (file)
@@ -9,6 +9,7 @@
 #include "third_party/skia/include/core/SkBitmap.h"
 #include "third_party/sqlite/sqlite3.h"
 #include "url/gurl.h"
+#include "base/files/file_path.h"
 #include "base/memory/weak_ptr.h"
 #include "base/macros.h"
 
@@ -20,7 +21,7 @@ class FaviconDatabase {
 
   virtual ~FaviconDatabase();
 
-  bool SetPath(const std::string &path);
+  bool SetPath(const base::FilePath &path);
   void SetPrivateBrowsingEnabled(bool enabled);
   bool IsPrivateBrowsingEnabled() const;
 
index 8c670ef..da86fe8 100644 (file)
@@ -10,6 +10,7 @@
 #include "url/gurl.h"
 #include "third_party/skia/include/core/SkBitmap.h"
 #include "third_party/sqlite/sqlite3.h"
+#include "base/files/file_path.h"
 #include "base/single_thread_task_runner.h"
 #include "base/synchronization/lock.h"
 #include "base/timer/timer.h"
@@ -37,7 +38,7 @@ struct FaviconDatabasePrivate : public base::RefCountedThreadSafe<FaviconDatabas
 
   std::map<GURL, GURL> pageToFaviconUrl;
   std::map<GURL, SkBitmap> faviconUrlToBitmap;
-  std::string path;
+  base::FilePath path;
   bool privateBrowsing;
 
   sqlite3 *sqlite;
index 55cebfc..5a5b284 100644 (file)
@@ -488,7 +488,7 @@ void EWebContext::GetAllOriginsWithFileSystem(Ewk_Local_File_System_Origins_Get_
         base::Bind(&GetFileSystemOriginsOnFILEThread, callback, user_data, partition));
 }
 
-bool EWebContext::SetFaviconDatabasePath(const char* path) {
+bool EWebContext::SetFaviconDatabasePath(const base::FilePath& path) {
   return FaviconDatabase::Instance()->SetPath(path);
 }
 
index abc1f3c..2787880 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef EWEB_CONTEXT_H
 #define EWEB_CONTEXT_H
 
+#include "base/files/file_path.h"
 #include "base/memory/scoped_ptr.h"
 #include "browser/web_cache_efl/web_cache_manager_efl.h"
 #include "common/tizen_extensible.h"
@@ -125,7 +126,7 @@ class EWebContext {
   void WebStorageOriginsAllGet(Ewk_Web_Storage_Origins_Get_Callback callback, void* user_data);
   void FileSystemDelete(const GURL& host);
   void GetAllOriginsWithFileSystem(Ewk_Local_File_System_Origins_Get_Callback callback, void* user_data) const;
-  bool SetFaviconDatabasePath(const char *path);
+  bool SetFaviconDatabasePath(const base::FilePath& path);
   Evas_Object *AddFaviconObject(const char *uri, Evas *canvas) const;
 
   void SendWidgetInfo(const std::string& tizen_id, double scale, const std::string &theme, const std::string &encoded_bundle);
index 058910e..0ff548b 100644 (file)
@@ -223,7 +223,7 @@ void Ewk_Context::FileSystemDelete(const GURL& host) {
   impl->FileSystemDelete(host);
 }
 
-bool Ewk_Context::SetFaviconDatabasePath(const char *path) {
+bool Ewk_Context::SetFaviconDatabasePath(const base::FilePath& path) {
   return impl->SetFaviconDatabasePath(path);
 }
 
index 9155100..75441c6 100644 (file)
@@ -8,6 +8,7 @@
 #include <string>
 #include <Evas.h>
 
+#include "base/files/file_path.h"
 #include "base/memory/ref_counted.h"
 #include "ewk_enums.h"
 #include "public/ewk_context.h"
@@ -96,7 +97,7 @@ struct Ewk_Context : public base::RefCounted<Ewk_Context> {
   void FileSystemDelete(const GURL& host);
 
   // Favicon
-  bool SetFaviconDatabasePath(const char *path);
+  bool SetFaviconDatabasePath(const base::FilePath& path);
   Evas_Object *AddFaviconObject(const char *uri, Evas *canvas) const;
 
   // Widget
index d252356..772834e 100644 (file)
@@ -133,7 +133,8 @@ Eina_Bool ewk_context_application_cache_quota_for_origin_set(Ewk_Context* contex
 Eina_Bool ewk_context_icon_database_path_set(Ewk_Context* context, const char* path)
 {
   EINA_SAFETY_ON_NULL_RETURN_VAL(context, EINA_FALSE);
-  return context->SetFaviconDatabasePath(path) ? EINA_TRUE : EINA_FALSE;
+  EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
+  return context->SetFaviconDatabasePath(base::FilePath(path));
 }
 
 Evas_Object* ewk_context_icon_database_icon_object_add(Ewk_Context* context, const char* uri, Evas* canvas)