Bug 227031 - Update Media Accessibility preferences in the WebContent process from the UI process
Summary: Update Media Accessibility preferences in the WebContent process from the UI ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-15 09:24 PDT by Per Arne Vollan
Modified: 2021-06-16 02:05 PDT (History)
8 users (show)

See Also:


Attachments
Patch (19.10 KB, patch)
2021-06-15 09:32 PDT, Per Arne Vollan
eric.carlson: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (19.10 KB, patch)
2021-06-16 01:07 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Per Arne Vollan 2021-06-15 09:24:08 PDT
Due to stricter sandboxing in the WebContent process, Media Accessibility preferences should be updated from the UI process.
Comment 1 Per Arne Vollan 2021-06-15 09:25:19 PDT
<rdar://78614882>
Comment 2 Per Arne Vollan 2021-06-15 09:32:44 PDT
Created attachment 431447 [details]
Patch
Comment 3 Eric Carlson 2021-06-15 10:26:55 PDT
Comment on attachment 431447 [details]
Patch

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

> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:222
> +    case kMACaptionAppearanceDisplayTypeForcedOnly:
> +        return ForcedOnly;
> +
> +    case kMACaptionAppearanceDisplayTypeAutomatic:
> +        return Automatic;
> +
> +    case kMACaptionAppearanceDisplayTypeAlwaysOn:
> +        return AlwaysOn;
> +    }

I think it is a mistake to have the one method sometimes return the cached value and sometimes call the system because the caller always knows if it to do one thing or the other, so I would split this into two methods.

> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:527
> +    if (cachedPreferredLanguages().has_value())
> +        return cachedPreferredLanguages().value();
> +
> +    auto captionLanguages = adoptCF(MACaptionAppearanceCopySelectedLanguages(kMACaptionAppearanceDomainUser));
> +    CFIndex captionLanguagesCount = captionLanguages ? CFArrayGetCount(captionLanguages.get()) : 0;
> +
> +    Vector<String> preferredLanguages;
> +    preferredLanguages.reserveInitialCapacity(captionLanguagesCount);
> +    for (CFIndex i = 0; i < captionLanguagesCount; i++)
> +        preferredLanguages.uncheckedAppend(static_cast<CFStringRef>(CFArrayGetValueAtIndex(captionLanguages.get(), i)));
> +
> +    return preferredLanguages;

Ditto.
Comment 4 Per Arne Vollan 2021-06-16 01:07:16 PDT
Created attachment 431524 [details]
Patch
Comment 5 EWS 2021-06-16 01:56:37 PDT
Committed r278927 (238858@main): <https://commits.webkit.org/238858@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431524 [details].
Comment 6 Per Arne Vollan 2021-06-16 02:05:07 PDT
(In reply to Eric Carlson from comment #3)
> Comment on attachment 431447 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=431447&action=review
> 
> > Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:222
> > +    case kMACaptionAppearanceDisplayTypeForcedOnly:
> > +        return ForcedOnly;
> > +
> > +    case kMACaptionAppearanceDisplayTypeAutomatic:
> > +        return Automatic;
> > +
> > +    case kMACaptionAppearanceDisplayTypeAlwaysOn:
> > +        return AlwaysOn;
> > +    }
> 
> I think it is a mistake to have the one method sometimes return the cached
> value and sometimes call the system because the caller always knows if it to
> do one thing or the other, so I would split this into two methods.
> 
> > Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:527
> > +    if (cachedPreferredLanguages().has_value())
> > +        return cachedPreferredLanguages().value();
> > +
> > +    auto captionLanguages = adoptCF(MACaptionAppearanceCopySelectedLanguages(kMACaptionAppearanceDomainUser));
> > +    CFIndex captionLanguagesCount = captionLanguages ? CFArrayGetCount(captionLanguages.get()) : 0;
> > +
> > +    Vector<String> preferredLanguages;
> > +    preferredLanguages.reserveInitialCapacity(captionLanguagesCount);
> > +    for (CFIndex i = 0; i < captionLanguagesCount; i++)
> > +        preferredLanguages.uncheckedAppend(static_cast<CFStringRef>(CFArrayGetValueAtIndex(captionLanguages.get(), i)));
> > +
> > +    return preferredLanguages;
> 
> Ditto.

Fixed by moving the check outside the method.

Thanks for reviewing!