---
title: SFSafariExtensionHandling
framework: safariservices
role: symbol
role_heading: Protocol
path: safariservices/sfsafariextensionhandling
---

# SFSafariExtensionHandling

A protocol for implementing event handling in a Safari app extension.

## Declaration

```swift
protocol SFSafariExtensionHandling : NSObjectProtocol
```

## Topics

### Receiving Messages in Your App Extension

- [messageReceived(withName:from:userInfo:)](safariservices/sfsafariextensionhandling/messagereceived(withname:from:userinfo:).md)
- [messageReceivedFromContainingApp(withName:userInfo:)](safariservices/sfsafariextensionhandling/messagereceivedfromcontainingapp(withname:userinfo:).md)

### Responding to Context Menu Selections

- [contextMenuItemSelected(withCommand:in:userInfo:)](safariservices/sfsafariextensionhandling/contextmenuitemselected(withcommand:in:userinfo:).md)
- [validateContextMenuItem(withCommand:in:userInfo:validationHandler:)](safariservices/sfsafariextensionhandling/validatecontextmenuitem(withcommand:in:userinfo:validationhandler:).md)

### Working with Toolbar Items

- [toolbarItemClicked(in:)](safariservices/sfsafariextensionhandling/toolbaritemclicked(in:).md)
- [validateToolbarItem(in:validationHandler:)](safariservices/sfsafariextensionhandling/validatetoolbaritem(in:validationhandler:).md)

### Working with Popovers

- [popoverViewController()](safariservices/sfsafariextensionhandling/popoverviewcontroller().md)
- [popoverWillShow(in:)](safariservices/sfsafariextensionhandling/popoverwillshow(in:).md)
- [popoverDidClose(in:)](safariservices/sfsafariextensionhandling/popoverdidclose(in:).md)

### Working with Content Blockers

- [contentBlocker(withIdentifier:blockedResourcesWith:on:)](safariservices/sfsafariextensionhandling/contentblocker(withidentifier:blockedresourceswith:on:).md)

### Responding to Page Navigation

- [page(_:willNavigateTo:)](safariservices/sfsafariextensionhandling/page(_:willnavigateto:).md)

### Instance Methods

- [additionalRequestHeaders(for:completionHandler:)](safariservices/sfsafariextensionhandling/additionalrequestheaders(for:completionhandler:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

### Conforming Types

- [SFSafariExtensionHandler](safariservices/sfsafariextensionhandler.md)

## See Also

### Related Documentation

- [dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:)](safariservices/sfsafariapplication/dispatchmessage(withname:toextensionwithidentifier:userinfo:completionhandler:).md)

### Injected style sheets and scripts

- [Using injected style sheets and scripts](safariservices/using-injected-style-sheets-and-scripts.md)
- [Injecting a script into a webpage](safariservices/injecting-a-script-into-a-webpage.md)
- [Injecting CSS style sheets into a webpage](safariservices/injecting-css-style-sheets-into-a-webpage.md)
- [Passing messages between Safari app extensions and injected scripts](safariservices/passing-messages-between-safari-app-extensions-and-injected-scripts.md)
- [SFSafariExtensionHandler](safariservices/sfsafariextensionhandler.md)
- [SFSafariExtensionManager](safariservices/sfsafariextensionmanager.md)
- [SFSafariExtensionState](safariservices/sfsafariextensionstate.md)
- [SFSafariPageProperties](safariservices/sfsafaripageproperties.md)
- [SFExtensionProfileKey](safariservices/sfextensionprofilekey.md)
