mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-25 00:17:41 +01:00
Store all persistent data in the CefSettings.cache_path directory (issue #510).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@709 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
f7c91a7d6b
commit
6f2897cb50
@ -7,38 +7,24 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "libcef/browser/browser_host_impl.h"
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/download_manager_delegate.h"
|
#include "libcef/browser/download_manager_delegate.h"
|
||||||
#include "libcef/browser/resource_context.h"
|
#include "libcef/browser/resource_context.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
#include "libcef/browser/url_request_context_getter.h"
|
#include "libcef/browser/url_request_context_getter.h"
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/environment.h"
|
|
||||||
#include "base/file_util.h"
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/path_service.h"
|
|
||||||
#include "base/threading/thread.h"
|
#include "base/threading/thread.h"
|
||||||
#include "content/public/browser/download_manager.h"
|
#include "content/public/browser/download_manager.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/geolocation_permission_context.h"
|
#include "content/public/browser/geolocation_permission_context.h"
|
||||||
#include "content/public/browser/speech_recognition_preferences.h"
|
#include "content/public/browser/speech_recognition_preferences.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#include "base/base_paths_win.h"
|
|
||||||
#elif defined(OS_LINUX)
|
|
||||||
#include "base/nix/xdg_util.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
|
||||||
const char kDotConfigDir[] = ".config";
|
|
||||||
const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class CefGeolocationPermissionContext
|
class CefGeolocationPermissionContext
|
||||||
: public content::GeolocationPermissionContext {
|
: public content::GeolocationPermissionContext {
|
||||||
public:
|
public:
|
||||||
@ -187,8 +173,6 @@ class CefSpeechRecognitionPreferences
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefBrowserContext::CefBrowserContext() {
|
CefBrowserContext::CefBrowserContext() {
|
||||||
InitWhileIOAllowed();
|
|
||||||
|
|
||||||
// Initialize the request context getter.
|
// Initialize the request context getter.
|
||||||
url_request_getter_ = new CefURLRequestContextGetter(
|
url_request_getter_ = new CefURLRequestContextGetter(
|
||||||
GetPath(),
|
GetPath(),
|
||||||
@ -206,30 +190,8 @@ CefBrowserContext::~CefBrowserContext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserContext::InitWhileIOAllowed() {
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_));
|
|
||||||
path_ = path_.Append(std::wstring(L"cef_data"));
|
|
||||||
#elif defined(OS_LINUX)
|
|
||||||
scoped_ptr<base::Environment> env(base::Environment::Create());
|
|
||||||
FilePath config_dir(
|
|
||||||
base::nix::GetXDGDirectory(env.get(),
|
|
||||||
base::nix::kXdgConfigHomeEnvVar,
|
|
||||||
base::nix::kDotConfigDir));
|
|
||||||
path_ = config_dir.Append("cef_data");
|
|
||||||
#elif defined(OS_MACOSX)
|
|
||||||
CHECK(PathService::Get(base::DIR_APP_DATA, &path_));
|
|
||||||
path_ = path_.Append("cef_data");
|
|
||||||
#else
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!file_util::PathExists(path_))
|
|
||||||
file_util::CreateDirectory(path_);
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath CefBrowserContext::GetPath() {
|
FilePath CefBrowserContext::GetPath() {
|
||||||
return path_;
|
return _Context->cache_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserContext::IsOffTheRecord() const {
|
bool CefBrowserContext::IsOffTheRecord() const {
|
||||||
|
@ -25,8 +25,6 @@ class CefBrowserContext : public content::BrowserContext {
|
|||||||
CefBrowserContext();
|
CefBrowserContext();
|
||||||
virtual ~CefBrowserContext();
|
virtual ~CefBrowserContext();
|
||||||
|
|
||||||
void InitWhileIOAllowed();
|
|
||||||
|
|
||||||
// BrowserContext methods.
|
// BrowserContext methods.
|
||||||
virtual FilePath GetPath() OVERRIDE;
|
virtual FilePath GetPath() OVERRIDE;
|
||||||
virtual bool IsOffTheRecord() const OVERRIDE;
|
virtual bool IsOffTheRecord() const OVERRIDE;
|
||||||
@ -45,7 +43,6 @@ class CefBrowserContext : public content::BrowserContext {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
FilePath path_;
|
|
||||||
scoped_ptr<content::ResourceContext> resource_context_;
|
scoped_ptr<content::ResourceContext> resource_context_;
|
||||||
scoped_refptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
scoped_refptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
||||||
scoped_refptr<content::DownloadManager> download_manager_;
|
scoped_refptr<content::DownloadManager> download_manager_;
|
||||||
|
@ -182,7 +182,9 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
|||||||
settings_ = settings;
|
settings_ = settings;
|
||||||
|
|
||||||
cache_path_ = FilePath(CefString(&settings.cache_path));
|
cache_path_ = FilePath(CefString(&settings.cache_path));
|
||||||
if (!cache_path_.empty() && !file_util::CreateDirectory(cache_path_)) {
|
if (!cache_path_.empty() &&
|
||||||
|
!file_util::DirectoryExists(cache_path_) &&
|
||||||
|
!file_util::CreateDirectory(cache_path_)) {
|
||||||
NOTREACHED() << "The cache_path directory could not be created";
|
NOTREACHED() << "The cache_path directory could not be created";
|
||||||
cache_path_ = FilePath();
|
cache_path_ = FilePath();
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,8 @@ bool CefCookieManagerImpl::SetStoragePath(const CefString& path) {
|
|||||||
// TODO(cef): Move directory creation to the blocking pool instead of
|
// TODO(cef): Move directory creation to the blocking pool instead of
|
||||||
// allowing file IO on this thread.
|
// allowing file IO on this thread.
|
||||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||||
if (file_util::CreateDirectory(new_path)) {
|
if (file_util::DirectoryExists(new_path) ||
|
||||||
|
file_util::CreateDirectory(new_path)) {
|
||||||
const FilePath& cookie_path = new_path.AppendASCII("Cookies");
|
const FilePath& cookie_path = new_path.AppendASCII("Cookies");
|
||||||
persistent_store =
|
persistent_store =
|
||||||
new SQLitePersistentCookieStore(cookie_path, false, NULL);
|
new SQLitePersistentCookieStore(cookie_path, false, NULL);
|
||||||
|
@ -95,7 +95,7 @@ void CefDownloadManagerDelegate::GenerateFilename(
|
|||||||
const FilePath& generated_name) {
|
const FilePath& generated_name) {
|
||||||
FilePath suggested_path = download_manager_->GetBrowserContext()->GetPath().
|
FilePath suggested_path = download_manager_->GetBrowserContext()->GetPath().
|
||||||
Append(FILE_PATH_LITERAL("Downloads"));
|
Append(FILE_PATH_LITERAL("Downloads"));
|
||||||
if (!file_util::PathExists(suggested_path))
|
if (!file_util::DirectoryExists(suggested_path))
|
||||||
file_util::CreateDirectory(suggested_path);
|
file_util::CreateDirectory(suggested_path);
|
||||||
|
|
||||||
suggested_path = suggested_path.Append(generated_name);
|
suggested_path = suggested_path.Append(generated_name);
|
||||||
|
@ -304,7 +304,8 @@ void CefURLRequestContextGetter::SetCookieStoragePath(const FilePath& path) {
|
|||||||
// TODO(cef): Move directory creation to the blocking pool instead of
|
// TODO(cef): Move directory creation to the blocking pool instead of
|
||||||
// allowing file IO on this thread.
|
// allowing file IO on this thread.
|
||||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||||
if (file_util::CreateDirectory(path)) {
|
if (file_util::DirectoryExists(path) ||
|
||||||
|
file_util::CreateDirectory(path)) {
|
||||||
const FilePath& cookie_path = path.AppendASCII("Cookies");
|
const FilePath& cookie_path = path.AppendASCII("Cookies");
|
||||||
persistent_store =
|
persistent_store =
|
||||||
new SQLitePersistentCookieStore(cookie_path, false, NULL);
|
new SQLitePersistentCookieStore(cookie_path, false, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user