Add per-origin media controls blacklist
ClosedPublic

Authored by broulik on Sep 24 2019, 2:24 PM.

Details

Summary

Allows disabling them for a specific origin in case it causes trouble or unwanted media controls.

BUG: 394126

Test Plan
  • Successfully enabled and disabled media controls on a domain
  • Popup shows all domains of the current page (in case it has iframes)
  • Shows only if there is a player in the current tab or user blacklisted an origin in that tab previously
  • Opened popup on site without player, got dummy popup, started iframe player, got blacklist offered

There's a way for us to ship a blacklist by default that the user can then override

Should there be wildcard support? Do we need a UI in settings to list all blacklists and edit them?


When there are no controls whatsoever in the popup

Diff Detail

Repository
R856 Plasma Browser Integration
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Sep 24 2019, 2:24 PM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 24 2019, 2:24 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik requested review of this revision.Sep 24 2019, 2:24 PM
broulik edited the test plan for this revision. (Show Details)Sep 24 2019, 2:40 PM
Termy awarded a token.Sep 24 2019, 3:02 PM
broulik updated this revision to Diff 66776.Sep 24 2019, 4:55 PM
broulik edited the test plan for this revision. (Show Details)
  • Add dummy icon when there's no controls
fvogt added a comment.Sep 26 2019, 2:19 PM

AFAICT it doesn't reload the mpris state in the content-script immediately when settings change, can that be implemented?

IMO the blacklist should be more than the domain, it should test the same conditions as CORS, so protocol, domain and port.

extension/action_popup.js
20

getCurrentTabUrl()

42

Currently the function name implies that it returns all tabs, so maybe rename to getCurrentTabFramesUrls() (or better)?

46

Maybe runAt: "document_start" to speed it up a bit? I'm not sure about the implications.

62

Whitespace?

118

Currently calling set(domain, false); twice has a different result from set(domain, false); once, so maybe split into whitelist(domain) and blacklist(domain))?

120

Whitespace?

extension/content-script.js
68–84

Is this guaranteed to be identical to new URL(window.location.href).hostname as used in utils?

70

Use mpris. instead of items.mpris

AFAICT it doesn't reload the mpris state in the content-script immediately when settings change, can that be implemented?

First we need D24203.
It might be tricky to properly unload e.g. the media sessions stuff, but I can look into this.
Actually, I wanted to implement "live" settings changes for the other settings (like breeze scroll bars and what not) in a later step, too, for which D24203 is a prerequisite.

extension/action_popup.js
20

The class is named TabUtils but I can change the method if you want..

46

Don't think this will change much, given it is only executed when you click the toolbar button, at which point the page is probably already loaded, but I'll give it a try

62

Intentional, for a bit of visual grouping

118

Imho the caller shouldn't have to care about whether it needs to be whitelisted or removed from the blacklist. The whitelist is only so that the user can opt-in to websites which we by default blacklist.

extension/content-script.js
68–84

Good question, no idea, probably. :)

broulik marked 7 inline comments as done.Sep 26 2019, 4:48 PM
broulik updated this revision to Diff 66907.Sep 26 2019, 4:58 PM
broulik retitled this revision from Add per-domain media controls blacklist to Add per-origin media controls blacklist.
broulik edited the summary of this revision. (Show Details)
  • Work on origin rather than hostname
  • Merge whitelist and blacklist
  • Some cleanups
broulik updated this revision to Diff 66924.Sep 26 2019, 8:25 PM
broulik edited the test plan for this revision. (Show Details)
  • Show media controls only if there is a player or something blacklisted on that page, otherwise it gets annoying
fvogt added inline comments.Sep 30 2019, 3:11 PM
extension/action_popup.js
217

Does this also hit all the frames inside?

broulik added inline comments.Sep 30 2019, 3:19 PM
extension/action_popup.js
217

Effectively, yes. It asks the extension.js whether it knows any players on the given tab, which will include all frames, see the actual implementation of "hasTabPlayer" which checks playerIds containing all of them.
(Also, I tested with an embedded YouTube player iframe which showed up alongside the main page)

broulik updated this revision to Diff 67492.Oct 8 2019, 11:36 AM
  • i18n for popup
This revision was not accepted when it landed; it landed in state Needs Review.Oct 14 2019, 9:50 AM
This revision was automatically updated to reflect the committed changes.