Commit bb04e07b authored by Jiewei Qian's avatar Jiewei Qian Committed by Commit Bot

sample-system-web-app: register common permissions for the chrome-untrusted part

Chromium browser grants some permissions to all websites by default.
Most WebUIs will expect to have these permissions. However, users can
block them if they are not registered with WebUIAllowlist for
chrome-untrusted:// pages.

This CL registers these permission to the chrome-untrusted:// part of
sample system web app, as a reference for future chrome-untrusted://
WebUI implementations.

Bug: 1101060
Change-Id: I66e84519ea4d8fc2b3cf759e8f147ad1111c752d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2342490
Commit-Queue: Jiewei Qian  <qjw@chromium.org>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Auto-Submit: Jiewei Qian  <qjw@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795817}
parent 1d08e8ad
......@@ -14,6 +14,7 @@
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/url_constants.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/webui/webui_allowlist.h"
namespace chromeos {
namespace {
......@@ -64,6 +65,22 @@ SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui)
// Add ability to request chrome-untrusted: URLs
web_ui->AddRequestableScheme(content::kChromeUIUntrustedScheme);
// Register common permissions for chrome-untrusted:// pages.
// TODO(https://crbug.com/1113568): Remove this after common permissions are
// granted by default.
auto* webui_allowlist = WebUIAllowlist::GetOrCreate(browser_context);
const url::Origin untrusted_sample_system_web_app_origin =
url::Origin::Create(GURL(kChromeUIUntrustedSampleSystemWebAppURL));
for (const auto& permission : {
ContentSettingsType::COOKIES,
ContentSettingsType::JAVASCRIPT,
ContentSettingsType::IMAGES,
ContentSettingsType::SOUND,
}) {
webui_allowlist->RegisterAutoGrantedPermission(
untrusted_sample_system_web_app_origin, permission);
}
}
SampleSystemWebAppUI::~SampleSystemWebAppUI() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment