Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/PreloadRequest.h

Issue 2440803002: Filter out data urls in the preload scanner (Closed)
Patch Set: fix up Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PreloadRequest_h 5 #ifndef PreloadRequest_h
6 #define PreloadRequest_h 6 #define PreloadRequest_h
7 7
8 #include "core/fetch/ClientHintsPreferences.h" 8 #include "core/fetch/ClientHintsPreferences.h"
9 #include "core/fetch/FetchRequest.h" 9 #include "core/fetch/FetchRequest.h"
10 #include "core/fetch/IntegrityMetadata.h" 10 #include "core/fetch/IntegrityMetadata.h"
(...skipping 12 matching lines...) Expand all
23 class PreloadRequest { 23 class PreloadRequest {
24 USING_FAST_MALLOC(PreloadRequest); 24 USING_FAST_MALLOC(PreloadRequest);
25 25
26 public: 26 public:
27 enum RequestType { 27 enum RequestType {
28 RequestTypePreload, 28 RequestTypePreload,
29 RequestTypePreconnect, 29 RequestTypePreconnect,
30 RequestTypeLinkRelPreload 30 RequestTypeLinkRelPreload
31 }; 31 };
32 32
33 // TODO(csharrison): Move the implementation to the cpp file when html
34 // gets its own testing source set in html/BUILD.gn.
33 static std::unique_ptr<PreloadRequest> create( 35 static std::unique_ptr<PreloadRequest> create(
Yoav Weiss 2016/10/24 15:00:32 Usually `create()` doesn't fail in normal circumst
Charlie Harrison 2016/10/24 17:39:48 Done.
34 const String& initiatorName, 36 const String& initiatorName,
35 const TextPosition& initiatorPosition, 37 const TextPosition& initiatorPosition,
36 const String& resourceURL, 38 const String& resourceURL,
37 const KURL& baseURL, 39 const KURL& baseURL,
38 Resource::Type resourceType, 40 Resource::Type resourceType,
39 const ReferrerPolicy referrerPolicy, 41 const ReferrerPolicy referrerPolicy,
40 const FetchRequest::ResourceWidth& resourceWidth = 42 const FetchRequest::ResourceWidth& resourceWidth =
41 FetchRequest::ResourceWidth(), 43 FetchRequest::ResourceWidth(),
42 const ClientHintsPreferences& clientHintsPreferences = 44 const ClientHintsPreferences& clientHintsPreferences =
43 ClientHintsPreferences(), 45 ClientHintsPreferences(),
44 RequestType requestType = RequestTypePreload) { 46 RequestType requestType = RequestTypePreload) {
47 // Never preload data or ref urls.
48 if (resourceURL.isEmpty() || resourceURL.startsWith("#") ||
Yoav Weiss 2016/10/24 14:43:54 Are absolute ref URLs an issue? What would happen
Charlie Harrison 2016/10/24 14:49:31 I think absolute ref URLs are okay because we real
Yoav Weiss 2016/10/24 15:00:32 Thanks. Clarifying that in the comment would be in
Charlie Harrison 2016/10/24 17:39:48 Done.
49 protocolIs(resourceURL, "data")) {
50 return nullptr;
51 }
45 return wrapUnique(new PreloadRequest( 52 return wrapUnique(new PreloadRequest(
46 initiatorName, initiatorPosition, resourceURL, baseURL, resourceType, 53 initiatorName, initiatorPosition, resourceURL, baseURL, resourceType,
47 resourceWidth, clientHintsPreferences, requestType, referrerPolicy)); 54 resourceWidth, clientHintsPreferences, requestType, referrerPolicy));
48 } 55 }
49 56
50 bool isSafeToSendToAnotherThread() const; 57 bool isSafeToSendToAnotherThread() const;
51 58
52 FetchRequest resourceRequest(Document*); 59 FetchRequest resourceRequest(Document*);
53 60
54 const String& charset() const { return m_charset; } 61 const String& charset() const { return m_charset; }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 140
134 // Used for deprecation warnings. 141 // Used for deprecation warnings.
135 bool m_hasInvalidTypeOrLanguage = false; 142 bool m_hasInvalidTypeOrLanguage = false;
136 }; 143 };
137 144
138 typedef Vector<std::unique_ptr<PreloadRequest>> PreloadRequestStream; 145 typedef Vector<std::unique_ptr<PreloadRequest>> PreloadRequestStream;
139 146
140 } // namespace blink 147 } // namespace blink
141 148
142 #endif 149 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698