Skip to content

Commit

Permalink
Rename addSiteAccessRequest to addHostAccessRequest (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverdunk authored Nov 26, 2024
1 parent 6b4db6a commit 74e1edf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# permissions.addSiteAccessRequest() Demo
# permissions.addHostAccessRequest() Demo

This sample demonstrates using the `permissions.addSiteAccessRequest` API to request access to a site.
This sample demonstrates using the `permissions.addHostAccessRequest` API to request access to a host.

## Overview

Expand All @@ -11,11 +11,10 @@ This API allows you to request access to an origin listed in `optional_host_perm
1. Clone this repository.
2. Make sure you have the latest version of Chrome Canary installed.
3. At chrome://flags, enable the "Extensions Menu Access Control" flag.
4. Close Chrome Canary.
5. Start Chrome Canary with the `--enable-features=ApiPermissionsSiteAccessRequests` flag.
6. Load this directory as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
7. At chrome://extensions, click on "Details" for the extension and unselect "Automatically allow access on the following sites".
8. Visit https://example.com/checkout.
9. Click "Allow 1?"
4. Restart Chrome Canary.
5. Load this directory as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
6. At chrome://extensions, click on "Details" for the extension and unselect "Automatically allow access on the following sites".
7. Visit https://example.com/checkout.
8. Click "Allow 1?"

You will see a banner injected on the page to show that the extension has run.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

/**
* Adds a site access request if the user visits https://example.com/checkout.
* Adds a host access request if the user visits https://example.com/checkout.
* This could be useful for an extension that wishes to offer users coupons or
* order tracking but needs access to the site to do so.
*/
Expand All @@ -33,9 +33,9 @@ chrome.tabs.onUpdated.addListener(async (tabId, changes) => {
return;
}

// Add a site access request if the API is available.
if (chrome.permissions.addSiteAccessRequest) {
chrome.permissions.addSiteAccessRequest({ tabId });
// Add a host access request if the API is available.
if (chrome.permissions.addHostAccessRequest) {
chrome.permissions.addHostAccessRequest({ tabId });
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Permissions (Add Site Access Request)",
"description": "Uses the `permissions.addSiteAccessRequest()` API to request access to a site.",
"name": "Permissions (Add Host Access Request)",
"description": "Uses the `permissions.addHostAccessRequest()` API to request access to a site.",
"version": "0.3",
"background": {
"service_worker": "background.js"
Expand Down

0 comments on commit 74e1edf

Please sign in to comment.