Bug 220436

Summary: Make SpeechRecognition permission error more informative
Product: WebKit Reporter: Sihui Liu <sihui_liu>
Component: New BugsAssignee: Sihui Liu <sihui_liu>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Sihui Liu 2021-01-07 14:19:08 PST
...
Comment 1 Sihui Liu 2021-01-07 14:25:21 PST
Created attachment 417211 [details]
Patch
Comment 2 youenn fablet 2021-01-08 00:29:06 PST
Comment on attachment 417211 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417211&action=review

> Source/WebKit/ChangeLog:9
> +        boolean value.

For debug purposes, it might be good to add release logging for each error case so that we get the information in sysdiagnose.

> Source/WebKit/UIProcess/SpeechRecognitionPermissionManager.cpp:78
> +void SpeechRecognitionPermissionManager::request(const String& lang, const WebCore::ClientOrigin& origin, CompletionHandler<void(Optional<WebCore::SpeechRecognitionError>)>&& completiontHandler)

Optional<WebCore::SpeechRecognitionError>&& here and elsewhere

> Source/WebKit/UIProcess/SpeechRecognitionPermissionManager.cpp:110
>          m_speechRecognitionServiceCheck = CheckResult::Granted;

We do not need to compute m_microphoneCheck and m_speechRecognitionServiceCheck if mockCaptureDevicesEnabled is true.
We could write it as:
if (mockCaptureDevicesEnabled) {
    m_microphoneCheck = CheckResult::Granted;
    ...
} else {
    m_microphoneCheck = computeMicrophoneAccess();
    if (m_microphoneCheck == CheckResult::Denied) { 
        ...
        return;
    }
    ...
}

> Source/WebKit/UIProcess/SpeechRecognitionPermissionManager.cpp:124
>      if (!mockCaptureDevicesEnabled && m_speechRecognitionServiceCheck != CheckResult::Denied) {

We no longer need m_speechRecognitionServiceCheck != CheckResult::Denied

> Source/WebKit/UIProcess/SpeechRecognitionServer.cpp:77
>              sendUpdate(identifier, WebCore::SpeechRecognitionUpdateType::Error, error);

WTFMove(error)

> Source/WebKit/UIProcess/SpeechRecognitionServer.h:48
> +using SpeechRecognitionPermissionChecker = Function<void(const String&, const WebCore::ClientOrigin&, CompletionHandler<void(Optional<WebCore::SpeechRecognitionError>)>&&)>;

Optional<WebCore::SpeechRecognitionError>&&
Comment 3 Sihui Liu 2021-01-11 13:52:47 PST
Created attachment 417409 [details]
Patch for landing
Comment 4 EWS 2021-01-11 14:29:27 PST
Committed r271381: <https://trac.webkit.org/changeset/271381>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417409 [details].
Comment 5 Radar WebKit Bug Importer 2021-01-11 14:30:15 PST
<rdar://problem/73014001>