feat: preliminary support for //extensions (#17440)
This commit is contained in:
parent
bd526f97a5
commit
95977291f7
54 changed files with 2483 additions and 36 deletions
|
@ -15,6 +15,7 @@
|
|||
#include "chrome/browser/net/proxy_config_monitor.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/resource_context.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "shell/browser/media/media_device_id_salt.h"
|
||||
#include "shell/browser/net/url_request_context_getter.h"
|
||||
|
||||
|
@ -26,6 +27,12 @@ namespace storage {
|
|||
class SpecialStoragePolicy;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
namespace extensions {
|
||||
class AtomExtensionSystem;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace electron {
|
||||
|
||||
class AtomBlobReader;
|
||||
|
@ -41,6 +48,27 @@ class AtomBrowserContext
|
|||
: public base::RefCountedDeleteOnSequence<AtomBrowserContext>,
|
||||
public content::BrowserContext {
|
||||
public:
|
||||
// partition_id => browser_context
|
||||
struct PartitionKey {
|
||||
std::string partition;
|
||||
bool in_memory;
|
||||
|
||||
PartitionKey(const std::string& partition, bool in_memory)
|
||||
: partition(partition), in_memory(in_memory) {}
|
||||
|
||||
bool operator<(const PartitionKey& other) const {
|
||||
if (partition == other.partition)
|
||||
return in_memory < other.in_memory;
|
||||
return partition < other.partition;
|
||||
}
|
||||
|
||||
bool operator==(const PartitionKey& other) const {
|
||||
return (partition == other.partition) && (in_memory == other.in_memory);
|
||||
}
|
||||
};
|
||||
using BrowserContextMap =
|
||||
std::map<PartitionKey, base::WeakPtr<AtomBrowserContext>>;
|
||||
|
||||
// Get or create the BrowserContext according to its |partition| and
|
||||
// |in_memory|. The |options| will be passed to constructor when there is no
|
||||
// existing BrowserContext.
|
||||
|
@ -49,6 +77,10 @@ class AtomBrowserContext
|
|||
bool in_memory,
|
||||
const base::DictionaryValue& options = base::DictionaryValue());
|
||||
|
||||
static BrowserContextMap browser_context_map() {
|
||||
return browser_context_map_;
|
||||
}
|
||||
|
||||
void SetUserAgent(const std::string& user_agent);
|
||||
std::string GetUserAgent() const;
|
||||
bool CanUseHttpCache() const;
|
||||
|
@ -84,6 +116,13 @@ class AtomBrowserContext
|
|||
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
||||
override;
|
||||
|
||||
// extensions deps
|
||||
void SetCorsOriginAccessListForOrigin(
|
||||
const url::Origin& source_origin,
|
||||
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
|
||||
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
|
||||
base::OnceClosure closure) override;
|
||||
|
||||
CookieChangeNotifier* cookie_change_notifier() const {
|
||||
return cookie_change_notifier_.get();
|
||||
}
|
||||
|
@ -114,26 +153,6 @@ class AtomBrowserContext
|
|||
// Initialize pref registry.
|
||||
void InitPrefs();
|
||||
|
||||
// partition_id => browser_context
|
||||
struct PartitionKey {
|
||||
std::string partition;
|
||||
bool in_memory;
|
||||
|
||||
PartitionKey(const std::string& partition, bool in_memory)
|
||||
: partition(partition), in_memory(in_memory) {}
|
||||
|
||||
bool operator<(const PartitionKey& other) const {
|
||||
if (partition == other.partition)
|
||||
return in_memory < other.in_memory;
|
||||
return partition < other.partition;
|
||||
}
|
||||
|
||||
bool operator==(const PartitionKey& other) const {
|
||||
return (partition == other.partition) && (in_memory == other.in_memory);
|
||||
}
|
||||
};
|
||||
using BrowserContextMap =
|
||||
std::map<PartitionKey, base::WeakPtr<AtomBrowserContext>>;
|
||||
static BrowserContextMap browser_context_map_;
|
||||
|
||||
// Self-destructing class responsible for creating URLRequestContextGetter
|
||||
|
@ -162,6 +181,11 @@ class AtomBrowserContext
|
|||
bool use_cache_ = true;
|
||||
int max_cache_size_ = 0;
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
// Owned by the KeyedService system.
|
||||
extensions::AtomExtensionSystem* extension_system_;
|
||||
#endif
|
||||
|
||||
base::WeakPtrFactory<AtomBrowserContext> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue