From 74e1edfac33279bad08c85445fec029a9cfe80f8 Mon Sep 17 00:00:00 2001 From: Oliver Dunk Date: Tue, 26 Nov 2024 13:29:59 +0000 Subject: [PATCH] Rename addSiteAccessRequest to addHostAccessRequest (#1356) --- .../README.md | 15 +++++++-------- .../background.js | 8 ++++---- .../banner.js | 0 .../manifest.json | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) rename functional-samples/{cookbook.permissions-addsiteaccessrequest => cookbook.permissions-addhostaccessrequest}/README.md (55%) rename functional-samples/{cookbook.permissions-addsiteaccessrequest => cookbook.permissions-addhostaccessrequest}/background.js (86%) rename functional-samples/{cookbook.permissions-addsiteaccessrequest => cookbook.permissions-addhostaccessrequest}/banner.js (100%) rename functional-samples/{cookbook.permissions-addsiteaccessrequest => cookbook.permissions-addhostaccessrequest}/manifest.json (74%) diff --git a/functional-samples/cookbook.permissions-addsiteaccessrequest/README.md b/functional-samples/cookbook.permissions-addhostaccessrequest/README.md similarity index 55% rename from functional-samples/cookbook.permissions-addsiteaccessrequest/README.md rename to functional-samples/cookbook.permissions-addhostaccessrequest/README.md index 9c15c399aa..61253adcfb 100644 --- a/functional-samples/cookbook.permissions-addsiteaccessrequest/README.md +++ b/functional-samples/cookbook.permissions-addhostaccessrequest/README.md @@ -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 @@ -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. diff --git a/functional-samples/cookbook.permissions-addsiteaccessrequest/background.js b/functional-samples/cookbook.permissions-addhostaccessrequest/background.js similarity index 86% rename from functional-samples/cookbook.permissions-addsiteaccessrequest/background.js rename to functional-samples/cookbook.permissions-addhostaccessrequest/background.js index 7f222a878e..f915f50397 100644 --- a/functional-samples/cookbook.permissions-addsiteaccessrequest/background.js +++ b/functional-samples/cookbook.permissions-addhostaccessrequest/background.js @@ -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. */ @@ -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 }); } } }); diff --git a/functional-samples/cookbook.permissions-addsiteaccessrequest/banner.js b/functional-samples/cookbook.permissions-addhostaccessrequest/banner.js similarity index 100% rename from functional-samples/cookbook.permissions-addsiteaccessrequest/banner.js rename to functional-samples/cookbook.permissions-addhostaccessrequest/banner.js diff --git a/functional-samples/cookbook.permissions-addsiteaccessrequest/manifest.json b/functional-samples/cookbook.permissions-addhostaccessrequest/manifest.json similarity index 74% rename from functional-samples/cookbook.permissions-addsiteaccessrequest/manifest.json rename to functional-samples/cookbook.permissions-addhostaccessrequest/manifest.json index 9495542628..136fb620fa 100644 --- a/functional-samples/cookbook.permissions-addsiteaccessrequest/manifest.json +++ b/functional-samples/cookbook.permissions-addhostaccessrequest/manifest.json @@ -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"