diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index c934437cd9010..b311fc382a111 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp @@ -1971,8 +1971,13 @@ Review - - Permissions removed from unused websites + + {NUM_SITES, plural, + =1 {Permissions removed from <b>1 site</b> you haven’t visited recently} + other {Permissions removed from <b>{NUM_SITES} sites</b> you haven’t visited recently}} + + + Review removed permissions Updates diff --git a/chrome/app/settings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_ARIA_LABEL.png.sha1 b/chrome/app/settings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_ARIA_LABEL.png.sha1 new file mode 100644 index 0000000000000..c6b41cb0a5470 --- /dev/null +++ b/chrome/app/settings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_ARIA_LABEL.png.sha1 @@ -0,0 +1 @@ +8d46e15dd9578988605e27e49c7481c274168f20 \ No newline at end of file diff --git a/chrome/app/settings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_LABEL.png.sha1 b/chrome/app/settings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_LABEL.png.sha1 new file mode 100644 index 0000000000000..d0084ef9736c4 --- /dev/null +++ b/chrome/app/settings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_LABEL.png.sha1 @@ -0,0 +1 @@ +ff1115bd8a8745b081d74fc1b30216d8f6eabffb \ No newline at end of file diff --git a/chrome/browser/resources/settings/BUILD.gn b/chrome/browser/resources/settings/BUILD.gn index dfc272f98a84b..470518c55aea5 100644 --- a/chrome/browser/resources/settings/BUILD.gn +++ b/chrome/browser/resources/settings/BUILD.gn @@ -362,6 +362,7 @@ build_webui("build") { "settings_routes.ts", "site_settings/constants.ts", "site_settings/site_settings_mixin.ts", + "site_settings/site_settings_permissions_browser_proxy.ts", "site_settings/site_settings_prefs_browser_proxy.ts", "site_settings/website_usage_browser_proxy.ts", ] diff --git a/chrome/browser/resources/settings/lazy_load.ts b/chrome/browser/resources/settings/lazy_load.ts index f21120dc1a94b..61a6064a30997 100644 --- a/chrome/browser/resources/settings/lazy_load.ts +++ b/chrome/browser/resources/settings/lazy_load.ts @@ -201,6 +201,7 @@ export {SiteDetailsPermissionElement} from './site_settings/site_details_permiss export {SiteEntryElement} from './site_settings/site_entry.js'; export {SiteListElement} from './site_settings/site_list.js'; export {SiteListEntryElement} from './site_settings/site_list_entry.js'; +export {SiteSettingsPermissionsBrowserProxy, SiteSettingsPermissionsBrowserProxyImpl, UnusedSitePermissions} from './site_settings/site_settings_permissions_browser_proxy.js'; export {ChooserException, ContentSettingProvider, CookiePrimarySetting, DefaultContentSetting, NotificationPermission, OriginInfo, RawChooserException, RawSiteException, RecentSitePermissions, SiteException, SiteGroup, SiteSettingsPrefsBrowserProxy, SiteSettingsPrefsBrowserProxyImpl, ZoomLevelEntry} from './site_settings/site_settings_prefs_browser_proxy.js'; export {WebsiteUsageBrowserProxy, WebsiteUsageBrowserProxyImpl} from './site_settings/website_usage_browser_proxy.js'; export {ZoomLevelsElement} from './site_settings/zoom_levels.js'; diff --git a/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.html b/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.html index 8fcec5f7cd6ea..0f673b7ddb8f0 100644 --- a/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.html +++ b/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.html @@ -2,9 +2,9 @@ diff --git a/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.ts b/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.ts index 50c0dce7f87bf..1a6f0dc4ab0c4 100644 --- a/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.ts +++ b/chrome/browser/resources/settings/safety_check_page/safety_check_unused_site_permissions.ts @@ -9,15 +9,20 @@ * some granted permissions. */ +// clang-format off import './safety_check_child.js'; +import {WebUiListenerMixin} from 'chrome://resources/cr_elements/web_ui_listener_mixin.js'; +import {PluralStringProxyImpl} from 'chrome://resources/js/plural_string_proxy.js'; import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {routes} from '../route.js'; import {Router} from '../router.js'; +import {UnusedSitePermissions, SiteSettingsPermissionsBrowserProxy, SiteSettingsPermissionsBrowserProxyImpl} from '../site_settings/site_settings_permissions_browser_proxy.js'; import {SafetyCheckIconStatus, SettingsSafetyCheckChildElement} from './safety_check_child.js'; import {getTemplate} from './safety_check_unused_site_permissions.html.js'; +// clang-format on export interface SettingsSafetyCheckUnusedSitePermissionsElement { $: { @@ -25,8 +30,11 @@ export interface SettingsSafetyCheckUnusedSitePermissionsElement { }; } +const SettingsSafetyCheckUnusedSitePermissionsElementBase = + WebUiListenerMixin(PolymerElement); + export class SettingsSafetyCheckUnusedSitePermissionsElement extends - PolymerElement { + SettingsSafetyCheckUnusedSitePermissionsElementBase { static get is() { return 'settings-safety-check-unused-site-permissions'; } @@ -43,11 +51,37 @@ export class SettingsSafetyCheckUnusedSitePermissionsElement extends return SafetyCheckIconStatus.UNUSED_SITE_PERMISSIONS; }, }, + + headerString_: String, }; } + private headerString_: string; private iconStatus_: SafetyCheckIconStatus; + private browserProxy_: SiteSettingsPermissionsBrowserProxy = + SiteSettingsPermissionsBrowserProxyImpl.getInstance(); + + override connectedCallback() { + super.connectedCallback(); + + // Register for review notification permission list updates. + this.addWebUIListener( + 'unused-permission-review-list-maybe-changed', + (sites: UnusedSitePermissions[]) => { + this.onSitesChanged_(sites); + }); + + this.browserProxy_.getRevokedUnusedSitePermissionsList().then( + this.onSitesChanged_.bind(this)); + } + + private async onSitesChanged_(sites: UnusedSitePermissions[]) { + this.headerString_ = + await PluralStringProxyImpl.getInstance().getPluralString( + 'safetyCheckUnusedSitePermissionsHeaderLabel', sites.length); + } + private onButtonClick_() { Router.getInstance().navigateTo( routes.SITE_SETTINGS, /* dynamicParams= */ undefined, diff --git a/chrome/browser/resources/settings/site_settings/OWNERS b/chrome/browser/resources/settings/site_settings/OWNERS index f198990353974..a7992bb08c137 100644 --- a/chrome/browser/resources/settings/site_settings/OWNERS +++ b/chrome/browser/resources/settings/site_settings/OWNERS @@ -1,3 +1,4 @@ sauski@google.com -per-file review_notification_permissions.*=rainhard@chromium.org \ No newline at end of file +per-file review_notification_permissions.*=rainhard@chromium.org +per-file site_settings_permissions_browser_proxy.ts=rainhard@chromium.org \ No newline at end of file diff --git a/chrome/browser/resources/settings/site_settings/site_settings_permissions_browser_proxy.ts b/chrome/browser/resources/settings/site_settings/site_settings_permissions_browser_proxy.ts new file mode 100644 index 0000000000000..fc366bb340bad --- /dev/null +++ b/chrome/browser/resources/settings/site_settings/site_settings_permissions_browser_proxy.ts @@ -0,0 +1,46 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * @fileoverview A helper object used by the "Site Settings" to interact with + * the permission-related updates of the browser. + */ + +// clang-format off +import {sendWithPromise} from 'chrome://resources/js/cr.js'; +// clang-format on + +export interface UnusedSitePermissions { + origin: string; + permissions: string[]; +} + +/** + * TODO(crbug.com/1383197): Move functions related to notification permission + * review here as well. + */ +export interface SiteSettingsPermissionsBrowserProxy { + /** + * Gets the unused origins along with the permissions they have been granted. + */ + getRevokedUnusedSitePermissionsList(): Promise; +} + +export class SiteSettingsPermissionsBrowserProxyImpl implements + SiteSettingsPermissionsBrowserProxy { + getRevokedUnusedSitePermissionsList() { + return sendWithPromise('getRevokedUnusedSitePermissionsList'); + } + + static getInstance(): SiteSettingsPermissionsBrowserProxy { + return instance || + (instance = new SiteSettingsPermissionsBrowserProxyImpl()); + } + + static setInstance(obj: SiteSettingsPermissionsBrowserProxy) { + instance = obj; + } +} + +let instance: SiteSettingsPermissionsBrowserProxy|null = null; diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 008a37bcb617d..c443932c85cd5 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn @@ -1684,6 +1684,8 @@ static_library("ui") { "webui/settings/site_settings_handler.h", "webui/settings/site_settings_helper.cc", "webui/settings/site_settings_helper.h", + "webui/settings/site_settings_permissions_handler.cc", + "webui/settings/site_settings_permissions_handler.h", "webui/side_panel/bookmarks/bookmarks_page_handler.cc", "webui/side_panel/bookmarks/bookmarks_page_handler.h", "webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc", diff --git a/chrome/browser/ui/webui/settings/OWNERS b/chrome/browser/ui/webui/settings/OWNERS index 7db49e89bcd52..23ae354936bd4 100644 --- a/chrome/browser/ui/webui/settings/OWNERS +++ b/chrome/browser/ui/webui/settings/OWNERS @@ -7,6 +7,7 @@ per-file hats_handler*=sauski@google.com per-file privacy_sandbox_handler*=file://components/privacy_sandbox/OWNERS per-file *site_settings*=msramek@chromium.org per-file *site_settings*=sauski@google.com +per-file site_settings_permissions_handler*=rainhard@chromium.org per-file safe_browsing_handler*=msramek@chromium.org per-file safe_browsing_handler*=sauski@google.com per-file safety_check_handler*=andzaytsev@google.com,rainhard@chromium.org diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index d7f3c78a6f311..0edb7b21c07ee 100644 --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -1992,8 +1992,6 @@ void AddSafetyCheckStrings(content::WebUIDataSource* html_source) { {"safetyCheckIconWarningAriaLabel", IDS_SETTINGS_SAFETY_CHECK_ICON_WARNING_ARIA_LABEL}, {"safetyCheckReview", IDS_SETTINGS_SAFETY_CHECK_REVIEW}, - {"safetyCheckUnusedSitePermissionsPrimaryLabel", - IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_PRIMARY_LABEL}, {"safetyCheckUpdatesPrimaryLabel", IDS_SETTINGS_SAFETY_CHECK_UPDATES_PRIMARY_LABEL}, {"safetyCheckUpdatesButtonAriaLabel", IDS_UPDATE_RECOMMENDED_DIALOG_TITLE}, @@ -2035,6 +2033,8 @@ void AddSafetyCheckStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_SAFETY_CHECK_NOTIFICATION_PERMISSION_REVIEW_DONE_LABEL}, {"safetyCheckNotificationPermissionReviewBlockAllLabel", IDS_SETTINGS_SAFETY_CHECK_NOTIFICATION_PERMISSION_REVIEW_BLOCK_ALL_LABEL}, + {"safetyCheckUnusedSitePermissionsHeaderAriaLabel", + IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_ARIA_LABEL}, #if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) {"safetyCheckChromeCleanerPrimaryLabel", IDS_SETTINGS_SAFETY_CHECK_CHROME_CLEANER_PRIMARY_LABEL}, diff --git a/chrome/browser/ui/webui/settings/settings_ui.cc b/chrome/browser/ui/webui/settings/settings_ui.cc index 033369031cb3f..3570e832de811 100644 --- a/chrome/browser/ui/webui/settings/settings_ui.cc +++ b/chrome/browser/ui/webui/settings/settings_ui.cc @@ -61,6 +61,7 @@ #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" #include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h" #include "chrome/browser/ui/webui/settings/site_settings_handler.h" +#include "chrome/browser/ui/webui/settings/site_settings_permissions_handler.h" #include "chrome/browser/ui/webui/webui_util.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" @@ -207,6 +208,7 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) AddSettingsPageUIHandler( std::make_unique(web_ui, profile)); AddSettingsPageUIHandler(std::make_unique()); + AddSettingsPageUIHandler(std::make_unique()); AddSettingsPageUIHandler(std::make_unique(profile)); AddSettingsPageUIHandler(std::make_unique()); AddSettingsPageUIHandler(std::make_unique(profile)); @@ -401,6 +403,9 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) plural_string_handler->AddLocalizedString( "safetyCheckNotificationPermissionReviewPrimaryLabel", IDS_SETTINGS_SAFETY_CHECK_REVIEW_NOTIFICATION_PERMISSIONS_PRIMARY_LABEL); + plural_string_handler->AddLocalizedString( + "safetyCheckUnusedSitePermissionsHeaderLabel", + IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_LABEL); web_ui->AddMessageHandler(std::move(plural_string_handler)); // Add the metrics handler to write uma stats. diff --git a/chrome/browser/ui/webui/settings/site_settings_permissions_handler.cc b/chrome/browser/ui/webui/settings/site_settings_permissions_handler.cc new file mode 100644 index 0000000000000..106e45eb488ff --- /dev/null +++ b/chrome/browser/ui/webui/settings/site_settings_permissions_handler.cc @@ -0,0 +1,35 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/settings/site_settings_permissions_handler.h" + +SiteSettingsPermissionsHandler::SiteSettingsPermissionsHandler() = default; +SiteSettingsPermissionsHandler::~SiteSettingsPermissionsHandler() = default; + +void SiteSettingsPermissionsHandler::HandleGetRevokedUnusedSitePermissionsList( + const base::Value::List& args) { + AllowJavascript(); + + CHECK_EQ(1U, args.size()); + const base::Value& callback_id = args[0]; + + // TODO(crbug.com/1345920): Replace with content from Unused Site Permissions + // service. + base::Value::List result; + ResolveJavascriptCallback(callback_id, base::Value(std::move(result))); +} + +void SiteSettingsPermissionsHandler::RegisterMessages() { + // Usage of base::Unretained(this) is safe, because web_ui() owns `this` and + // won't release ownership until destruction. + web_ui()->RegisterMessageCallback( + "getRevokedUnusedSitePermissionsList", + base::BindRepeating(&SiteSettingsPermissionsHandler:: + HandleGetRevokedUnusedSitePermissionsList, + base::Unretained(this))); +} + +void SiteSettingsPermissionsHandler::OnJavascriptAllowed() {} + +void SiteSettingsPermissionsHandler::OnJavascriptDisallowed() {} diff --git a/chrome/browser/ui/webui/settings/site_settings_permissions_handler.h b/chrome/browser/ui/webui/settings/site_settings_permissions_handler.h new file mode 100644 index 0000000000000..3d552690645bc --- /dev/null +++ b/chrome/browser/ui/webui/settings/site_settings_permissions_handler.h @@ -0,0 +1,34 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_PERMISSIONS_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_PERMISSIONS_HANDLER_H_ + +#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" + +/** + * This handler deals with the permission-related operations on the site + * settings page. + */ + +class SiteSettingsPermissionsHandler : public settings::SettingsPageUIHandler { + public: + SiteSettingsPermissionsHandler(); + + ~SiteSettingsPermissionsHandler() override; + + private: + // SettingsPageUIHandler implementation. + void OnJavascriptAllowed() override; + void OnJavascriptDisallowed() override; + + // WebUIMessageHandler implementation. + void RegisterMessages() override; + + // Returns the list of origins that haven't been visited recently with + // associated permissions. + void HandleGetRevokedUnusedSitePermissionsList(const base::Value::List& args); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_PERMISSIONS_HANDLER_H_ diff --git a/chrome/test/data/webui/settings/BUILD.gn b/chrome/test/data/webui/settings/BUILD.gn index f3510a349efe6..b3eb913730ef8 100644 --- a/chrome/test/data/webui/settings/BUILD.gn +++ b/chrome/test/data/webui/settings/BUILD.gn @@ -141,6 +141,7 @@ non_preprocessed_files = [ "test_profile_info_browser_proxy.ts", "test_reset_browser_proxy.ts", "test_search_engines_browser_proxy.ts", + "test_site_settings_permissions_browser_proxy.ts", "test_site_settings_prefs_browser_proxy.ts", "test_util.ts", "trusted_html.ts", diff --git a/chrome/test/data/webui/settings/OWNERS b/chrome/test/data/webui/settings/OWNERS index 248e91f8da7c4..a9ce3f6e716a5 100644 --- a/chrome/test/data/webui/settings/OWNERS +++ b/chrome/test/data/webui/settings/OWNERS @@ -24,4 +24,5 @@ per-file site_list_entry_tests.ts=sauski@google.com per-file site_list_tests.ts=sauski@google.com per-file site_settings_page_test.ts=sauski@google.com per-file test_privacy_page_browser_proxy.ts=sauski@google.com +per-file test_site_settings_permissions_browser_proxy.ts=rainhard@chromium.org,sauski@google.com per-file test_site_settings_prefs_browser_proxy.ts=sauski@google.com diff --git a/chrome/test/data/webui/settings/safety_check_permissions_test.ts b/chrome/test/data/webui/settings/safety_check_permissions_test.ts index 06d8dbe693680..9f498f727202f 100644 --- a/chrome/test/data/webui/settings/safety_check_permissions_test.ts +++ b/chrome/test/data/webui/settings/safety_check_permissions_test.ts @@ -3,39 +3,73 @@ // found in the LICENSE file. // clang-format off +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {Router, routes, SafetyCheckIconStatus, SettingsSafetyCheckNotificationPermissionsElement, SettingsSafetyCheckUnusedSitePermissionsElement} from 'chrome://settings/settings.js'; import {assertEquals} from 'chrome://webui-test/chai_assert.js'; -import {NotificationPermission, SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; +import {NotificationPermission, UnusedSitePermissions, SiteSettingsPermissionsBrowserProxyImpl, SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js'; import {PluralStringProxyImpl} from 'chrome://resources/js/plural_string_proxy.js'; import {assertSafetyCheckChild} from './safety_check_test_utils.js'; +import {TestSiteSettingsPermissionsBrowserProxy} from './test_site_settings_permissions_browser_proxy.js'; import {TestSiteSettingsPrefsBrowserProxy} from './test_site_settings_prefs_browser_proxy.js'; // clang-format on suite('SafetyCheckUnusedSitePermissionsUiTests', function() { let page: SettingsSafetyCheckUnusedSitePermissionsElement; + let browserProxy: TestSiteSettingsPermissionsBrowserProxy; + + const origin1 = 'www.example1.com'; + const origin2 = 'www.example2.com'; setup(function() { + browserProxy = new TestSiteSettingsPermissionsBrowserProxy(); + SiteSettingsPermissionsBrowserProxyImpl.setInstance(browserProxy); + document.body.innerHTML = window.trustedTypes!.emptyHTML; + }); + + function createPage(data: UnusedSitePermissions[]) { + browserProxy.setUnusedSitePermissions(data); + page = document.createElement('settings-safety-check-unused-site-permissions'); document.body.appendChild(page); flush(); - }); + } teardown(function() { page.remove(); }); - test('unusedSitesPermissionsReviewUiTest', function() { + test('unusedSitesPermissionsReviewUiTest', async function() { + const mockData = [ + { + origin: origin1, + permissions: ['location', 'camera'], + }, + { + origin: origin2, + permissions: ['popups', 'sensors'], + }, + ]; + createPage(mockData); + + await browserProxy.whenCalled('getRevokedUnusedSitePermissionsList'); + flush(); + + const headerLabel = + await PluralStringProxyImpl.getInstance().getPluralString( + 'safetyCheckUnusedSitePermissionsHeaderLabel', mockData.length); + // Ensure the elements are correct. assertSafetyCheckChild({ page: page, iconStatus: SafetyCheckIconStatus.UNUSED_SITE_PERMISSIONS, - label: 'Permissions removed from unused websites', - buttonLabel: 'Review', - buttonAriaLabel: 'Review', + label: headerLabel, + buttonLabel: loadTimeData.getString('safetyCheckReview'), + buttonAriaLabel: loadTimeData.getString( + 'safetyCheckUnusedSitePermissionsHeaderAriaLabel'), }); // User clicks review button. diff --git a/chrome/test/data/webui/settings/test_site_settings_permissions_browser_proxy.ts b/chrome/test/data/webui/settings/test_site_settings_permissions_browser_proxy.ts new file mode 100644 index 0000000000000..72f92c4867e11 --- /dev/null +++ b/chrome/test/data/webui/settings/test_site_settings_permissions_browser_proxy.ts @@ -0,0 +1,33 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// clang-format off +import {UnusedSitePermissions, SiteSettingsPermissionsBrowserProxy} from 'chrome://settings/lazy_load.js'; +import {TestBrowserProxy} from 'chrome://webui-test/test_browser_proxy.js'; +// clang-format on + +/** + * A test version of SiteSettingsPermissionsBrowserProxy. Provides helper + * methods for allowing tests to know when a method was called, as well as + * specifying mock responses. + */ +export class TestSiteSettingsPermissionsBrowserProxy extends TestBrowserProxy + implements SiteSettingsPermissionsBrowserProxy { + private unusedSitePermissions_: UnusedSitePermissions[] = []; + + constructor() { + super([ + 'getRevokedUnusedSitePermissionsList', + ]); + } + + setUnusedSitePermissions(unusedSitePermissionsList: UnusedSitePermissions[]) { + this.unusedSitePermissions_ = unusedSitePermissionsList; + } + + getRevokedUnusedSitePermissionsList(): Promise { + this.methodCalled('getRevokedUnusedSitePermissionsList'); + return Promise.resolve(this.unusedSitePermissions_.slice()); + } +}