Skip to content

Commit

Permalink
Deploy more smart pointers in Source/WebKit/UIProcess/Extensions
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260845

Reviewed by Brian Weinstein.

Deployed more smart pointers.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::removePermissionMatchPatterns):
(WebKit::WebExtensionContext::addInjectedContent):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::addPage):
(WebKit::WebExtensionController::removePage):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.cpp:
(WebKit::WebExtensionContext::processes const):

Canonical link: https://commits.webkit.org/267429@main
  • Loading branch information
rniwa committed Aug 29, 2023
1 parent d6f0fed commit 787859b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,9 @@ static _WKWebExtensionContextError toAPI(WebExtensionContext::Error error)
}

for (auto& patternToRemove : matchPatternsToRemove) {
if (patternToRemove->matchesPattern(entry.key, WebExtensionMatchPattern::Options::IgnorePaths)) {
removedMatchPatterns.add(entry.key);
Ref pattern = entry.key;
if (patternToRemove->matchesPattern(pattern, WebExtensionMatchPattern::Options::IgnorePaths)) {
removedMatchPatterns.add(pattern);
return true;
}
}
Expand Down Expand Up @@ -1926,7 +1927,7 @@ static _WKWebExtensionContextError toAPI(WebExtensionContext::Error error)
auto injectedFrames = injectedContentData.injectsIntoAllFrames ? WebCore::UserContentInjectedFrames::InjectInAllFrames : WebCore::UserContentInjectedFrames::InjectInTopFrameOnly;
auto injectionTime = toImpl(injectedContentData.injectionTime);
auto waitForNotification = WebCore::WaitForNotificationBeforeInjecting::No;
auto& executionWorld = injectedContentData.forMainWorld ? API::ContentWorld::pageContentWorld() : *m_contentScriptWorld;
Ref executionWorld = injectedContentData.forMainWorld ? API::ContentWorld::pageContentWorld() : *m_contentScriptWorld;

for (NSString *scriptPath in injectedContentData.scriptPaths.get()) {
NSString *scriptString = m_extension->resourceStringForPath(scriptPath, WebExtension::CacheResult::Yes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,21 @@
for (auto& entry : m_registeredSchemeHandlers)
page.setURLSchemeHandlerForScheme(entry.value.copyRef(), entry.key);

addProcessPool(page.process().processPool());
addUserContentController(page.userContentController());
Ref pool = page.process().processPool();
addProcessPool(pool);
Ref controller = page.userContentController();
addUserContentController(controller);
}

void WebExtensionController::removePage(WebPageProxy& page)
{
ASSERT(m_pages.contains(page));
m_pages.remove(page);

removeProcessPool(page.process().processPool());
removeUserContentController(page.userContentController());
Ref pool = page.process().processPool();
removeProcessPool(pool);
Ref controller = page.userContentController();
removeUserContentController(controller);
}

void WebExtensionController::addProcessPool(WebProcessPool& processPool)
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/Extensions/WebExtensionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ WeakHashSet<WebProcessProxy> WebExtensionContext::processes(WebExtensionEventLis
auto page = m_eventListenerPages.find(type);
if (page != m_eventListenerPages.end()) {
for (auto entry : page->value) {
auto& process = entry.key.process();
if (process.canSendMessage())
Ref process = entry.key.process();
if (process->canSendMessage())
processes.add(process);
}
}
Expand Down

0 comments on commit 787859b

Please sign in to comment.