Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SafetyCheck] Add backend connection for unused site permissions
This CL adds the connection between the web UI and the site settings permissions handler. For this, it adds a new browser proxy and handler. The handler currently returns mock data for testing purposes. Screenshot: https://bugs.chromium.org/p/chromium/issues/detail?id=1345920#c89 Bug: 1345920 Change-Id: I5483d2ebe4d4a754df3568e07db2c8ab7a71bb17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4008498 Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org> Reviewed-by: Side YILMAZ <sideyilmaz@chromium.org> Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com> Commit-Queue: Tom Van Goethem <tov@chromium.org> Cr-Commit-Position: refs/heads/main@{#1075118}
- Loading branch information
1 parent
0599248
commit 1670e28
Showing
19 changed files
with
250 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_ARIA_LABEL.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8d46e15dd9578988605e27e49c7481c274168f20 |
1 change: 1 addition & 0 deletions
1
...ings_strings_grdp/IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_HEADER_LABEL.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ff1115bd8a8745b081d74fc1b30216d8f6eabffb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
sauski@google.com | ||
|
||
per-file review_notification_permissions.*=rainhard@chromium.org | ||
per-file review_notification_permissions.*=rainhard@chromium.org | ||
per-file site_settings_permissions_browser_proxy.ts=rainhard@chromium.org |
46 changes: 46 additions & 0 deletions
46
chrome/browser/resources/settings/site_settings/site_settings_permissions_browser_proxy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<UnusedSitePermissions[]>; | ||
} | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
chrome/browser/ui/webui/settings/site_settings_permissions_handler.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
34 changes: 34 additions & 0 deletions
34
chrome/browser/ui/webui/settings/site_settings_permissions_handler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.