refactor: Add ElectronBrowserContext::BrowserContexts()
(35-x-y backport) (#46161)
refactor: Add `ElectronBrowserContext::BrowserContexts()` * refactor: add ElectronBrowserContext::BrowserContexts() * refactor: use ElectronBrowserContext::BrowserContexts() in ElectronBrowserMainParts::PostMainMessageLoopRun() * refactor: use ElectronBrowserContext::BrowserContexts() in ElectronExtensionsBrowserClient::IsValidContext() * refactor: use ElectronBrowserContext::BrowserContexts() in ElectronExtensionsBrowserClient::BroadcastEventToRenderers() * refactor: move PartitionKey, BrowserContextMap private * refactor: add ElectronBrowserContext::IsValidContext() decouple ElectronExtensionsBrowserClient from the internals of ElectronBrowserContext
This commit is contained in:
parent
e3d95bb8a4
commit
998de7aa6c
4 changed files with 58 additions and 51 deletions
|
@ -85,12 +85,7 @@ bool ElectronExtensionsBrowserClient::AreExtensionsDisabled(
|
|||
}
|
||||
|
||||
bool ElectronExtensionsBrowserClient::IsValidContext(void* context) {
|
||||
auto& context_map = ElectronBrowserContext::browser_context_map();
|
||||
for (auto const& entry : context_map) {
|
||||
if (entry.second && entry.second.get() == context)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ElectronBrowserContext::IsValidContext(context);
|
||||
}
|
||||
|
||||
bool ElectronExtensionsBrowserClient::IsSameContext(BrowserContext* first,
|
||||
|
@ -341,13 +336,10 @@ void ElectronExtensionsBrowserClient::BroadcastEventToRenderers(
|
|||
return;
|
||||
}
|
||||
|
||||
for (auto const& [key, browser_context] :
|
||||
ElectronBrowserContext::browser_context_map()) {
|
||||
if (browser_context) {
|
||||
extensions::EventRouter::Get(browser_context.get())
|
||||
->BroadcastEvent(std::make_unique<extensions::Event>(
|
||||
histogram_value, event_name, args.Clone()));
|
||||
}
|
||||
for (auto* browser_context : ElectronBrowserContext::BrowserContexts()) {
|
||||
extensions::EventRouter::Get(browser_context)
|
||||
->BroadcastEvent(std::make_unique<extensions::Event>(
|
||||
histogram_value, event_name, args.Clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue