Allow changing wxWebViewBackendChromium data directory path
Use the value provided via wxWebViewConfiguration::SetDataPath() if any.
This commit is contained in:
parent
416e241e6a
commit
30c8c64e45
3 changed files with 33 additions and 7 deletions
|
|
@ -173,7 +173,7 @@ private:
|
||||||
friend class wxWebViewChromiumModule;
|
friend class wxWebViewChromiumModule;
|
||||||
static bool ms_cefInitialized;
|
static bool ms_cefInitialized;
|
||||||
|
|
||||||
static bool InitCEF();
|
static bool InitCEF(const wxWebViewConfiguration& config);
|
||||||
|
|
||||||
static void ShutdownCEF();
|
static void ShutdownCEF();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,8 @@ public:
|
||||||
local storage, etc.
|
local storage, etc.
|
||||||
@param path The path to the data directory.
|
@param path The path to the data directory.
|
||||||
|
|
||||||
@note This is only used by the Edge and WebKit2GTK+ backend.
|
@note This is used by Edge, WebKit2GTK+ and Chromium backends (the
|
||||||
|
latter creates "UserData" subdirectory under the given path).
|
||||||
*/
|
*/
|
||||||
void SetDataPath(const wxString& path);
|
void SetDataPath(const wxString& path);
|
||||||
|
|
||||||
|
|
@ -350,7 +351,8 @@ public:
|
||||||
local storage, etc.
|
local storage, etc.
|
||||||
@return The path to the data directory.
|
@return The path to the data directory.
|
||||||
|
|
||||||
@note This is only used by the Edge and WebKit2GTK+ backend.
|
@note This is used by Edge, WebKit2GTK+ and Chromium backends and
|
||||||
|
always returns empty string for the other ones.
|
||||||
*/
|
*/
|
||||||
wxString GetDataPath() const;
|
wxString GetDataPath() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,19 @@ public:
|
||||||
return wxWebViewConfiguration(wxWebViewBackendChromium,
|
return wxWebViewConfiguration(wxWebViewBackendChromium,
|
||||||
new wxWebViewConfigurationImplChromium);
|
new wxWebViewConfigurationImplChromium);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void SetDataPath(const wxString& path) override
|
||||||
|
{
|
||||||
|
m_dataPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual wxString GetDataPath() const override
|
||||||
|
{
|
||||||
|
return m_dataPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_dataPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
@ -675,7 +688,7 @@ bool wxWebViewChromium::Create(wxWindow* parent,
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( !InitCEF() )
|
if ( !InitCEF(m_implData->m_config) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
|
@ -931,7 +944,7 @@ bool CheckCEFLoadOrder()
|
||||||
|
|
||||||
#endif // __LINUX__
|
#endif // __LINUX__
|
||||||
|
|
||||||
bool wxWebViewChromium::InitCEF()
|
bool wxWebViewChromium::InitCEF(const wxWebViewConfiguration& config)
|
||||||
{
|
{
|
||||||
if (ms_cefInitialized)
|
if (ms_cefInitialized)
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -941,8 +954,19 @@ bool wxWebViewChromium::InitCEF()
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxFileName cefDataFolder(wxStandardPaths::Get().GetUserLocalDataDir(), "");
|
wxFileName cefDataFolder;
|
||||||
cefDataFolder.AppendDir("CEF");
|
const wxString& dataDir = config.GetDataPath();
|
||||||
|
if ( !dataDir.empty() )
|
||||||
|
{
|
||||||
|
cefDataFolder = wxFileName::DirName(dataDir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cefDataFolder = wxFileName::DirName(
|
||||||
|
wxStandardPaths::Get().GetUserLocalDataDir()
|
||||||
|
);
|
||||||
|
cefDataFolder.AppendDir("CEF");
|
||||||
|
}
|
||||||
cefDataFolder.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
cefDataFolder.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue