| Commit-Queue | +1 |
Adding Rob as a local DevTools reviewer, PTAL!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
We talked about these offline. I'm generally happy with your answers, but I'll post them so you can leave them. Overall lgtm, but I'm no longer a DevTools reviewer!
std::unique_ptr<protocol::Audits::InspectorIssue> BuildHapticsIssue(Your CL description says "Include the JS call site" but I don't see that occurring here?
protocol::Audits::HapticsIssueReasonEnum::PermissionsPolicyBlocked;Nit: is an `-Enum` suffix common on these type names? I don't recall that being a thing.
PlayCallback callback) = 0;I'm trying to grok what the purpose is of the continuation-passing model is here. I was under the impression that the haptics issues were sourced in the event that there was a problem with the parameters passed to the API. If that's the case, you should be able to dispatch the issue without having a continuation by returning a return-value instead (i.e. `virtual HapticsResult PlayHaptics` rather than a continuation).
If that isn't possible I guess a continuation is the only way forward. Just wanted some clarity.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
std::unique_ptr<protocol::Audits::InspectorIssue> BuildHapticsIssue(Your CL description says "Include the JS call site" but I don't see that occurring here?
When we're reporting renderer-side checks, we can easily grab the call site directly, but we'd have to capture and report the call site across the mojom boundary for browser-side checks. I think it also makes less sense for platform level failures to report a javascript call site, but I'm not opposed to either removing the call site reporting all-up or implementing the additional overhead for sending call site info down the pipe.
Will leave this as an open question for DevTools reviewers if it is a design concern.
protocol::Audits::HapticsIssueReasonEnum::PermissionsPolicyBlocked;Nit: is an `-Enum` suffix common on these type names? I don't recall that being a thing.
It's automatically generated when describing the Enum in mojom!
PlayCallback callback) = 0;I'm trying to grok what the purpose is of the continuation-passing model is here. I was under the impression that the haptics issues were sourced in the event that there was a problem with the parameters passed to the API. If that's the case, you should be able to dispatch the issue without having a continuation by returning a return-value instead (i.e. `virtual HapticsResult PlayHaptics` rather than a continuation).
If that isn't possible I guess a continuation is the only way forward. Just wanted some clarity.
Good question, since the Haptics API was a one-way call across mojom, we have no way of reporting errors that happened in the browser side back across the mojom pipe (that Android uses). We've added a new method with a callback for playHaptics which allows us to communicate platform errors that happen across the pipe. If we were only reporting renderer errors (parameters like you said, or permission policy, etc.) then we wouldn't need the callback anymore.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
We're adding DevTools Issues reporting for the Web Haptics feature to prepare for OT. PTAL, thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
From googleclient/chrome/chromium_gwsq/ipc/config.gwsq:
IPC: toyo...@chromium.org
📎 It looks like you’re making a possibly security-sensitive change! 📎 IPC security review isn’t a rubberstamp, so your friendly security reviewer will need a fair amount of context to review your CL effectively. Please review your CL description and code comments to make sure they provide context for someone unfamiliar with your project/area. Pay special attention to where data comes from and which processes it flows between (and their privilege levels). Feel free to point your security reviewer at design docs, bugs, or other links if you can’t reasonably make a self-contained CL description. (Also see https://cbea.ms/git-commit/).
IPC reviewer(s): toyo...@chromium.org
Reviewer source(s):
toyo...@chromium.org is from context(googleclient/chrome/chromium_gwsq/ipc/config.gwsq)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Adding Rob Pitkin for visibility especially around the Android impl
| Code-Review | +1 |
lgtm % nits
using PlayCallback = base::OnceCallback<void(device::mojom::HapticsResult)>;nit: Declaration order, please move the `using` declaration above the destructor.
https://google.github.io/styleguide/cppguide.html#declaration-order
// Collects the waveform ids advertised as supported by the current haptics
// controller for |manager|. Returns an empty vector if none are available.Please document `lookup_failure` in the function-level comment
base::test::TestFuture<mojom::HapticsResult> result;`result` records the result but never tests it, let's add an expectation for `mojom::HapticsResult::kPlatformUnsupported`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
using PlayCallback = base::OnceCallback<void(device::mojom::HapticsResult)>;nit: Declaration order, please move the `using` declaration above the destructor.
https://google.github.io/styleguide/cppguide.html#declaration-order
Done
// Collects the waveform ids advertised as supported by the current haptics
// controller for |manager|. Returns an empty vector if none are available.Please document `lookup_failure` in the function-level comment
Done
`result` records the result but never tests it, let's add an expectation for `mojom::HapticsResult::kPlatformUnsupported`
Added an expectation for the Windows side, but the Android one isn't deterministic.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
PlayCallback callback) {[NIT] (IWYU)
Include `base/functional/callback.h` directly here for `PlayCallback` (the base header only forward-declares it), and likewise include `base/notreached.h` directly where `NOTREACHED()` is added in `AuditsIssue`.
[Basis / Citation]: [Google C++ Style Guide: Include What You Use](https://google.github.io/styleguide/cppguide.html#Include_What_You_Use)
// Sets |lookup_failure| if the controller is unavailable or a lookup fails.
std::vector<uint16_t> GetSupportedWaveforms(Please fix this INFO reported by Chromium Code Review Agent: Use backticks (`` `lookup_failure` ``) instead of legacy pipe delimiters (`|look...
Use backticks (`` `lookup_failure` ``) instead of legacy pipe delimiters (`|lookup_failure|`) when referencing code symbols in new comments.
KB rule: styleguide/cpp/comments/wrap-code-references-in-backticks
Why: Codesearch and code-indexing tools use backtick pairs as a heuristic for finding C++ symbols in comments and generating cross-references, while trailing parentheses on `FooFunction()` disambiguate functions from class names and English words.
ref: f/49aca2bf
auto* manager = InstallDeviceScenario({kHoverId});
manager->set_send_result(E_FAIL);Please fix this INFO reported by Chromium Code Review Agent: `auto* manager = InstallDeviceScenario({kHoverId});` uses `auto` where the deduc...
`auto* manager = InstallDeviceScenario({kHoverId});` uses `auto` where the deduced type (`FakeInputHapticsManager*`) is not obvious from the call expression (compare line 753 in the same file, which spells out `FakeInputHapticsManager*`). Spell out the explicit type here and in the other newly added occurrences:
KB rule: styleguide/cpp/features/auto-only-when-type-is-obvious-or-irrelevant
Why: C++ code is usually clearer when types are explicit, especially when deduction depends on information from distant parts of the code. Readers are not necessarily on your team, so types that feel like clutter to the author and reviewer often give others useful information.
ref: f/0f99534c
blink::mojom::AffectedFrame::New(rfh.GetDevToolsFrameToken().ToString()));[NIT] (IWYU)
Include `base/unguessable_token.h` directly for `GetDevToolsFrameToken().ToString()`, as the `RenderFrameHost` header only forward-declares `base::UnguessableToken`.
[Basis / Citation]: [Google C++ Style Guide: Include What You Use](https://google.github.io/styleguide/cppguide.html#Include_What_You_Use)
if (!base::FeatureList::IsEnabled(blink::features::kWebHaptics) &&[CRITICAL] (Feature Gating & Mojo Remote Lifecycle)
Returning from `HapticsServiceImpl::Create` without binding the receiver (while emitting `kFeatureDisabled` once) leaves Blink's `HeapMojoRemote` with `is_bound() == true` and `is_connected() == false` because `HapticsController` has no disconnect handler. When Blink exposes WebHaptics while `kWebHaptics` is disabled in the browser, an unactivated first call emits both `FeatureDisabled` and a contradictory `UserActivationRequired`, and subsequent activated calls pass the `is_bound()` guard and silently drop IPCs without reporting an issue.
Separately, checking `blink::features::kWebHaptics` via `base::FeatureList` on the browser side rejects `--enable-blink-features=WebHaptics`. Consider either calling `ResetWithReason` on the receiver with a matching disconnect handler in `HapticsController` (or binding the service and reporting `kFeatureDisabled` per `PlayHaptics` call), and confirm whether `--enable-blink-features=WebHaptics` should be honored or gated alongside the `base::Feature`.
[Basis / Citation]: [mojo::Remote::is_bound() vs is_connected()](https://source.chromium.org/chromium/chromium/src/+/main:mojo/public/cpp/bindings/remote.h;l=113-138), [DocumentService::ResetWithReasonAndDeleteThis()](https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/document_service.h;l=148-154), [kEnableBlinkFeatures handling](https://source.chromium.org/chromium/chromium/src/+/main:content/child/runtime_features.cc;l=594-597), [Mojo Style Guide: Privileged Feature Checks](https://chromium.googlesource.com/chromium/src/+/main/docs/security/mojo.md#not-yet-shipped-features-should-be-feature-checked-on-the-privileged-side)
#include "content/public/test/content_browser_test.h"[NIT] (Header Hygiene & IWYU)
After migrating to `DevToolsProtocolTest`, `content/public/test/content_browser_test.h` is unused; please remove it and include `base/unguessable_token.h` directly for the `GetDevToolsFrameToken().ToString()` assertions.
[Basis / Citation]: [Chromium C++ Dos and Don'ts: Minimize Code in Headers](https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-dos-and-donts.md#minimize-code-in-headers), [Google C++ Style Guide: Include What You Use](https://google.github.io/styleguide/cppguide.html#Include_What_You_Use)
base::BindLambdaForTesting([&]() -> std::unique_ptr<HapticsManager> {
auto mock = std::make_unique<MockHapticsManager>();
EXPECT_CALL(*mock, PlayHaptics(testing::_, 0.0, testing::_))
.Times(2)
.WillRepeatedly([](device::mojom::HapticEffect, double,
HapticsManager::PlayCallback callback) {
std::move(callback).Run(device::mojom::HapticsResult::kSubmitted);
});
EXPECT_CALL(*mock, PlayHaptics(testing::_, 0.5, testing::_))
.WillOnce([&](device::mojom::HapticEffect, double,
HapticsManager::PlayCallback callback) {
std::move(callback).Run(device::mojom::HapticsResult::kSubmitted);
submitted.SetValue();
});
return mock;
}));
ASSERT_TRUE(ExecJs(web_contents(), R"(Please fix this WARNING reported by Chromium Code Review Agent: The lambda passed to `HapticsServiceImpl::SetHapticsManagerFactoryForTesting(......
The lambda passed to `HapticsServiceImpl::SetHapticsManagerFactoryForTesting(...)` (line 326) and its nested `WillOnce` lambda (line 335) use default by-reference capture (`[&]`), capturing the stack-local `base::test::TestFuture<void> submitted`. Because `SetHapticsManagerFactoryForTesting` stores the factory in a process-global `base::NoDestructor` singleton that is not cleared until `TearDownOnMainThread()`, and the returned `MockHapticsManager` is owned by `HapticsServiceImpl`, either can outlive `submitted` (for example if an `ASSERT_*` exits the test early or another binding occurs during teardown). Use explicit captures (e.g., `[&submitted]`) and clear the factory before `submitted` goes out of scope.
KB rule: styleguide/cpp/features/lambda-default-ref-capture-only-if-short-lived
Why: Variable capture is a source of dangling-pointer bugs when a lambda escapes the current scope; with a default capture, the lambda's use of a reference to a local, or of `this`, may not be apparent on a cursory inspection.
ref: f/d2c1d644
public int playHaptics(int effect, double intensity) {Sorry, I'm not a specialist on JNI, but if this comment is useful...
----
[NIT] (JNI Boundary Type Safety)
`playHaptics` passes `effect` and returns its result as raw `int`s with manual `static_cast`s on the C++ side. Annotating the return value and `effect` with `@JniType("device::mojom::HapticsResult") @HapticsResult.EnumType int` and `@JniType("device::mojom::HapticEffect") @HapticEffect.EnumType int` lets JNI Zero handle the enum conversions directly.
[Basis / Citation]: [JNI Zero Guide: Automatic Type Conversions using @JniType](https://chromium.googlesource.com/chromium/src/+/main/third_party/jni_zero/README.md#automatic-type-conversions-using-jnitype-jnitype), [PrimitiveConvert for C++ enums](https://source.chromium.org/chromium/chromium/src/+/main:third_party/jni_zero/type_conversions.h;l=85-102)
BindHapticsService(pending_receiver<HapticsBackend> receiver);[NIT] (API Naming Consistency)
Sibling `Bind*` methods on `DeviceService` match their bound Mojom interface 1:1, whereas `BindHapticsService` now binds `pending_receiver<HapticsBackend>`. Renaming `BindHapticsService`, `GetHapticsServiceBinderOverride`, `ScopedHapticsServiceOverrider`, `MockHapticsService`, and `device_haptics_service_` (along with README references) to `*HapticsBackend*` would avoid confusion with the renderer-facing `mojom::HapticsService`.
[Basis / Citation]: [DeviceService::Bind* naming convention](https://source.chromium.org/chromium/chromium/src/+/main:services/device/public/mojom/device_service.mojom;l=39-113), [HapticsService vs HapticsBackend](https://source.chromium.org/chromium/chromium/src/+/main:services/device/public/mojom/haptics.mojom;l=31-52)
enum HapticsResult {[NIT] (Mojo Documentation)
Consider adding brief Mojom comments on the `HapticsResult` enumerators and on `HapticsIssueReason` / `HapticsIssueDetails` to clarify non-obvious semantics—for example, that `kSubmitted` covers Android `0.0` no-ops and Windows fallback acceptance, and which `HapticsIssueReason` values originate in Blink versus the browser.
[Basis / Citation]: [Mojo Style Guide: Documentation](https://chromium.googlesource.com/chromium/src/+/main/docs/security/mojo.md#documentation)
static void ReportHapticsIssue(LocalDOMWindow* window,[SUGGESTION] (Inputs & Outputs)
`AuditsIssue::ReportHapticsIssue` unconditionally dereferences `window` and callers already ensure it is non-null. Change the parameter from `LocalDOMWindow*` to `LocalDOMWindow&` to make the non-null contract explicit at the API boundary.
[Basis / Citation]: [Google C++ Style Guide: Inputs and Outputs](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs)
void AuditsIssue::ReportHapticsIssue(LocalDOMWindow* window,
mojom::blink::HapticsIssueReason reason) {
String protocol_reason;Please fix this INFO reported by Chromium Code Review Agent: `AuditsIssue::ReportHapticsIssue` is declared `static` in `inspector_audits_issu...
`AuditsIssue::ReportHapticsIssue` is declared `static` in `inspector_audits_issue.h`; precede its out-of-line definition with a standalone `// static` comment.
KB rule: blink/general/add-static-comment-above-static-method-definitions-in-cc
Why: In C++, the 'static' storage class specifier is permitted only on declarations inside class bodies in header files, not on out-of-line member function definitions. Adding a standalone '// static' comment immediately above the implementation definition makes the static scope immediately obvious to readers and reviewers without cross-referencing the header. Keeping documentation comments in the header provides a single source of truth for callers and prevents doc comments from drifting out of sync.
ref: f/cdf89dc3
HapticsController::HapticsController(Navigator& navigator)[CRITICAL] (Window Reuse State Drift & Silent Issue Suppression)
`HapticsController` caches `blocked_reason_` and binds `haptics_service_` once at construction as a `Supplement<Navigator>`. However, `LocalDOMWindow::ClearForReuse()` preserves `navigator_` across same-origin window reuse (such as initial `about:blank` transitioning to a committed document), even though the new document applies a new `PermissionsPolicy` and the browser replaces `DocumentAssociatedData`.
After window reuse, `HapticsController` can rely on a stale `blocked_reason_` or send over a disconnected pipe whose `is_bound()` remains `true`, silently dropping calls without reporting `PermissionsPolicyBlocked`. Re-evaluate fenced-frame and permissions-policy eligibility per `PlayHaptics()` call (or reset/rebind controller state when the window's `Document` changes).
[Basis / Citation]: [LocalDOMWindow::ClearForReuse()](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_dom_window.cc;l=272-289), [LocalDOMWindow::navigator_ lifetime](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_dom_window.h;l=685), [mojo::Remote::is_bound() vs is_connected()](https://source.chromium.org/chromium/chromium/src/+/main:mojo/public/cpp/bindings/remote.h;l=113-138)