0
Files
android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
codelabs
components
about_ui
access_code_cast
account_id
account_manager_core
aggregation_service
android_autofill
android_system_error_page
apdu
app_constants
app_restore
arc
arc_strings_grdp
assist_ranker
attribution_reporting
autofill
autofill_payments_strings_grdp
autofill_strings_grdp
back_forward_cache
background_fetch
background_sync
background_task_scheduler
base32
blocked_content
blocklist
bookmark_bar_strings_grdp
bookmark_component_strings_grdp
bookmarks
breadcrumbs
browser_sync
browser_ui
browser_watcher
browsing_data
browsing_data_strings_grdp
browsing_topics
captive_portal
cast
cast_receiver
cast_streaming
cbor
cdm
certificate_matching
certificate_transparency
chrome_cleaner
chromeos_camera
client_hints
client_update_protocol
cloud_devices
commerce
commerce_strings_grdp
component_updater
components_chromium_strings_grd
components_google_chrome_strings_grd
components_strings_grd
consent_auditor
constrained_window
content_capture
content_creation
content_creation_strings_grdp
content_settings
contextual_search
continuous_search
cookie_config
country_codes
crash
crash_strings_grdp
creator
cronet
crx_file
custom_handlers
BUILD.gn
DEPS
OWNERS
README.md
pref_names.cc
pref_names.h
protocol_handler.cc
protocol_handler.h
protocol_handler_registry.cc
protocol_handler_registry.h
protocol_handler_registry_browsertest.cc
protocol_handler_registry_unittest.cc
protocol_handler_throttle.cc
protocol_handler_throttle.h
register_protocol_handler_permission_request.cc
register_protocol_handler_permission_request.h
simple_protocol_handler_registry_factory.cc
simple_protocol_handler_registry_factory.h
test_protocol_handler_registry_delegate.cc
test_protocol_handler_registry_delegate.h
database_utils
dbus
desks_storage
device_event_log
device_reauth
device_signals
devtools
digital_asset_links
digital_goods
discardable_memory
dom_distiller
dom_distiller_strings_grdp
domain_reliability
download
drive
embedder_support
encrypted_messages
endpoint_fetcher
enterprise
enterprise_strings_grdp
error_page
error_page_strings_grdp
exo
external_intents
external_intents_strings_grdp
externalauth
favicon
favicon_base
feature_engagement
feed
feedback
file_access
filename_generation
find_in_page
flags_strings_grdp
flags_ui
fuchsia_component_support
fuchsia_legacymetrics
fullscreen_control
fullscreen_control_strings_grdp
gcm_driver
global_media_controls
global_media_controls_strings_grdp
google
grpc_support
guest_os
guest_view
gwp_asan
handoff
headless
heap_profiling
heavy_ad_intervention
heavy_ad_intervention_strings_grdp
history
history_clusters
history_clusters_strings_grdp
history_strings_grdp
image_fetcher
image_service
infobars
installedapp
invalidation
javascript_dialogs
javascript_dialogs_strings_grdp
js_injection
keep_alive_registry
keyed_service
language
lens
leveldb_proto
link_header_util
live_caption
live_caption_strings_grdp
local_state
location
login
lookalikes
management
management_ios_strings_grdp
management_strings_grdp
media_control
media_message_center
media_message_center_strings_grdp
media_router
memory_pressure
messages
metal_util
metrics
metrics_services_manager
minidump_uploader
mirroring
ml
module_installer
nacl
named_mojo_ipc_server
navigation_interception
navigation_metrics
net_log
neterror
network_hints
network_session_configurator
network_time
new_or_sad_tab_strings_grdp
no_state_prefetch
ntp_snippets
ntp_snippets_strings_grdp
ntp_tiles
offline_items_collection
offline_pages
omnibox
omnibox_pedal_ui_strings_grdp
omnibox_strings_grdp
on_load_script_injector
onc
open_from_clipboard
openscreen_platform
optimization_guide
origin_trials
os_crypt
ownership
page_image_annotation
page_info
page_info_strings_grdp
page_load_metrics
paint_preview
password_manager
password_manager_strings_grdp
payments
payments_strings_grdp
pdf
pdf_strings_grdp
performance_manager
permissions
permissions_strings_grdp
plugins
policy
policy_strings_grdp
power_bookmarks
power_metrics
power_monitor
power_scheduler
pref_registry
prefs
previous_session_info
print_media_strings_grdp
printing
printing_component_strings_grdp
privacy_sandbox
privacy_sandbox_strings_grdp
profile_metrics
proxy_config
pwg_encoder
qr_code_generator
query_parser
query_tiles
quirks
reading_list
reduce_accept_language
remote_cocoa
renderer_context_menu
reporting
reset_password_strings_grdp
resources
rlz
safe_browsing
safe_search_api
safety_check
saved_tab_groups
scheduling_metrics
schema_org
search
search_engines
search_provider_logos
security_interstitials
security_interstitials_strings_grdp
security_state
segmentation_platform
send_tab_to_self
send_tab_to_self_strings_grdp
services
session_manager
session_proto_db
sessions
shared_highlighting
signin
site_engagement
site_isolation
site_settings_strings_grdp
sms_strings_grdp
soda
soda_strings_grdp
speech
spellcheck
sqlite_proto
ssl_errors
ssl_errors_strings_grdp
startup_metric_utils
storage_monitor
strictmode
strings
stylus_handwriting
subresource_filter
subresource_filter_strings_grdp
supervised_user
supervised_user_strings_grdp
sync
sync_bookmarks
sync_device_info
sync_preferences
sync_sessions
sync_ui_strings_grdp
sync_user_events
system_media_controls
tab_groups
tab_groups_strings_grdp
test
thin_webview
tracing
translate
translate_strings_grdp
ui_devtools
ui_metrics
ukm
undo
undo_strings_grdp
unexportable_keys
unified_consent
update_client
upload_list
url_formatter
url_matcher
url_pattern_index
url_rewrite
user_actions_ui
user_education
user_education_strings_grdp
user_manager
user_notes
user_prefs
value_store
variations
vector_icons
version_info
version_ui
version_ui_strings_grdp
visitedlink
viz
web_app_resources
web_cache
web_modal
web_package
web_resource
webapk
webapps
webauthn
webcrypto
webdata
webdata_services
webrtc
webrtc_logging
webxr
webxr_strings_grdp
wifi
winhttp
zoom
zucchini
.eslintrc.js
BUILD.gn
DEPS
OWNERS
PRESUBMIT.py
README.md
android_system_error_page_strings.grdp
arc_strings.grdp
autofill_payments_strings.grdp
autofill_strings.grdp
blocked_content_strings.grdp
bookmark_bar_strings.grdp
bookmark_component_strings.grdp
browsing_data_strings.grdp
commerce_strings.grdp
components_chromium_strings.grd
components_google_chrome_strings.grd
components_locale_settings.grd
components_settings_strings.grdp
components_strings.grd
content_creation_strings.grdp
crash_strings.grdp
dialog_strings.grdp
dom_distiller_strings.grdp
enterprise_strings.grdp
error_page_strings.grdp
external_intents_strings.grdp
find_in_page_strings.grdp
flags_strings.grdp
fullscreen_control_strings.grdp
global_media_controls_strings.grdp
heavy_ad_intervention_strings.grdp
history_clusters_strings.grdp
history_strings.grdp
javascript_dialogs_strings.grdp
live_caption_strings.grdp
login_dialog_strings.grdp
management_ios_strings.grdp
management_strings.grdp
media_message_center_strings.grdp
new_or_sad_tab_strings.grdp
ntp_snippets_strings.grdp
omnibox_pedal_ui_strings.grdp
omnibox_strings.grdp
page_info_strings.grdp
paint_preview_strings.grdp
password_manager_strings.grdp
payments_strings.grdp
pdf_strings.grdp
permissions_strings.grdp
policy_strings.grdp
print_media_strings.grdp
printing_component_strings.grdp
privacy_sandbox_strings.grdp
protocol_handler_strings.grdp
reset_password_strings.grdp
security_interstitials_strings.grdp
send_tab_to_self_strings.grdp
site_settings_strings.grdp
sms_strings.grdp
soda_strings.grdp
ssl_errors_strings.grdp
subresource_filter_strings.grdp
supervised_user_strings.grdp
sync_ui_strings.grdp
tab_groups_strings.grdp
translate_strings.grdp
undo_strings.grdp
user_education_strings.grdp
version_ui_strings.grdp
webapps_strings.grdp
webxr_strings.grdp
content
courgette
crypto
dbus
device
docs
extensions
fuchsia_web
gin
google_apis
google_update
gpu
headless
infra
ios
ipc
media
mojo
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
weblayer
.clang-format
.clang-tidy
.eslintrc.js
.git-blame-ignore-revs
.gitattributes
.gitignore
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/components/custom_handlers
Javier Fernández García-Boente c0e70558d0 Implement devtools protocol support for SetRPHRegistrationMode
See: https://chromium-review.googlesource.com/c/chromium/src/+/4200660

This CL adds a new enum attribute to the ProtocolHandlerRegistry to
operate under a mode where it will automatically simulate a user either
accepting or rejecting a registration confirmation prompt dialog.

Bug: 1359103
Change-Id: I9f99b82eee08a0b249ce79c1db5463ffc58e9dae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4203529
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Danil Somsikov <dsv@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100903}
2023-02-03 09:41:13 +00:00
..

Custom Handlers

The custom handlers component provides a way to register custom protocol handlers for specific URL schemes. This is part of the implementation of the System state and capabilities defined in the HTML spec. Specifically, it implements the interface NavigatorContentUtils from which the Navigator object derives.

These handlers may be used to translate the http request's URL so that it is redirected to the appropriated service (e.g. email, apps) or a different http(s) site.

All the component's code is intended to be run by the Browser process, in the UI thread.

Security and privacy

The component addresses the security and privacy considerations described in the HTML spec.

A protocol handler is only valid if it passes all protocol handler parameters normalization steps. These security and privacy checks are:

Chromium defines a hierarchy of security levels to relax the restrictions imposed by the spec and allow the implementation of certain features. Being strict the default behavior and the one defined in the spec, there are levels for allowing untrusted-origins and schemes not listed in the mentioned safelist defined in the spec.

For instance, on order to make possible for extensions to register their own pages as handlers, the chrome-extension scheme is also allowed when security level is blink::ProtocolHandlerSecurityLevel::kExtensionFeatures.

It's also worth mentioned that Chromium defines its own kProtocolSafelist that includes some additional decentralized schemes that are not being explicitly defined in the mentioned.

High-level architecture

Browser

  +--------------------------------------------------------------------+
  | //components/custom_handlers                                       |
  |                                                                    |
  |                     +------------------------------------------+   |
  |                     | RegisterProtocolHandlerPermissionRequest |   |
  |                     +------------------------------------------+   |
  |                                                / \                 |
  |      +-----------------+                        |                  |
  |      | ProtocolHandler | <-------------+        |                  |
  |      +-----------------+               |        |                  |
  |              / \                       |        |                  |
  |               |                        |        |                  |
  |               |                        |        |                  |
  |               |                        |        |                  |
  |   +-------------------------+          |        |                  |
  |   | ProtocolHandlerRegistry | <--------+        |                  |
  |   +-------------------------+          |        |                  |
  |              / \                       |        |                  |
  |               |                        |        |                  |
  |               |                        |        |                  |
  +--------------------------------------------------------------------+
                  |                        |        |
                  |                        |        |
  +--------------------------------------------------------------------+
  | //chrome      |                        |        |                  |
  |               |                        |        |                  |
  | +--------------------------------+     |  +---------+              |    +--------------------------+
  | | ProtocolHandlerRegistryFactory | <----- | Browser | ----------------> | PermissionRequestManager |
  | +--------------------------------+        +---------+              |    +--------------------------+
  |                                                / \                 |
  |                                                 |                  |
  +--------------------------------------------------------------------+
                                                    |
  +--------------------------------------------------------------------+
  | //content                                       |                  |
  |                                                 |                 |
  |   +-----------------+            +---------------------+           |
  |   | WebContentsImpl | ---------> | WebContentsDelegate |           |
  |   +-----------------+            +---------------------+           |
  |          / \                                                       |
  |           |                                                        |
  |           |                                                        |
  |           |                                                        |
  |  +-------------------------+            +---------------------+    |
  |  | RenderFrameHostDelegate | <--------- | RenderFrameHostImpl |    |
  |  +-------------------------+            +---------------------+    |
  |                                                 |                  |
  |                                                 |                  |
  +--------------------------------------------------------------------+
                                                    |
                                                    |
+--------------------------------------------------------------------------------------------------------+
Renderer                                            |
                                                    |
  +--------------------------------------------------------------------+
  | //blink                                         |                  |
  |                                                 V                  |
  |  +-----------------------+       +------------------------------+  |
  |  | NavigatorContentUtils | ----> | mojom::blink::LocalFrameHost |  |
  |  +-----------------------+       +------------------------------+  |
  |                                                                    |
  +--------------------------------------------------------------------+

Here is a summary of the core responsibilities of the classes and interfaces:

  • ProtocolHandler

    It's the class responsible of the security and privacy validation mentioned before, and eventually of the http request's URL translation, using the protocol handler's url spec.

  • ProtocolHandlerRegistry

    This class is implemented as a KeyedService which means it is attached to a BrowserContext.

    The registry holds different kind of protocol handlers lists, depending on their source during the registration: user or internal policies. The registry also provides an API to selectively ignore protocol handlers, which are managed in an independent list.

    There are also some predefined-handlers, which are automatically registered by the registry factory during the service's initialization.

    Finally there is a list of the default handlers for each protocol.

    All the protocol handlers managed by the registry are stored in the user preference storage, based on the user profile (the Browser Context) used to initialize the keyed service. This makes possible to guarantee the persistence of the protocol handlers state.

  • ProtocolHandlerThrottle

    It implements the blink's blink::URLLoaderThrottle interface to manage the http request. It holds a pointer to a ProtocolHandlerRegistry instance to performs the URL translation if there is a custom handler for the protocol used for the request.

  • RegisterProtocolHandlerPermissionRequest

    It implements the PermissionRequest interface to manage user authorization for the requests issued by the Navigator object's registerProtocolHandler() method. An instance of this class holds a pointer to a ProtocolHandlerRegistry instance and a ProtocolHandler reference to be registered.

    It performs the handler registration of granted, or adds it to the ignored list if denied.