Commit bbc91166 authored by Abigail Klein's avatar Abigail Klein Committed by Commit Bot

[chrome:accessibility] Only allow event recording on one page at a time.

Prevent a user from clicking Start recording on multiple pages at the same
time by disabling all Start recording buttons when one has been pressed.
This prevents a crash which would occur when a user would click
Start recording on multiple pages without stopping the recording.

Bug: 1036755, 785493
Change-Id: I58cdd9be1595dac679f4bfa488599bc198863c18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1997946
Commit-Queue: Abigail Klein <abigailbklein@google.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731782}
parent 7bbfdf1e
......@@ -660,6 +660,9 @@ void AccessibilityUIMessageHandler::RequestAccessibilityEvents(
content::WebContents* web_contents =
content::WebContents::FromRenderViewHost(rvh);
if (start) {
if (observer_) {
return;
}
web_contents->RecordAccessibilityEvents(
base::BindRepeating(&AccessibilityUIMessageHandler::Callback,
base::Unretained(this)),
......
......@@ -106,13 +106,25 @@ cr.define('accessibility', function() {
element.textContent = 'Stop recording';
element.setAttribute('aria-expanded', 'true');
// TODO Hide all other start recording elements. UI should reflect the
// fact that there can only be one accessibility recorder at once.
// Disable all other start recording buttons. UI reflects the fact that
// there can only be one accessibility recorder at once.
const buttons = document.getElementsByClassName('recordEventsButton');
for (const button of buttons) {
if (button != element) {
button.disabled = true;
}
}
} else {
element.textContent = 'Start recording';
element.setAttribute('aria-expanded', 'false');
// TODO Show all start recording elements.
// Enable all start recording buttons.
const buttons = document.getElementsByClassName('recordEventsButton');
for (const button of buttons) {
if (button != element) {
button.disabled = false;
}
}
}
chrome.send('requestAccessibilityEvents', [
{'processId': data.processId, 'routingId': data.routingId, 'start': start}
......@@ -368,6 +380,7 @@ cr.define('accessibility', function() {
function createStartStopAccessibilityEventRecordingElement(data, id) {
const show = document.createElement('button');
show.classList.add('recordEventsButton');
show.textContent = 'Start recording';
show.id = id + ':startOrStopEvents';
show.setAttribute('aria-expanded', 'false');
......
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