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

Side by Side Diff: third_party/WebKit/Source/core/loader/LinkHeader.h

Issue 1811163002: Share link header parsing code between blink and content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base-optional
Patch Set: Created 4 years, 8 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef LinkHeader_h
6 #define LinkHeader_h
7
8 #include "core/CoreExport.h"
9 #include "core/html/CrossOriginAttribute.h"
10 #include "wtf/Allocator.h"
11 #include "wtf/text/WTFString.h"
12
13 namespace blink {
14
15 class LinkHeader {
16 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
17 public:
18 template <typename CharType>
19 LinkHeader(CharType*& position, CharType* end);
20
21 const String& url() const { return m_url; }
22 const String& rel() const { return m_rel; }
23 const String& as() const { return m_as; }
24 const String& mimeType() const { return m_mimeType; }
25 const String& media() const { return m_media; }
26 CrossOriginAttributeValue crossOrigin() const { return m_crossOrigin; }
27 bool valid() const { return m_isValid; }
28
29 enum LinkParameterName {
30 LinkParameterRel,
31 LinkParameterAnchor,
32 LinkParameterTitle,
33 LinkParameterMedia,
34 LinkParameterType,
35 LinkParameterRev,
36 LinkParameterHreflang,
37 // Beyond this point, only link-extension parameters
38 LinkParameterUnknown,
39 LinkParameterCrossOrigin,
40 LinkParameterAs,
41 };
42
43 private:
44 void setValue(LinkParameterName, String value);
45
46 String m_url;
47 String m_rel;
48 String m_as;
49 String m_mimeType;
50 String m_media;
51 CrossOriginAttributeValue m_crossOrigin;
52 bool m_isValid;
53 };
54
55 class CORE_EXPORT LinkHeaderSet {
56 STACK_ALLOCATED();
57 public:
58 LinkHeaderSet(const String& header);
59
60 Vector<LinkHeader>::const_iterator begin() const { return m_headerSet.begin( ); }
61 Vector<LinkHeader>::const_iterator end() const { return m_headerSet.end(); }
62 LinkHeader& operator[](size_t i) { return m_headerSet[i]; }
63 size_t size() { return m_headerSet.size(); }
64
65 private:
66 template <typename CharType>
67 void init(CharType* headerValue, unsigned len);
68
69 Vector<LinkHeader> m_headerSet;
70 };
71
72 } // namespace blink
73
74 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698