Notify user when recording is aborted due to audio capture disabled.
Bug: b/249355530 Change-Id: I582edd1393dd512edaac0f02d51210e359945154 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3923874 Reviewed-by: Yilkal Abe <yilkal@chromium.org> Commit-Queue: Li Lin <llin@chromium.org> Cr-Commit-Position: refs/heads/main@{#1053298}
This commit is contained in:
ash
ash_strings.grd
ash_strings_grd
IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TEXT.png.sha1IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TITLE.png.sha1
projector
tools/metrics/histograms
@ -4578,6 +4578,14 @@ Here are some things you can try to get started.
|
|||||||
Something went wrong. Try again.
|
Something went wrong. Try again.
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message name="IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TITLE" desc="The title of the notification when Projector session is aborted due to audio capture policy disabled.">
|
||||||
|
Can’t create screencast
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TEXT" desc="The text of the notification when Projector session is aborted due to audio capture policy disabled.">
|
||||||
|
Your administrator doesn’t allow audio capture. Contact your administrator for more info.
|
||||||
|
</message>
|
||||||
|
|
||||||
<message name="IDS_ASH_PROJECTOR_FAILURE_MESSAGE_TRANSCRIPTION" desc="The test of the notification when Projector transcription fails.">
|
<message name="IDS_ASH_PROJECTOR_FAILURE_MESSAGE_TRANSCRIPTION" desc="The test of the notification when Projector transcription fails.">
|
||||||
Can't generate transcript
|
Can't generate transcript
|
||||||
</message>
|
</message>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
e811052fa24990f59da11466316e643b118e2da6
|
@ -0,0 +1 @@
|
|||||||
|
e811052fa24990f59da11466316e643b118e2da6
|
@ -374,6 +374,13 @@ void ProjectorControllerImpl::OnRecordingStartAborted() {
|
|||||||
|
|
||||||
projector_session_->Stop();
|
projector_session_->Stop();
|
||||||
|
|
||||||
|
auto* capture_mode_controller = CaptureModeController::Get();
|
||||||
|
if (capture_mode_controller->IsAudioCaptureDisabledByPolicy()) {
|
||||||
|
ui_controller_->ShowFailureNotification(
|
||||||
|
IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TEXT,
|
||||||
|
IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
if (client_)
|
if (client_)
|
||||||
client_->OpenProjectorApp();
|
client_->OpenProjectorApp();
|
||||||
|
|
||||||
|
@ -78,6 +78,9 @@ void RecordCreationFlowError(int message_id) {
|
|||||||
case IDS_ASH_PROJECTOR_FAILURE_MESSAGE_TRANSCRIPTION:
|
case IDS_ASH_PROJECTOR_FAILURE_MESSAGE_TRANSCRIPTION:
|
||||||
error = ProjectorCreationFlowError::kTranscriptionError;
|
error = ProjectorCreationFlowError::kTranscriptionError;
|
||||||
break;
|
break;
|
||||||
|
case IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TEXT:
|
||||||
|
error = ProjectorCreationFlowError::kSessionAbortedByAudioPolicyDisabled;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
break;
|
break;
|
||||||
|
@ -87,10 +87,11 @@ enum class ProjectorCreationFlow {
|
|||||||
enum class ProjectorCreationFlowError {
|
enum class ProjectorCreationFlowError {
|
||||||
kSaveError = 0,
|
kSaveError = 0,
|
||||||
kTranscriptionError = 1,
|
kTranscriptionError = 1,
|
||||||
|
kSessionAbortedByAudioPolicyDisabled = 2,
|
||||||
// Add future entries above this comment, in sync with
|
// Add future entries above this comment, in sync with
|
||||||
// "ProjectorCreationFlowError" in src/tools/metrics/histograms/enums.xml.
|
// "ProjectorCreationFlowError" in src/tools/metrics/histograms/enums.xml.
|
||||||
// Update kMaxValue to the last value.
|
// Update kMaxValue to the last value.
|
||||||
kMaxValue = kTranscriptionError
|
kMaxValue = kSessionAbortedByAudioPolicyDisabled
|
||||||
};
|
};
|
||||||
|
|
||||||
// These enum values represent potential error that occurs at policy value
|
// These enum values represent potential error that occurs at policy value
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "ash/resources/vector_icons/vector_icons.h"
|
#include "ash/resources/vector_icons/vector_icons.h"
|
||||||
#include "ash/root_window_controller.h"
|
#include "ash/root_window_controller.h"
|
||||||
#include "ash/shell.h"
|
#include "ash/shell.h"
|
||||||
#include "ash/strings/grit/ash_strings.h"
|
|
||||||
#include "ash/system/toast/toast_manager_impl.h"
|
#include "ash/system/toast/toast_manager_impl.h"
|
||||||
#include "base/callback_helpers.h"
|
#include "base/callback_helpers.h"
|
||||||
#include "components/live_caption/views/caption_bubble.h"
|
#include "components/live_caption/views/caption_bubble.h"
|
||||||
@ -122,11 +121,11 @@ void ShowNotification(
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void ProjectorUiController::ShowFailureNotification(int message_id) {
|
void ProjectorUiController::ShowFailureNotification(int message_id,
|
||||||
|
int title_id) {
|
||||||
RecordCreationFlowError(message_id);
|
RecordCreationFlowError(message_id);
|
||||||
ShowNotification(
|
ShowNotification(
|
||||||
kProjectorErrorNotificationId, IDS_ASH_PROJECTOR_FAILURE_TITLE,
|
kProjectorErrorNotificationId, title_id, message_id,
|
||||||
message_id,
|
|
||||||
message_center::SystemNotificationWarningLevel::CRITICAL_WARNING);
|
message_center::SystemNotificationWarningLevel::CRITICAL_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "ash/ash_export.h"
|
#include "ash/ash_export.h"
|
||||||
#include "ash/projector/projector_metrics.h"
|
#include "ash/projector/projector_metrics.h"
|
||||||
#include "ash/public/cpp/projector/projector_session.h"
|
#include "ash/public/cpp/projector/projector_session.h"
|
||||||
|
#include "ash/strings/grit/ash_strings.h"
|
||||||
#include "base/scoped_observation.h"
|
#include "base/scoped_observation.h"
|
||||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
@ -26,7 +27,9 @@ class ASH_EXPORT ProjectorUiController : public ProjectorSessionObserver {
|
|||||||
public:
|
public:
|
||||||
// Shows a notification informing the user that a Projector error has
|
// Shows a notification informing the user that a Projector error has
|
||||||
// occurred.
|
// occurred.
|
||||||
static void ShowFailureNotification(int message_id);
|
static void ShowFailureNotification(
|
||||||
|
int message_id,
|
||||||
|
int title_id = IDS_ASH_PROJECTOR_FAILURE_TITLE);
|
||||||
|
|
||||||
// Shows a notification informing the user that a Projector save error has
|
// Shows a notification informing the user that a Projector save error has
|
||||||
// occurred.
|
// occurred.
|
||||||
|
@ -252,6 +252,45 @@ TEST_F(ProjectorUiControllerTest, ShowFailureNotification) {
|
|||||||
/*count=*/2);
|
/*count=*/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectorUiControllerTest, ShowFailureNotificationWithTitle) {
|
||||||
|
base::HistogramTester histogram_tester;
|
||||||
|
|
||||||
|
MockMessageCenterObserver mock_message_center_observer;
|
||||||
|
message_center::MessageCenter::Get()->AddObserver(
|
||||||
|
&mock_message_center_observer);
|
||||||
|
|
||||||
|
EXPECT_CALL(
|
||||||
|
mock_message_center_observer,
|
||||||
|
OnNotificationAdded(/*notification_id=*/"projector_error_notification"))
|
||||||
|
.Times(1);
|
||||||
|
EXPECT_CALL(mock_message_center_observer,
|
||||||
|
OnNotificationDisplayed(
|
||||||
|
/*notification_id=*/"projector_error_notification",
|
||||||
|
message_center::DisplaySource::DISPLAY_SOURCE_POPUP));
|
||||||
|
|
||||||
|
ProjectorUiController::ShowFailureNotification(
|
||||||
|
IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TEXT,
|
||||||
|
IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TITLE);
|
||||||
|
|
||||||
|
const message_center::NotificationList::Notifications& notifications =
|
||||||
|
message_center::MessageCenter::Get()->GetVisibleNotifications();
|
||||||
|
EXPECT_EQ(notifications.size(), 1u);
|
||||||
|
EXPECT_EQ((*notifications.begin())->id(), "projector_error_notification");
|
||||||
|
EXPECT_EQ(
|
||||||
|
(*notifications.begin())->message(),
|
||||||
|
l10n_util::GetStringUTF16(IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TEXT));
|
||||||
|
EXPECT_EQ(
|
||||||
|
(*notifications.begin())->title(),
|
||||||
|
l10n_util::GetStringUTF16(IDS_ASH_PROJECTOR_ABORT_BY_AUDIO_POLICY_TITLE));
|
||||||
|
|
||||||
|
histogram_tester.ExpectBucketCount(
|
||||||
|
kProjectorCreationFlowErrorHistogramName,
|
||||||
|
ProjectorCreationFlowError::kSessionAbortedByAudioPolicyDisabled,
|
||||||
|
/*expected_count=*/1);
|
||||||
|
histogram_tester.ExpectTotalCount(kProjectorCreationFlowErrorHistogramName,
|
||||||
|
/*count=*/1);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ProjectorUiControllerTest, ShowSaveFailureNotification) {
|
TEST_F(ProjectorUiControllerTest, ShowSaveFailureNotification) {
|
||||||
base::HistogramTester histogram_tester;
|
base::HistogramTester histogram_tester;
|
||||||
|
|
||||||
|
@ -82087,6 +82087,8 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
|
|||||||
<enum name="ProjectorCreationFlowError">
|
<enum name="ProjectorCreationFlowError">
|
||||||
<int value="0" label="Can't save recording"/>
|
<int value="0" label="Can't save recording"/>
|
||||||
<int value="1" label="Can't generate transcription"/>
|
<int value="1" label="Can't generate transcription"/>
|
||||||
|
<int value="2"
|
||||||
|
label="Session aborted since audio capture policy is disabled"/>
|
||||||
</enum>
|
</enum>
|
||||||
|
|
||||||
<enum name="ProjectorMarkerColor">
|
<enum name="ProjectorMarkerColor">
|
||||||
|
Reference in New Issue
Block a user