OLD | NEW |
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 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h" | 5 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/public/browser/stream_handle.h" | 10 #include "content/public/browser/stream_handle.h" |
11 #include "content/public/browser/stream_info.h" | 11 #include "content/public/browser/stream_info.h" |
12 #include "content/public/common/content_constants.h" | 12 #include "content/public/common/content_constants.h" |
13 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" | 13 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" |
14 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
15 #include "mojo/public/cpp/bindings/map.h" | 15 #include "mojo/public/cpp/bindings/map.h" |
16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 namespace { | 19 namespace { |
20 | 20 |
21 mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap( | 21 mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap( |
22 const net::HttpResponseHeaders* headers) { | 22 const net::HttpResponseHeaders* headers) { |
23 std::map<std::string, std::string> result; | 23 std::map<std::string, std::string> result; |
24 if (!headers) | 24 if (!headers) |
25 return mojo::Map<mojo::String, mojo::String>::From(result); | 25 return mojo::Map<mojo::String, mojo::String>::From(result); |
26 | 26 |
27 void* iter = nullptr; | 27 size_t iter = 0; |
28 std::string header_name; | 28 std::string header_name; |
29 std::string header_value; | 29 std::string header_value; |
30 while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) { | 30 while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) { |
31 // mojo strings must be UTF-8 and headers might not be, so drop any headers | 31 // mojo strings must be UTF-8 and headers might not be, so drop any headers |
32 // that aren't ASCII. The PDF plugin does not use any headers with non-ASCII | 32 // that aren't ASCII. The PDF plugin does not use any headers with non-ASCII |
33 // names and non-ASCII values are never useful for the headers the plugin | 33 // names and non-ASCII values are never useful for the headers the plugin |
34 // does use. | 34 // does use. |
35 // | 35 // |
36 // TODO(sammc): Send as bytes instead of a string and let the client decide | 36 // TODO(sammc): Send as bytes instead of a string and let the client decide |
37 // how to decode. | 37 // how to decode. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 result->original_url = info->original_url.spec(); | 116 result->original_url = info->original_url.spec(); |
117 } | 117 } |
118 | 118 |
119 result->stream_url = info->handle->GetURL().spec(); | 119 result->stream_url = info->handle->GetURL().spec(); |
120 result->response_headers = | 120 result->response_headers = |
121 extensions::CreateResponseHeadersMap(info->response_headers.get()); | 121 extensions::CreateResponseHeadersMap(info->response_headers.get()); |
122 return result; | 122 return result; |
123 } | 123 } |
124 | 124 |
125 } // namespace mojo | 125 } // namespace mojo |
OLD | NEW |