[webkit-changes] [WebKit/WebKit] dd82fa: Add WebExtensionSidebar object to UIProcess.

Ariel Young noreply at github.com
Tue Aug 6 01:07:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dd82fa0c239ee137d28c8b225390b0d482d9b401
      https://github.com/WebKit/WebKit/commit/dd82fa0c239ee137d28c8b225390b0d482d9b401
  Author: Ari Young <ari_young at apple.com>
  Date:   2024-08-06 (Tue, 06 Aug 2024)

  Changed paths:
    M Source/WebKit/Platform/cocoa/CocoaHelpers.h
    M Source/WebKit/Shared/API/APIObject.h
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    A Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionSidebarCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtension.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    A Source/WebKit/UIProcess/Extensions/WebExtensionSidebar.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  Add WebExtensionSidebar object to UIProcess.
https://webkit.org/b/277574
rdar://133073139

Reviewed by Timothy Hatcher.

This PR adds the WebExtensionSidebar class to UIProcess. The structure
of this class closely mirrors that of WebExtensionAction, except it
prefers to use std::optional over nullable pointers when possible. This
PR also adds several utility methods in WebExtensionContext which will
be used to manage the WebExtensionSidebar objects necessary to service
the sidePanel / sidebarAction APIs for each extensions that utilizes
them.

* Source/WebKit/Platform/cocoa/CocoaHelpers.h:
 (WebKit::toOptional): Add helper method to convert nulltable T * (where
T is some Cocoa type) to optional<RetainPtr<T>>, where the interior
RetainPtr is guaranteed to be non-null
* Source/WebKit/Shared/API/APIObject.h: Add WebExtensionSidebar to
  API::Object::Type enum
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::sidebarIcon): Getter for current extension's
default sidebar icon
(WebKit::WebExtension::sidebarDocumentPath): Getter for current
extension's default document path
(WebKit::WebExtension::sidebarTitle): Getter for current extension's
default sidebar title
(WebKit::WebExtension::populateSidebarPropertiesIfNeeded): Helper method
to populate sidebar-related properties if needed
(WebKit::WebExtension::populateSidebarActionProperties): Helper method
to populate sidebar-related properties when sidebarAction is detected
(WebKit::WebExtension::populateSidePanelProperties): Helper method to
populate sidebar-related properties when sidePanel is detected
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload): Set m_defaultSidebar to nullptr
on unload
(WebKit::WebExtensionContext::defaultSidebar): Getter for
m_defaultSidebar
(WebKit::WebExtensionContext::getSidebar): Getters for window- or
tab-specific sidebar objects
(WebKit::WebExtensionContext::getOrCreateSidebar): Functions to create
and get window- or tab-specific sidebar objects
* Source/WebKit/UIProcess/Extensions/WebExtensionSidebar.h: Added.
(WebKit::WebExtensionSidebar::create): Canonical WebKit create method
(WebKit::WebExtensionSidebar::isOpen const): Getter for m_isOpen
(WebKit::WebExtensionSidebar::opensSidebar): Method to check if the
current sidebar has a valid path, enabling it to be opened
(WebKit::WebExtensionSidebar::isDefaultSidebar const): Method to check
if this sidebar object is the default sidebar object
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionSidebarCocoa.mm: Added.
(WebKit::getDefaultSidebarTitleFromExtension): Utility function to
retrieve the manifest-specified default sidebar title for an extension
(WebKit::getDefaultSidebarPathFromExtension): Utility function to
retrieve the manifest-specified default sidebar path for an extension
(WebKit::WebExtensionSidebar::WebExtensionSidebar): Constructor for
WebExtensionSidebar which populates instance variables and performs a
simple sanity check on the provided window and tab values
(WebKit::WebExtensionSidebar::extensionContext const): Getter for
this sidebar's context
(WebKit::WebExtensionSidebar::tab const): Getter for this
sidebar's tab
(WebKit::WebExtensionSidebar::window const): Getter for this
sidebar's window
(WebKit::WebExtensionSidebar::parent const): Getter for this
sidebar's parent. It will check the current context for a less-specific
sidebar override if present, otherwise returning the default sidebar. If
this sidebar is the default sidebar, it will return std::nullopt (since
the default sidebar has no parent).
(WebKit::WebExtensionSidebar::propertiesDidChange): Function to notify
the browser through the yet-unimplemented sidebar delegate methods that
the properties of this sidebar have changed.
(WebKit::WebExtensionSidebar::icon): Getter for the icon override of this
sidebar, or this sidebar's parent if there is no override set.
(WebKit::WebExtensionSidebar::setIconsDictionary): Setter for this
sidebar's icon override
(WebKit::WebExtensionSidebar::title const): Getter for the title
override of this sidebar, or this sidebar's parent if there is no
override set.
(WebKit::WebExtensionSidebar::setTitle): Setter for this
sidebar's title override.
(WebKit::WebExtensionSidebar::isEnabled const): Getter to determine if
this specific sidebar is enabled.
(WebKit::WebExtensionSidebar::setEnabled): Setter to set whether this
specific sidebar is enabled.
(WebKit::WebExtensionSidebar::canProgrammaticallyOpenSidebar const):
Function to check whether it is possible to programmatically open this
sidebar. It ensures that this extension's context is present, and that
the context contains a valid extension controller object
(WebKit::WebExtensionSidebar::openSidebarWhenReady): Currently
unimplemented method to open this sidebar when the delegate is ready to
do so.
(WebKit::WebExtensionSidebar::canProgrammaticallyCloseSidebar const):
Functino to check whether it is possible to programmatically close this
sidebar. It ensures that this extension's context is present, and that
the context contains a valid extension controller object.
(WebKit::WebExtensionSidebar::closeSidebarWhenReady): Currently
unimplemented method to close this sidebar when the delegate is ready to
do so.
(WebKit::WebExtensionSidebar::sidebarPath const): Getter for this
sidebar's path override, or its parent's if there is no override set.
(WebKit::WebExtensionSidebar::setSidebarPath): Setter for this
particualr sidebar's path override.
(WebKit::WebExtensionSidebar::webView): Getter for this sidebar's
WebView.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: Add member
  variables to service sidebar management methods, add sidebar
management method declarations.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add
  WebExtensionSidebar.h and WebExtensionSidebar.mm to the project.

Canonical link: https://commits.webkit.org/281881@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list