-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shared storage] implement permissions policy
Add the "shared-storage" permissions policy that disallows all Shared Storage methods. https://github.com/WICG/shared-storage/blob/main/README.md#permissions-policy Due to this change, Shared Storage won't be allowed in Fenced Frames as Fenced Frames disallow all permissions policies. This decision may change in the future: WICG/fenced-frame#44 Bug: 1337454 Change-Id: I856d31933032355409585bc376f2b6826f667270 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3710841 Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Ian Clelland <[email protected]> Commit-Queue: Yao Xiao <[email protected]> Reviewed-by: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1023892}
- Loading branch information
1 parent
8130feb
commit 5187275
Showing
20 changed files
with
328 additions
and
43 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
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/modules/shared_storage/util.h" | ||
|
||
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink.h" | ||
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" | ||
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h" | ||
#include "third_party/blink/renderer/core/execution_context/execution_context.h" | ||
#include "third_party/blink/renderer/platform/bindings/exception_state.h" | ||
#include "third_party/blink/renderer/platform/bindings/script_state.h" | ||
|
||
namespace blink { | ||
|
||
bool CheckBrowsingContextIsValid(ScriptState& script_state, | ||
ExceptionState& exception_state) { | ||
if (!script_state.ContextIsValid()) { | ||
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidAccessError, | ||
"A browsing context is required."); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool CheckSharedStoragePermissionsPolicy(ScriptState& script_state, | ||
ExecutionContext& execution_context, | ||
ScriptPromiseResolver& resolver) { | ||
if (!execution_context.IsFeatureEnabled( | ||
mojom::blink::PermissionsPolicyFeature::kSharedStorage)) { | ||
resolver.Reject(V8ThrowDOMException::CreateOrEmpty( | ||
script_state.GetIsolate(), DOMExceptionCode::kInvalidAccessError, | ||
"The \"shared-storage\" Permissions Policy denied the method on " | ||
"window.sharedStorage.")); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} // namespace blink |
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,28 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SHARED_STORAGE_UTIL_H_ | ||
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SHARED_STORAGE_UTIL_H_ | ||
|
||
namespace blink { | ||
|
||
class ExecutionContext; | ||
class ExceptionState; | ||
class ScriptState; | ||
class ScriptPromiseResolver; | ||
|
||
// Return if there is a valid browsing context associated with `script_state`. | ||
// Throw an error via `exception_state` if invalid. | ||
bool CheckBrowsingContextIsValid(ScriptState& script_state, | ||
ExceptionState& exception_state); | ||
|
||
// Return if the shared-storage permissions policy is allowed in | ||
// `execution_context`. Reject the `resolver` with an error if disallowed. | ||
bool CheckSharedStoragePermissionsPolicy(ScriptState& script_state, | ||
ExecutionContext& execution_context, | ||
ScriptPromiseResolver& resolver); | ||
|
||
} // namespace blink | ||
|
||
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SHARED_STORAGE_UTIL_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.