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 // NOTE: based loosely on mozilla's nsDataChannel.cpp | 5 // NOTE: based loosely on mozilla's nsDataChannel.cpp |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "net/base/data_url.h" | 9 #include "net/base/data_url.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 if (comma == end) | 36 if (comma == end) |
37 return false; | 37 return false; |
38 | 38 |
39 std::vector<std::string> meta_data = | 39 std::vector<std::string> meta_data = |
40 base::SplitString(base::StringPiece(after_colon, comma), ";", | 40 base::SplitString(base::StringPiece(after_colon, comma), ";", |
41 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 41 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
42 | 42 |
43 std::vector<std::string>::iterator iter = meta_data.begin(); | 43 std::vector<std::string>::iterator iter = meta_data.begin(); |
44 if (iter != meta_data.end()) { | 44 if (iter != meta_data.end()) { |
45 mime_type->swap(*iter); | 45 mime_type->swap(*iter); |
46 base::StringToLowerASCII(mime_type); | 46 *mime_type = base::ToLowerASCII(*mime_type); |
47 ++iter; | 47 ++iter; |
48 } | 48 } |
49 | 49 |
50 static const char kBase64Tag[] = "base64"; | 50 static const char kBase64Tag[] = "base64"; |
51 static const char kCharsetTag[] = "charset="; | 51 static const char kCharsetTag[] = "charset="; |
52 const size_t kCharsetTagLength = arraysize(kCharsetTag) - 1; | 52 const size_t kCharsetTagLength = arraysize(kCharsetTag) - 1; |
53 | 53 |
54 bool base64_encoded = false; | 54 bool base64_encoded = false; |
55 for (; iter != meta_data.end(); ++iter) { | 55 for (; iter != meta_data.end(); ++iter) { |
56 if (!base64_encoded && *iter == kBase64Tag) { | 56 if (!base64_encoded && *iter == kBase64Tag) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 temp_data.resize(length + padding_needed, '='); | 129 temp_data.resize(length + padding_needed, '='); |
130 } | 130 } |
131 return base::Base64Decode(temp_data, data); | 131 return base::Base64Decode(temp_data, data); |
132 } | 132 } |
133 | 133 |
134 temp_data.swap(*data); | 134 temp_data.swap(*data); |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 } // namespace net | 138 } // namespace net |
OLD | NEW |