feat: add session.storagePath to get path on disk for session data (#28866)

* feat: add session.storagePath to get path on disk for session data

* spec: add session.storagePath tests

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
trop[bot]
2021-05-03 12:14:53 -04:00
committed by GitHub
parent f9bf319e66
commit 5c12606b13
4 changed files with 39 additions and 1 deletions

View File

@@ -971,6 +971,13 @@ v8::Local<v8::Promise> Session::CloseAllConnections() {
return handle;
}
v8::Local<v8::Value> Session::GetPath(v8::Isolate* isolate) {
if (browser_context_->IsOffTheRecord()) {
return v8::Null(isolate);
}
return gin::ConvertToV8(isolate, browser_context_->GetPath());
}
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
base::Value Session::GetSpellCheckerLanguages() {
return browser_context_->prefs()
@@ -1195,11 +1202,13 @@ gin::ObjectTemplateBuilder Session::GetObjectTemplateBuilder(
#endif
.SetMethod("preconnect", &Session::Preconnect)
.SetMethod("closeAllConnections", &Session::CloseAllConnections)
.SetMethod("getStoragePath", &Session::GetPath)
.SetProperty("cookies", &Session::Cookies)
.SetProperty("netLog", &Session::NetLog)
.SetProperty("protocol", &Session::Protocol)
.SetProperty("serviceWorkers", &Session::ServiceWorkerContext)
.SetProperty("webRequest", &Session::WebRequest);
.SetProperty("webRequest", &Session::WebRequest)
.SetProperty("storagePath", &Session::GetPath);
}
const char* Session::GetTypeName() {

View File

@@ -124,6 +124,7 @@ class Session : public gin::Wrappable<Session>,
v8::Local<v8::Value> NetLog(v8::Isolate* isolate);
void Preconnect(const gin_helper::Dictionary& options, gin::Arguments* args);
v8::Local<v8::Promise> CloseAllConnections();
v8::Local<v8::Value> GetPath(v8::Isolate* isolate);
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
base::Value GetSpellCheckerLanguages();
void SetSpellCheckerLanguages(gin_helper::ErrorThrower thrower,