OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ | 5 #ifndef NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ |
6 #define NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ | 6 #define NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 class NET_EXPORT HttpContentDisposition { | 15 class NET_EXPORT HttpContentDisposition { |
16 public: | 16 public: |
17 enum Type { | 17 enum Type { |
18 INLINE, | 18 INLINE, |
19 ATTACHMENT, | 19 ATTACHMENT, |
20 }; | 20 }; |
21 | 21 |
22 // Properties of the Content-Disposition header. Used for UMA. | 22 // Properties of the Content-Disposition header. Used for UMA. |
Alexei Svitkine (slow)
2015/04/28 14:26:56
If this is used for UMA, then you shouldn't renumb
dtapuska
2015/04/28 14:29:15
These values aren't used for UMA directly... they
Alexei Svitkine (slow)
2015/04/28 14:41:19
I see - I think the comment as-is is misleading th
| |
23 enum ParseResultFlags { | 23 enum ParseResultFlags { |
24 INVALID = 0, | 24 INVALID = 0, |
25 | 25 |
26 // A valid disposition-type is present. | 26 // A valid disposition-type is present. |
27 HAS_DISPOSITION_TYPE = 1 << 0, | 27 HAS_DISPOSITION_TYPE = 1 << 0, |
28 | 28 |
29 // The disposition-type is not 'inline' or 'attachment'. | 29 // The disposition-type is not 'inline' or 'attachment'. |
30 HAS_UNKNOWN_DISPOSITION_TYPE = 1 << 1, | 30 HAS_UNKNOWN_DISPOSITION_TYPE = 1 << 1, |
31 | 31 |
32 // Has a valid non-empty 'name' attribute. | |
33 HAS_NAME = 1 << 2, | |
34 | |
35 // Has a valid non-empty 'filename' attribute. | 32 // Has a valid non-empty 'filename' attribute. |
36 HAS_FILENAME = 1 << 3, | 33 HAS_FILENAME = 1 << 2, |
37 | 34 |
38 // Has a valid non-empty 'filename*' attribute. | 35 // Has a valid non-empty 'filename*' attribute. |
39 HAS_EXT_FILENAME = 1 << 4, | 36 HAS_EXT_FILENAME = 1 << 3, |
40 | 37 |
41 // The following fields are properties of the 'filename' attribute: | 38 // The following fields are properties of the 'filename' attribute: |
42 | 39 |
43 // Quoted-string contains non-ASCII characters. | 40 // Quoted-string contains non-ASCII characters. |
44 HAS_NON_ASCII_STRINGS = 1 << 5, | 41 HAS_NON_ASCII_STRINGS = 1 << 4, |
45 | 42 |
46 // Quoted-string contains percent-encoding. | 43 // Quoted-string contains percent-encoding. |
47 HAS_PERCENT_ENCODED_STRINGS = 1 << 6, | 44 HAS_PERCENT_ENCODED_STRINGS = 1 << 5, |
48 | 45 |
49 // Quoted-string contains RFC 2047 encoded words. | 46 // Quoted-string contains RFC 2047 encoded words. |
50 HAS_RFC2047_ENCODED_STRINGS = 1 << 7 | 47 HAS_RFC2047_ENCODED_STRINGS = 1 << 6 |
51 }; | 48 }; |
52 | 49 |
53 HttpContentDisposition(const std::string& header, | 50 HttpContentDisposition(const std::string& header, |
54 const std::string& referrer_charset); | 51 const std::string& referrer_charset); |
55 ~HttpContentDisposition(); | 52 ~HttpContentDisposition(); |
56 | 53 |
57 bool is_attachment() const { return type() == ATTACHMENT; } | 54 bool is_attachment() const { return type() == ATTACHMENT; } |
58 | 55 |
59 Type type() const { return type_; } | 56 Type type() const { return type_; } |
60 const std::string& filename() const { return filename_; } | 57 const std::string& filename() const { return filename_; } |
61 | 58 |
62 // A combination of ParseResultFlags values. | 59 // A combination of ParseResultFlags values. |
63 int parse_result_flags() const { return parse_result_flags_; } | 60 int parse_result_flags() const { return parse_result_flags_; } |
64 | 61 |
65 private: | 62 private: |
66 void Parse(const std::string& header, const std::string& referrer_charset); | 63 void Parse(const std::string& header, const std::string& referrer_charset); |
67 std::string::const_iterator ConsumeDispositionType( | 64 std::string::const_iterator ConsumeDispositionType( |
68 std::string::const_iterator begin, std::string::const_iterator end); | 65 std::string::const_iterator begin, std::string::const_iterator end); |
69 | 66 |
70 Type type_; | 67 Type type_; |
71 std::string filename_; | 68 std::string filename_; |
72 int parse_result_flags_; | 69 int parse_result_flags_; |
73 | 70 |
74 DISALLOW_COPY_AND_ASSIGN(HttpContentDisposition); | 71 DISALLOW_COPY_AND_ASSIGN(HttpContentDisposition); |
75 }; | 72 }; |
76 | 73 |
77 } // namespace net | 74 } // namespace net |
78 | 75 |
79 #endif // NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ | 76 #endif // NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ |
OLD | NEW |