Bug 27787

Summary: The type information about the resource loading is not forwarded to the network layer
Product: WebKit Reporter: Zsombor <gzsombor>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: REOPENED    
Severity: Normal CC: abarth, eric
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
patch which resource type information to the ResourceRequestBase class
eric: review-
new version of the patch
none
new version of the patch, with changelog
eric: review-
patch implementing the base functionality abarth: review-

Zsombor
Reported 2009-07-28 17:36:30 PDT
It would be useful, for the network layer to know, not only the url, but also the type of the resource being requested. For example, for a 'Do not download images' feature, or an advanced adblocker filtering, etc.
Attachments
patch which resource type information to the ResourceRequestBase class (3.62 KB, patch)
2009-07-28 17:38 PDT, Zsombor
eric: review-
new version of the patch (22.74 KB, patch)
2009-08-09 18:41 PDT, Zsombor
no flags
new version of the patch, with changelog (28.10 KB, patch)
2009-08-14 16:54 PDT, Zsombor
eric: review-
patch implementing the base functionality (26.40 KB, patch)
2009-09-13 17:02 PDT, Zsombor
abarth: review-
Zsombor
Comment 1 2009-07-28 17:38:14 PDT
Created attachment 33682 [details] patch which resource type information to the ResourceRequestBase class
Alexey Proskuryakov
Comment 2 2009-07-29 17:30:32 PDT
Please set review? flag if this patch is intended for review; see <http://webkit.org/coding/contributing.html>.
Eric Seidel (no email)
Comment 3 2009-07-31 15:22:36 PDT
Comment on attachment 33682 [details] patch which resource type information to the ResourceRequestBase class Style: 361 case CachedResource::ImageResource :
Zsombor
Comment 4 2009-08-02 18:40:04 PDT
?
Eric Seidel (no email)
Comment 5 2009-08-06 19:16:51 PDT
Extra space before the :. Please run check-webkit-style if you have not already.
Eric Seidel (no email)
Comment 6 2009-08-07 13:50:51 PDT
Comment on attachment 33682 [details] patch which resource type information to the ResourceRequestBase class r- for lack of ChangeLog. Please run check-webkit-style. I think this should just be an argument to the constructor, but I can see how that would be harry to add given the current design. Please don't add a default here: + default : + m_resourceType = GenericRequest; + break; it defeats the point of using a switch for an enum (which is to catch when something is added to the enum). Never used, and not needed: + void setResourceType(RequestType type) { m_resourceType = type; } Hum... but Platform can never depend on WebCore. So this is a layering violation. I suggest that instead you make CachedResource use these constants. And then CachedResource can cast its own constancts back to these for setting.
Zsombor
Comment 7 2009-08-09 18:41:58 PDT
Created attachment 34437 [details] new version of the patch I'm hopefull, that this patch is better suited for incorporation.
Zsombor
Comment 8 2009-08-14 16:54:07 PDT
Created attachment 34879 [details] new version of the patch, with changelog
Eric Seidel (no email)
Comment 9 2009-09-03 01:12:31 PDT
Comment on attachment 34879 [details] new version of the patch, with changelog In general this looks good! Please remove this: 42 default: 243 return Other; and put a "return Other" after the switch. See my previous comment about default: cases for switches over enums as being bad. :) We could avoid all this search/replace by adding a typedef ResourceRequestBase::Type Type; into CachedResponse. I'm not sure I really care one way or the other, but it would definitely make the patch smaller. Style: 45 case ResourceRequestBase::ImageResource : (no space after value before ':') Otherwise looks good.
Zsombor
Comment 10 2009-09-13 17:02:03 PDT
Created attachment 39527 [details] patch implementing the base functionality I don't want to mess too much with the switch-cases - there is already some 'default:' branch in the touched code, so this is way I haven't originaly modified it. I've removed the qt - specific translation code, because it's unknown when ResourceRequestType enum value is added to QtNetworkRequest.
Adam Barth
Comment 11 2009-09-23 22:27:28 PDT
Comment on attachment 39527 [details] patch implementing the base functionality This is a layering violation. The network layer shouldn't know what an image or a style sheet is. If you want to implement a "block all images feature," you should use a client callback.
Zsombor
Comment 12 2009-09-24 00:18:07 PDT
Can you explain, what do you mean, when you say 'client callback' ? I would like to have a proper adblocker, which is compatible with the de facto standard firefox extension. For this it needs to discriminate between several type of network request, for example 'image','stylesheet','dtd','xmlhttprequest','object', etc. Please check the documentation at : http://adblockplus.org/en/filters in the 'Specifying filter options' section.
Eric Seidel (no email)
Comment 13 2009-09-24 11:11:58 PDT
The *Client.h files in WebCore. WebCore asks WebKit to make network requests.
Eric Seidel (no email)
Comment 14 2009-12-04 14:52:17 PST
Bug 32167 is very similar.
Note You need to log in before you can comment on or make changes to this bug.