Removing uses of X11 native key events.
[chromium-blink-merge.git] / content / child / web_url_request_util.cc
blob64ea18d65c2d013336e392efa8bd13f1615a2b7a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/child/web_url_request_util.h"
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebURLRequest.h"
10 using blink::WebURLRequest;
12 namespace content {
14 ResourceType WebURLRequestToResourceType(const WebURLRequest& request) {
15 WebURLRequest::RequestContext requestContext = request.requestContext();
16 if (request.frameType() != WebURLRequest::FrameTypeNone) {
17 DCHECK(requestContext == WebURLRequest::RequestContextForm ||
18 requestContext == WebURLRequest::RequestContextFrame ||
19 requestContext == WebURLRequest::RequestContextHyperlink ||
20 requestContext == WebURLRequest::RequestContextIframe ||
21 requestContext == WebURLRequest::RequestContextInternal ||
22 requestContext == WebURLRequest::RequestContextLocation);
23 if (request.frameType() == WebURLRequest::FrameTypeTopLevel ||
24 request.frameType() == WebURLRequest::FrameTypeAuxiliary) {
25 return RESOURCE_TYPE_MAIN_FRAME;
27 if (request.frameType() == WebURLRequest::FrameTypeNested)
28 return RESOURCE_TYPE_SUB_FRAME;
29 NOTREACHED();
30 return RESOURCE_TYPE_SUB_RESOURCE;
33 switch (requestContext) {
34 // Favicon
35 case WebURLRequest::RequestContextFavicon:
36 return RESOURCE_TYPE_FAVICON;
38 // Font
39 case WebURLRequest::RequestContextFont:
40 return RESOURCE_TYPE_FONT_RESOURCE;
42 // Image
43 case WebURLRequest::RequestContextImage:
44 case WebURLRequest::RequestContextImageSet:
45 return RESOURCE_TYPE_IMAGE;
47 // Media
48 case WebURLRequest::RequestContextAudio:
49 case WebURLRequest::RequestContextVideo:
50 return RESOURCE_TYPE_MEDIA;
52 // Object
53 case WebURLRequest::RequestContextEmbed:
54 case WebURLRequest::RequestContextObject:
55 return RESOURCE_TYPE_OBJECT;
57 // Ping
58 case WebURLRequest::RequestContextBeacon:
59 case WebURLRequest::RequestContextCSPReport:
60 case WebURLRequest::RequestContextPing:
61 return RESOURCE_TYPE_PING;
63 // Prefetch
64 case WebURLRequest::RequestContextPrefetch:
65 return RESOURCE_TYPE_PREFETCH;
67 // Script
68 case WebURLRequest::RequestContextImport:
69 case WebURLRequest::RequestContextScript:
70 return RESOURCE_TYPE_SCRIPT;
72 // Style
73 case WebURLRequest::RequestContextXSLT:
74 case WebURLRequest::RequestContextStyle:
75 return RESOURCE_TYPE_STYLESHEET;
77 // Subresource
78 case WebURLRequest::RequestContextDownload:
79 case WebURLRequest::RequestContextManifest:
80 case WebURLRequest::RequestContextSubresource:
81 case WebURLRequest::RequestContextPlugin:
82 return RESOURCE_TYPE_SUB_RESOURCE;
84 // TextTrack
85 case WebURLRequest::RequestContextTrack:
86 return RESOURCE_TYPE_MEDIA;
88 // Workers
89 case WebURLRequest::RequestContextServiceWorker:
90 return RESOURCE_TYPE_SERVICE_WORKER;
91 case WebURLRequest::RequestContextSharedWorker:
92 return RESOURCE_TYPE_SHARED_WORKER;
93 case WebURLRequest::RequestContextWorker:
94 return RESOURCE_TYPE_WORKER;
96 // Unspecified
97 case WebURLRequest::RequestContextInternal:
98 case WebURLRequest::RequestContextUnspecified:
99 return RESOURCE_TYPE_SUB_RESOURCE;
101 // XHR
102 case WebURLRequest::RequestContextEventSource:
103 case WebURLRequest::RequestContextFetch:
104 case WebURLRequest::RequestContextXMLHttpRequest:
105 return RESOURCE_TYPE_XHR;
107 // These should be handled by the FrameType checks at the top of the
108 // function.
109 case WebURLRequest::RequestContextForm:
110 case WebURLRequest::RequestContextHyperlink:
111 case WebURLRequest::RequestContextLocation:
112 case WebURLRequest::RequestContextFrame:
113 case WebURLRequest::RequestContextIframe:
114 NOTREACHED();
115 return RESOURCE_TYPE_SUB_RESOURCE;
117 default:
118 NOTREACHED();
119 return RESOURCE_TYPE_SUB_RESOURCE;
123 } // namespace content