|
@@ -284,7 +284,7 @@ Session::Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
|
|
SpellcheckService* service =
|
|
|
- SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
|
|
+ SpellcheckServiceFactory::GetForContext(browser_context_);
|
|
|
if (service) {
|
|
|
service->SetHunspellObserver(this);
|
|
|
}
|
|
@@ -297,7 +297,7 @@ Session::~Session() {
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
|
|
SpellcheckService* service =
|
|
|
- SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
|
|
+ SpellcheckServiceFactory::GetForContext(browser_context_);
|
|
|
if (service) {
|
|
|
service->SetHunspellObserver(nullptr);
|
|
|
}
|
|
@@ -366,7 +366,7 @@ v8::Local<v8::Promise> Session::GetCacheSize() {
|
|
|
gin_helper::Promise<int64_t> promise(isolate);
|
|
|
auto handle = promise.GetHandle();
|
|
|
|
|
|
- content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
->GetNetworkContext()
|
|
|
->ComputeHttpCacheSize(
|
|
|
base::Time(), base::Time::Max(),
|
|
@@ -390,7 +390,7 @@ v8::Local<v8::Promise> Session::ClearCache() {
|
|
|
gin_helper::Promise<void> promise(isolate);
|
|
|
auto handle = promise.GetHandle();
|
|
|
|
|
|
- content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
->GetNetworkContext()
|
|
|
->ClearHttpCache(base::Time(), base::Time::Max(), nullptr,
|
|
|
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
|
|
@@ -486,17 +486,17 @@ void Session::EnableNetworkEmulation(const gin_helper::Dictionary& options) {
|
|
|
conditions->latency = base::TimeDelta::FromMillisecondsD(latency);
|
|
|
}
|
|
|
|
|
|
- auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
|
|
- browser_context_.get())
|
|
|
- ->GetNetworkContext();
|
|
|
+ auto* network_context =
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
+ ->GetNetworkContext();
|
|
|
network_context->SetNetworkConditions(network_emulation_token_,
|
|
|
std::move(conditions));
|
|
|
}
|
|
|
|
|
|
void Session::DisableNetworkEmulation() {
|
|
|
- auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
|
|
- browser_context_.get())
|
|
|
- ->GetNetworkContext();
|
|
|
+ auto* network_context =
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
+ ->GetNetworkContext();
|
|
|
network_context->SetNetworkConditions(
|
|
|
network_emulation_token_, network::mojom::NetworkConditions::New());
|
|
|
}
|
|
@@ -516,7 +516,7 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
|
|
std::make_unique<CertVerifierClient>(proc),
|
|
|
cert_verifier_client_remote.InitWithNewPipeAndPassReceiver());
|
|
|
}
|
|
|
- content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
->GetNetworkContext()
|
|
|
->SetCertVerifierClient(std::move(cert_verifier_client_remote));
|
|
|
|
|
@@ -569,7 +569,7 @@ v8::Local<v8::Promise> Session::ClearHostResolverCache(
|
|
|
gin_helper::Promise<void> promise(isolate);
|
|
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
|
|
|
|
|
- content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
->GetNetworkContext()
|
|
|
->ClearHostCache(nullptr,
|
|
|
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
|
|
@@ -583,7 +583,7 @@ v8::Local<v8::Promise> Session::ClearAuthCache() {
|
|
|
gin_helper::Promise<void> promise(isolate);
|
|
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
|
|
|
|
|
- content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
->GetNetworkContext()
|
|
|
->ClearHttpAuthCache(
|
|
|
base::Time(),
|
|
@@ -609,9 +609,9 @@ void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
|
|
void Session::SetUserAgent(const std::string& user_agent,
|
|
|
gin_helper::Arguments* args) {
|
|
|
browser_context_->SetUserAgent(user_agent);
|
|
|
- auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
|
|
- browser_context_.get())
|
|
|
- ->GetNetworkContext();
|
|
|
+ auto* network_context =
|
|
|
+ content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
|
|
+ ->GetNetworkContext();
|
|
|
network_context->SetUserAgent(user_agent);
|
|
|
|
|
|
std::string accept_lang;
|
|
@@ -790,10 +790,9 @@ v8::Local<v8::Value> Session::NetLog(v8::Isolate* isolate) {
|
|
|
return v8::Local<v8::Value>::New(isolate, net_log_);
|
|
|
}
|
|
|
|
|
|
-static void StartPreconnectOnUI(
|
|
|
- scoped_refptr<ElectronBrowserContext> browser_context,
|
|
|
- const GURL& url,
|
|
|
- int num_sockets_to_preconnect) {
|
|
|
+static void StartPreconnectOnUI(ElectronBrowserContext* browser_context,
|
|
|
+ const GURL& url,
|
|
|
+ int num_sockets_to_preconnect) {
|
|
|
std::vector<predictors::PreconnectRequest> requests = {
|
|
|
{url::Origin::Create(url), num_sockets_to_preconnect,
|
|
|
net::NetworkIsolationKey()}};
|
|
@@ -823,7 +822,7 @@ void Session::Preconnect(const gin_helper::Dictionary& options,
|
|
|
DCHECK_GT(num_sockets_to_preconnect, 0);
|
|
|
base::PostTask(
|
|
|
FROM_HERE, {content::BrowserThread::UI},
|
|
|
- base::BindOnce(&StartPreconnectOnUI, base::RetainedRef(browser_context_),
|
|
|
+ base::BindOnce(&StartPreconnectOnUI, base::Unretained(browser_context_),
|
|
|
url, num_sockets_to_preconnect));
|
|
|
}
|
|
|
|
|
@@ -867,7 +866,7 @@ v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() {
|
|
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
|
|
|
|
|
SpellcheckService* spellcheck =
|
|
|
- SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
|
|
+ SpellcheckServiceFactory::GetForContext(browser_context_);
|
|
|
|
|
|
if (!spellcheck)
|
|
|
promise.RejectWithErrorMessage(
|
|
@@ -893,7 +892,7 @@ bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
|
|
|
return false;
|
|
|
|
|
|
SpellcheckService* spellcheck =
|
|
|
- SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
|
|
+ SpellcheckServiceFactory::GetForContext(browser_context_);
|
|
|
if (!spellcheck)
|
|
|
return false;
|
|
|
|
|
@@ -915,7 +914,7 @@ bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
|
|
|
return false;
|
|
|
|
|
|
SpellcheckService* service =
|
|
|
- SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
|
|
+ SpellcheckServiceFactory::GetForContext(browser_context_);
|
|
|
if (!service)
|
|
|
return false;
|
|
|
|
|
@@ -952,7 +951,7 @@ gin::Handle<Session> Session::CreateFrom(
|
|
|
gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
|
|
|
const std::string& partition,
|
|
|
base::DictionaryValue options) {
|
|
|
- scoped_refptr<ElectronBrowserContext> browser_context;
|
|
|
+ ElectronBrowserContext* browser_context;
|
|
|
if (partition.empty()) {
|
|
|
browser_context =
|
|
|
ElectronBrowserContext::From("", false, std::move(options));
|
|
@@ -965,7 +964,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
|
|
|
browser_context =
|
|
|
ElectronBrowserContext::From(partition, true, std::move(options));
|
|
|
}
|
|
|
- return CreateFrom(isolate, browser_context.get());
|
|
|
+ return CreateFrom(isolate, browser_context);
|
|
|
}
|
|
|
|
|
|
// static
|