Bug 93138 - Cleanup locations of various checks in requestPlugin and loadPlugin
Summary: Cleanup locations of various checks in requestPlugin and loadPlugin
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mike West
URL:
Keywords:
Depends on: 92649
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-03 10:24 PDT by Mike West
Modified: 2012-08-04 15:49 PDT (History)
4 users (show)

See Also:


Attachments
Patch (7.28 KB, patch)
2012-08-04 11:54 PDT, Mike West
no flags Details | Formatted Diff | Diff
Patch (7.38 KB, patch)
2012-08-04 14:08 PDT, Mike West
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike West 2012-08-03 10:24:04 PDT
For example, the sandbox check should be by the Content Security Policy check.
Comment 1 Mike West 2012-08-04 11:54:33 PDT
Created attachment 156535 [details]
Patch
Comment 2 Mike West 2012-08-04 11:56:24 PDT
What do you think about this, Adam and Jochen (since I think both you know things about SubframeLoader)?

I think it makes sense to extract these tests out into a separate method, but the structure as it stands isn't terribly clear to me. Is there a good reason to have both requestPlugin and loadPlugin? Perhaps we could simply merge them?
Comment 3 Adam Barth 2012-08-04 12:18:37 PDT
Comment on attachment 156535 [details]
Patch

Makes sense.  Usually we phrase these sorts of functions in terms of what's allowed rather than what's blocked to avoid having too many confusing double negatives.
Comment 4 Adam Barth 2012-08-04 12:24:52 PDT
Comment on attachment 156535 [details]
Patch

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

> Source/WebCore/loader/SubframeLoader.cpp:116
> +        if (document() && document()->securityOrigin()->isLocal() && !settings->isJavaEnabledForLocalFiles())

For a followup patch, I wonder if we should be getting the document from the pluginElement.  That way we'll always find it and we can remove these null checks.
Comment 5 Mike West 2012-08-04 12:36:25 PDT
(In reply to comment #3)
> (From update of attachment 156535 [details])
> Makes sense.  Usually we phrase these sorts of functions in terms of what's allowed rather than what's blocked to avoid having too many confusing double negatives.

There's already `allowPlugins`, which (I think) is more concerned with content settings. I'm not sure it makes a lot of sense to have `allowPlugins?` directly followed by `isPluginAllowed?`. Conceptually, it's clear ("Are plugins allowed, in general?" is a different question to "Is this specific plugin allowed?"), but it doesn't read well.

I'd originally planned to push the `isSandboxed` check into `allowPlugins` (since it falls into the former question), but stopped since it would have the side-effect of notifying `didNotAllowPlugins`, which I think Chromium does something interesting with.

Any thoughts on that split?
Comment 6 Adam Barth 2012-08-04 12:38:21 PDT
> There's already `allowPlugins`, which (I think) is more concerned with content settings. I'm not sure it makes a lot of sense to have `allowPlugins?` directly followed by `isPluginAllowed?`. Conceptually, it's clear ("Are plugins allowed, in general?" is a different question to "Is this specific plugin allowed?"), but it doesn't read well.
> 
> I'd originally planned to push the `isSandboxed` check into `allowPlugins` (since it falls into the former question), but stopped since it would have the side-effect of notifying `didNotAllowPlugins`, which I think Chromium does something interesting with.
> 
> Any thoughts on that split?

I think it's better to keep the sandbox check separate.  That's what we do in other cases.  Perhaps shouldLoadPlugin(...) is a good name for the function?
Comment 7 Mike West 2012-08-04 12:49:22 PDT
(In reply to comment #6)
> > There's already `allowPlugins`, which (I think) is more concerned with content settings. I'm not sure it makes a lot of sense to have `allowPlugins?` directly followed by `isPluginAllowed?`. Conceptually, it's clear ("Are plugins allowed, in general?" is a different question to "Is this specific plugin allowed?"), but it doesn't read well.
> > 
> > I'd originally planned to push the `isSandboxed` check into `allowPlugins` (since it falls into the former question), but stopped since it would have the side-effect of notifying `didNotAllowPlugins`, which I think Chromium does something interesting with.
> > 
> > Any thoughts on that split?
> 
> I think it's better to keep the sandbox check separate.  That's what we do in other cases.  Perhaps shouldLoadPlugin(...) is a good name for the function?

Makes sense. However, there's already `shouldUsePlugin`, which determines whether the plugin rendering process should be kicked off for a particular resource.

I've been sitting here about 5 minutes typing new suggestions for names, and then backspacing over them. :)
Comment 8 Mike West 2012-08-04 12:51:24 PDT
(In reply to comment #7)
> (In reply to comment #6)
> > > There's already `allowPlugins`, which (I think) is more concerned with content settings. I'm not sure it makes a lot of sense to have `allowPlugins?` directly followed by `isPluginAllowed?`. Conceptually, it's clear ("Are plugins allowed, in general?" is a different question to "Is this specific plugin allowed?"), but it doesn't read well.
> > > 
> > > I'd originally planned to push the `isSandboxed` check into `allowPlugins` (since it falls into the former question), but stopped since it would have the side-effect of notifying `didNotAllowPlugins`, which I think Chromium does something interesting with.
> > > 
> > > Any thoughts on that split?
> > 
> > I think it's better to keep the sandbox check separate.  That's what we do in other cases.  Perhaps shouldLoadPlugin(...) is a good name for the function?
> 
> Makes sense. However, there's already `shouldUsePlugin`, which determines whether the plugin rendering process should be kicked off for a particular resource.
> 
> I've been sitting here about 5 minutes typing new suggestions for names, and then backspacing over them. :)

pluginIsLoadable?
Comment 9 Adam Barth 2012-08-04 13:34:20 PDT
Lets not get too hung up on the name.  Pick you favorite.  :)
Comment 10 Mike West 2012-08-04 14:08:18 PDT
Created attachment 156539 [details]
Patch
Comment 11 Mike West 2012-08-04 14:09:13 PDT
(In reply to comment #9)
> Lets not get too hung up on the name.  Pick you favorite.  :)

`pluginIsLoadable` is the least bad name I've come up with. CQ? :)
Comment 12 WebKit Review Bot 2012-08-04 15:49:35 PDT
Comment on attachment 156539 [details]
Patch

Clearing flags on attachment: 156539

Committed r124704: <http://trac.webkit.org/changeset/124704>
Comment 13 WebKit Review Bot 2012-08-04 15:49:39 PDT
All reviewed patches have been landed.  Closing bug.