fix: browser contexts live forever (#24964)
This commit is contained in:
parent
befbbc27d8
commit
bac2f46ba9
11 changed files with 68 additions and 73 deletions
|
@ -1197,10 +1197,10 @@ void App::ImportCertificate(gin_helper::ErrorThrower thrower,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto browser_context = ElectronBrowserContext::From("", false);
|
auto* browser_context = ElectronBrowserContext::From("", false);
|
||||||
if (!certificate_manager_model_) {
|
if (!certificate_manager_model_) {
|
||||||
CertificateManagerModel::Create(
|
CertificateManagerModel::Create(
|
||||||
browser_context.get(),
|
browser_context,
|
||||||
base::BindOnce(&App::OnCertificateManagerModelCreated,
|
base::BindOnce(&App::OnCertificateManagerModelCreated,
|
||||||
base::Unretained(this), std::move(options),
|
base::Unretained(this), std::move(options),
|
||||||
std::move(callback)));
|
std::move(callback)));
|
||||||
|
|
|
@ -276,7 +276,7 @@ Session::Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||||
SpellcheckService* service =
|
SpellcheckService* service =
|
||||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
SpellcheckServiceFactory::GetForContext(browser_context_);
|
||||||
if (service) {
|
if (service) {
|
||||||
service->SetHunspellObserver(this);
|
service->SetHunspellObserver(this);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ Session::~Session() {
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||||
SpellcheckService* service =
|
SpellcheckService* service =
|
||||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
SpellcheckServiceFactory::GetForContext(browser_context_);
|
||||||
if (service) {
|
if (service) {
|
||||||
service->SetHunspellObserver(nullptr);
|
service->SetHunspellObserver(nullptr);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ v8::Local<v8::Promise> Session::GetCacheSize() {
|
||||||
gin_helper::Promise<int64_t> promise(isolate);
|
gin_helper::Promise<int64_t> promise(isolate);
|
||||||
auto handle = promise.GetHandle();
|
auto handle = promise.GetHandle();
|
||||||
|
|
||||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext()
|
->GetNetworkContext()
|
||||||
->ComputeHttpCacheSize(
|
->ComputeHttpCacheSize(
|
||||||
base::Time(), base::Time::Max(),
|
base::Time(), base::Time::Max(),
|
||||||
|
@ -375,7 +375,7 @@ v8::Local<v8::Promise> Session::ClearCache() {
|
||||||
gin_helper::Promise<void> promise(isolate);
|
gin_helper::Promise<void> promise(isolate);
|
||||||
auto handle = promise.GetHandle();
|
auto handle = promise.GetHandle();
|
||||||
|
|
||||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext()
|
->GetNetworkContext()
|
||||||
->ClearHttpCache(base::Time(), base::Time::Max(), nullptr,
|
->ClearHttpCache(base::Time(), base::Time::Max(), nullptr,
|
||||||
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
|
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
|
||||||
|
@ -471,16 +471,16 @@ void Session::EnableNetworkEmulation(const gin_helper::Dictionary& options) {
|
||||||
conditions->latency = base::TimeDelta::FromMillisecondsD(latency);
|
conditions->latency = base::TimeDelta::FromMillisecondsD(latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
auto* network_context =
|
||||||
browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext();
|
->GetNetworkContext();
|
||||||
network_context->SetNetworkConditions(network_emulation_token_,
|
network_context->SetNetworkConditions(network_emulation_token_,
|
||||||
std::move(conditions));
|
std::move(conditions));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::DisableNetworkEmulation() {
|
void Session::DisableNetworkEmulation() {
|
||||||
auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
auto* network_context =
|
||||||
browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext();
|
->GetNetworkContext();
|
||||||
network_context->SetNetworkConditions(
|
network_context->SetNetworkConditions(
|
||||||
network_emulation_token_, network::mojom::NetworkConditions::New());
|
network_emulation_token_, network::mojom::NetworkConditions::New());
|
||||||
|
@ -501,7 +501,7 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||||
std::make_unique<CertVerifierClient>(proc),
|
std::make_unique<CertVerifierClient>(proc),
|
||||||
cert_verifier_client_remote.InitWithNewPipeAndPassReceiver());
|
cert_verifier_client_remote.InitWithNewPipeAndPassReceiver());
|
||||||
}
|
}
|
||||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext()
|
->GetNetworkContext()
|
||||||
->SetCertVerifierClient(std::move(cert_verifier_client_remote));
|
->SetCertVerifierClient(std::move(cert_verifier_client_remote));
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ v8::Local<v8::Promise> Session::ClearHostResolverCache(gin::Arguments* args) {
|
||||||
gin_helper::Promise<void> promise(isolate);
|
gin_helper::Promise<void> promise(isolate);
|
||||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext()
|
->GetNetworkContext()
|
||||||
->ClearHostCache(nullptr,
|
->ClearHostCache(nullptr,
|
||||||
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
|
base::BindOnce(gin_helper::Promise<void>::ResolvePromise,
|
||||||
|
@ -567,7 +567,7 @@ v8::Local<v8::Promise> Session::ClearAuthCache() {
|
||||||
gin_helper::Promise<void> promise(isolate);
|
gin_helper::Promise<void> promise(isolate);
|
||||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext()
|
->GetNetworkContext()
|
||||||
->ClearHttpAuthCache(
|
->ClearHttpAuthCache(
|
||||||
base::Time(),
|
base::Time(),
|
||||||
|
@ -593,8 +593,8 @@ void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||||
void Session::SetUserAgent(const std::string& user_agent,
|
void Session::SetUserAgent(const std::string& user_agent,
|
||||||
gin::Arguments* args) {
|
gin::Arguments* args) {
|
||||||
browser_context_->SetUserAgent(user_agent);
|
browser_context_->SetUserAgent(user_agent);
|
||||||
auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
auto* network_context =
|
||||||
browser_context_.get())
|
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||||
->GetNetworkContext();
|
->GetNetworkContext();
|
||||||
network_context->SetUserAgent(user_agent);
|
network_context->SetUserAgent(user_agent);
|
||||||
|
|
||||||
|
@ -781,8 +781,7 @@ v8::Local<v8::Value> Session::NetLog(v8::Isolate* isolate) {
|
||||||
return net_log_.Get(isolate);
|
return net_log_.Get(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StartPreconnectOnUI(
|
static void StartPreconnectOnUI(ElectronBrowserContext* browser_context,
|
||||||
scoped_refptr<ElectronBrowserContext> browser_context,
|
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
int num_sockets_to_preconnect) {
|
int num_sockets_to_preconnect) {
|
||||||
std::vector<predictors::PreconnectRequest> requests = {
|
std::vector<predictors::PreconnectRequest> requests = {
|
||||||
|
@ -815,7 +814,7 @@ void Session::Preconnect(const gin_helper::Dictionary& options,
|
||||||
DCHECK_GT(num_sockets_to_preconnect, 0);
|
DCHECK_GT(num_sockets_to_preconnect, 0);
|
||||||
base::PostTask(
|
base::PostTask(
|
||||||
FROM_HERE, {content::BrowserThread::UI},
|
FROM_HERE, {content::BrowserThread::UI},
|
||||||
base::BindOnce(&StartPreconnectOnUI, base::RetainedRef(browser_context_),
|
base::BindOnce(&StartPreconnectOnUI, base::Unretained(browser_context_),
|
||||||
url, num_sockets_to_preconnect));
|
url, num_sockets_to_preconnect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +859,7 @@ v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() {
|
||||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||||
|
|
||||||
SpellcheckService* spellcheck =
|
SpellcheckService* spellcheck =
|
||||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
SpellcheckServiceFactory::GetForContext(browser_context_);
|
||||||
|
|
||||||
if (!spellcheck)
|
if (!spellcheck)
|
||||||
promise.RejectWithErrorMessage(
|
promise.RejectWithErrorMessage(
|
||||||
|
@ -886,7 +885,7 @@ bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SpellcheckService* service =
|
SpellcheckService* service =
|
||||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
SpellcheckServiceFactory::GetForContext(browser_context_);
|
||||||
if (!service)
|
if (!service)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -907,7 +906,7 @@ bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SpellcheckService* service =
|
SpellcheckService* service =
|
||||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
SpellcheckServiceFactory::GetForContext(browser_context_);
|
||||||
if (!service)
|
if (!service)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -953,7 +952,7 @@ gin::Handle<Session> Session::CreateFrom(
|
||||||
gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
|
gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
|
||||||
const std::string& partition,
|
const std::string& partition,
|
||||||
base::DictionaryValue options) {
|
base::DictionaryValue options) {
|
||||||
scoped_refptr<ElectronBrowserContext> browser_context;
|
ElectronBrowserContext* browser_context;
|
||||||
if (partition.empty()) {
|
if (partition.empty()) {
|
||||||
browser_context =
|
browser_context =
|
||||||
ElectronBrowserContext::From("", false, std::move(options));
|
ElectronBrowserContext::From("", false, std::move(options));
|
||||||
|
@ -966,7 +965,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
|
||||||
browser_context =
|
browser_context =
|
||||||
ElectronBrowserContext::From(partition, true, std::move(options));
|
ElectronBrowserContext::From(partition, true, std::move(options));
|
||||||
}
|
}
|
||||||
return CreateFrom(isolate, browser_context.get());
|
return CreateFrom(isolate, browser_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
gin::ObjectTemplateBuilder Session::GetObjectTemplateBuilder(
|
gin::ObjectTemplateBuilder Session::GetObjectTemplateBuilder(
|
||||||
|
|
|
@ -71,9 +71,7 @@ class Session : public gin::Wrappable<Session>,
|
||||||
const std::string& partition,
|
const std::string& partition,
|
||||||
base::DictionaryValue options = base::DictionaryValue());
|
base::DictionaryValue options = base::DictionaryValue());
|
||||||
|
|
||||||
ElectronBrowserContext* browser_context() const {
|
ElectronBrowserContext* browser_context() const { return browser_context_; }
|
||||||
return browser_context_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// gin::Wrappable
|
// gin::Wrappable
|
||||||
static gin::WrapperInfo kWrapperInfo;
|
static gin::WrapperInfo kWrapperInfo;
|
||||||
|
@ -159,7 +157,7 @@ class Session : public gin::Wrappable<Session>,
|
||||||
// The client id to enable the network throttler.
|
// The client id to enable the network throttler.
|
||||||
base::UnguessableToken network_emulation_token_;
|
base::UnguessableToken network_emulation_token_;
|
||||||
|
|
||||||
scoped_refptr<ElectronBrowserContext> browser_context_;
|
ElectronBrowserContext* browser_context_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Session);
|
DISALLOW_COPY_AND_ASSIGN(Session);
|
||||||
};
|
};
|
||||||
|
|
|
@ -250,14 +250,8 @@ void CommonWebContentsDelegate::ResetManagedWebContents(bool async) {
|
||||||
// is destroyed.
|
// is destroyed.
|
||||||
// //electron/patches/chromium/content_browser_main_loop.patch
|
// //electron/patches/chromium/content_browser_main_loop.patch
|
||||||
// is required to get the right quit closure for the main message loop.
|
// is required to get the right quit closure for the main message loop.
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
|
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
|
||||||
FROM_HERE,
|
web_contents_.release());
|
||||||
base::BindOnce(
|
|
||||||
[](scoped_refptr<ElectronBrowserContext> browser_context,
|
|
||||||
std::unique_ptr<InspectableWebContents> web_contents) {
|
|
||||||
web_contents.reset();
|
|
||||||
},
|
|
||||||
base::RetainedRef(browser_context_), std::move(web_contents_)));
|
|
||||||
} else {
|
} else {
|
||||||
web_contents_.reset();
|
web_contents_.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,8 +171,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
|
||||||
|
|
||||||
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
||||||
|
|
||||||
// Make sure BrowserContext is alwasys destroyed after WebContents.
|
ElectronBrowserContext* browser_context_;
|
||||||
scoped_refptr<ElectronBrowserContext> browser_context_;
|
|
||||||
|
|
||||||
// The stored InspectableWebContents object.
|
// The stored InspectableWebContents object.
|
||||||
// Notice that web_contents_ must be placed after dialog_manager_, so we can
|
// Notice that web_contents_ must be placed after dialog_manager_, so we can
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
|
#include "base/no_destructor.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/task/post_task.h"
|
#include "base/task/post_task.h"
|
||||||
|
@ -91,15 +92,17 @@ std::string MakePartitionName(const std::string& input) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ElectronBrowserContext::BrowserContextMap
|
ElectronBrowserContext::BrowserContextMap&
|
||||||
ElectronBrowserContext::browser_context_map_;
|
ElectronBrowserContext::browser_context_map() {
|
||||||
|
static base::NoDestructor<ElectronBrowserContext::BrowserContextMap>
|
||||||
|
browser_context_map;
|
||||||
|
return *browser_context_map;
|
||||||
|
}
|
||||||
|
|
||||||
ElectronBrowserContext::ElectronBrowserContext(const std::string& partition,
|
ElectronBrowserContext::ElectronBrowserContext(const std::string& partition,
|
||||||
bool in_memory,
|
bool in_memory,
|
||||||
base::DictionaryValue options)
|
base::DictionaryValue options)
|
||||||
: base::RefCountedDeleteOnSequence<ElectronBrowserContext>(
|
: in_memory_pref_store_(nullptr),
|
||||||
base::ThreadTaskRunnerHandle::Get()),
|
|
||||||
in_memory_pref_store_(nullptr),
|
|
||||||
storage_policy_(new SpecialStoragePolicy),
|
storage_policy_(new SpecialStoragePolicy),
|
||||||
protocol_registry_(new ProtocolRegistry),
|
protocol_registry_(new ProtocolRegistry),
|
||||||
in_memory_(in_memory),
|
in_memory_(in_memory),
|
||||||
|
@ -444,19 +447,21 @@ ResolveProxyHelper* ElectronBrowserContext::GetResolveProxyHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
scoped_refptr<ElectronBrowserContext> ElectronBrowserContext::From(
|
ElectronBrowserContext* ElectronBrowserContext::From(
|
||||||
const std::string& partition,
|
const std::string& partition,
|
||||||
bool in_memory,
|
bool in_memory,
|
||||||
base::DictionaryValue options) {
|
base::DictionaryValue options) {
|
||||||
PartitionKey key(partition, in_memory);
|
PartitionKey key(partition, in_memory);
|
||||||
auto* browser_context = browser_context_map_[key].get();
|
ElectronBrowserContext* browser_context = browser_context_map()[key].get();
|
||||||
if (browser_context)
|
if (browser_context) {
|
||||||
return scoped_refptr<ElectronBrowserContext>(browser_context);
|
return browser_context;
|
||||||
|
}
|
||||||
|
|
||||||
auto* new_context =
|
auto* new_context =
|
||||||
new ElectronBrowserContext(partition, in_memory, std::move(options));
|
new ElectronBrowserContext(partition, in_memory, std::move(options));
|
||||||
browser_context_map_[key] = new_context->GetWeakPtr();
|
browser_context_map()[key] =
|
||||||
return scoped_refptr<ElectronBrowserContext>(new_context);
|
std::unique_ptr<ElectronBrowserContext>(new_context);
|
||||||
|
return new_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/memory/ref_counted_delete_on_sequence.h"
|
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "chrome/browser/predictors/preconnect_manager.h"
|
#include "chrome/browser/predictors/preconnect_manager.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
|
@ -50,8 +49,7 @@ class WebViewManager;
|
||||||
class ProtocolRegistry;
|
class ProtocolRegistry;
|
||||||
|
|
||||||
class ElectronBrowserContext
|
class ElectronBrowserContext
|
||||||
: public base::RefCountedDeleteOnSequence<ElectronBrowserContext>,
|
: public content::BrowserContext,
|
||||||
public content::BrowserContext,
|
|
||||||
public network::mojom::TrustedURLLoaderAuthClient {
|
public network::mojom::TrustedURLLoaderAuthClient {
|
||||||
public:
|
public:
|
||||||
// partition_id => browser_context
|
// partition_id => browser_context
|
||||||
|
@ -73,19 +71,17 @@ class ElectronBrowserContext
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
using BrowserContextMap =
|
using BrowserContextMap =
|
||||||
std::map<PartitionKey, base::WeakPtr<ElectronBrowserContext>>;
|
std::map<PartitionKey, std::unique_ptr<ElectronBrowserContext>>;
|
||||||
|
|
||||||
// Get or create the BrowserContext according to its |partition| and
|
// Get or create the BrowserContext according to its |partition| and
|
||||||
// |in_memory|. The |options| will be passed to constructor when there is no
|
// |in_memory|. The |options| will be passed to constructor when there is no
|
||||||
// existing BrowserContext.
|
// existing BrowserContext.
|
||||||
static scoped_refptr<ElectronBrowserContext> From(
|
static ElectronBrowserContext* From(
|
||||||
const std::string& partition,
|
const std::string& partition,
|
||||||
bool in_memory,
|
bool in_memory,
|
||||||
base::DictionaryValue options = base::DictionaryValue());
|
base::DictionaryValue options = base::DictionaryValue());
|
||||||
|
|
||||||
static BrowserContextMap browser_context_map() {
|
static BrowserContextMap& browser_context_map();
|
||||||
return browser_context_map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetUserAgent(const std::string& user_agent);
|
void SetUserAgent(const std::string& user_agent);
|
||||||
std::string GetUserAgent() const;
|
std::string GetUserAgent() const;
|
||||||
|
@ -151,15 +147,12 @@ class ElectronBrowserContext
|
||||||
return protocol_registry_.get();
|
return protocol_registry_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
ElectronBrowserContext(const std::string& partition,
|
|
||||||
bool in_memory,
|
|
||||||
base::DictionaryValue options);
|
|
||||||
~ElectronBrowserContext() override;
|
~ElectronBrowserContext() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedDeleteOnSequence<ElectronBrowserContext>;
|
ElectronBrowserContext(const std::string& partition,
|
||||||
friend class base::DeleteHelper<ElectronBrowserContext>;
|
bool in_memory,
|
||||||
|
base::DictionaryValue options);
|
||||||
|
|
||||||
void OnLoaderCreated(int32_t request_id,
|
void OnLoaderCreated(int32_t request_id,
|
||||||
mojo::PendingReceiver<network::mojom::TrustedAuthClient>
|
mojo::PendingReceiver<network::mojom::TrustedAuthClient>
|
||||||
|
@ -168,8 +161,6 @@ class ElectronBrowserContext
|
||||||
// Initialize pref registry.
|
// Initialize pref registry.
|
||||||
void InitPrefs();
|
void InitPrefs();
|
||||||
|
|
||||||
static BrowserContextMap browser_context_map_;
|
|
||||||
|
|
||||||
ValueMapPrefStore* in_memory_pref_store_;
|
ValueMapPrefStore* in_memory_pref_store_;
|
||||||
|
|
||||||
std::unique_ptr<content::ResourceContext> resource_context_;
|
std::unique_ptr<content::ResourceContext> resource_context_;
|
||||||
|
|
|
@ -553,6 +553,8 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
|
||||||
js_env_->OnMessageLoopDestroying();
|
js_env_->OnMessageLoopDestroying();
|
||||||
node_env_.reset();
|
node_env_.reset();
|
||||||
|
|
||||||
|
ElectronBrowserContext::browser_context_map().clear();
|
||||||
|
|
||||||
fake_browser_process_->PostMainMessageLoopRun();
|
fake_browser_process_->PostMainMessageLoopRun();
|
||||||
content::DevToolsAgentHost::StopRemoteDebuggingPipeHandler();
|
content::DevToolsAgentHost::StopRemoteDebuggingPipeHandler();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ bool ElectronExtensionsBrowserClient::AreExtensionsDisabled(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ElectronExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
bool ElectronExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
||||||
auto context_map = ElectronBrowserContext::browser_context_map();
|
auto& context_map = ElectronBrowserContext::browser_context_map();
|
||||||
for (auto const& entry : context_map) {
|
for (auto const& entry : context_map) {
|
||||||
if (entry.second && entry.second.get() == context)
|
if (entry.second && entry.second.get() == context)
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,7 +113,7 @@ BrowserContext* ElectronExtensionsBrowserClient::GetOriginalContext(
|
||||||
BrowserContext* context) {
|
BrowserContext* context) {
|
||||||
DCHECK(context);
|
DCHECK(context);
|
||||||
if (context->IsOffTheRecord()) {
|
if (context->IsOffTheRecord()) {
|
||||||
return ElectronBrowserContext::From("", false).get();
|
return ElectronBrowserContext::From("", false);
|
||||||
} else {
|
} else {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ void ElectronExtensionsBrowserClient::BroadcastEventToRenderers(
|
||||||
|
|
||||||
std::unique_ptr<extensions::Event> event(
|
std::unique_ptr<extensions::Event> event(
|
||||||
new extensions::Event(histogram_value, event_name, std::move(args)));
|
new extensions::Event(histogram_value, event_name, std::move(args)));
|
||||||
auto context_map = ElectronBrowserContext::browser_context_map();
|
auto& context_map = ElectronBrowserContext::browser_context_map();
|
||||||
for (auto const& entry : context_map) {
|
for (auto const& entry : context_map) {
|
||||||
if (entry.second) {
|
if (entry.second) {
|
||||||
extensions::EventRouter::Get(entry.second.get())
|
extensions::EventRouter::Get(entry.second.get())
|
||||||
|
|
|
@ -419,7 +419,7 @@ void ElectronURLLoaderFactory::StartLoadingHttp(
|
||||||
if (request->method != "GET" && request->method != "HEAD")
|
if (request->method != "GET" && request->method != "HEAD")
|
||||||
dict.Get("uploadData", &upload_data);
|
dict.Get("uploadData", &upload_data);
|
||||||
|
|
||||||
scoped_refptr<ElectronBrowserContext> browser_context =
|
ElectronBrowserContext* browser_context =
|
||||||
ElectronBrowserContext::From("", false);
|
ElectronBrowserContext::From("", false);
|
||||||
v8::Local<v8::Value> value;
|
v8::Local<v8::Value> value;
|
||||||
if (dict.Get("session", &value)) {
|
if (dict.Get("session", &value)) {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
const { app, BrowserWindow } = require('electron');
|
||||||
|
|
||||||
|
app.on('ready', async () => {
|
||||||
|
const win = new BrowserWindow({ show: false, webPreferences: { partition: '123321' } });
|
||||||
|
await win.loadURL('data:text/html,<body>');
|
||||||
|
setTimeout(() => app.quit());
|
||||||
|
});
|
Loading…
Reference in a new issue