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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/public/browser/stream_handle.h" | 8 #include "content/public/browser/stream_handle.h" |
9 #include "content/public/browser/stream_info.h" | 9 #include "content/public/browser/stream_info.h" |
| 10 #include "content/public/common/content_constants.h" |
10 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" | 11 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" |
11 #include "extensions/common/constants.h" | 12 #include "extensions/common/constants.h" |
12 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/map.h" | 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/map.h" |
14 | 15 |
15 namespace extensions { | 16 namespace extensions { |
16 namespace { | 17 namespace { |
17 | 18 |
18 mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap( | 19 mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap( |
19 const net::HttpResponseHeaders* headers) { | 20 const net::HttpResponseHeaders* headers) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 extensions::StreamContainer>::Convert(const extensions::StreamContainer& | 93 extensions::StreamContainer>::Convert(const extensions::StreamContainer& |
93 stream) { | 94 stream) { |
94 if (!stream.stream_info()->handle) | 95 if (!stream.stream_info()->handle) |
95 return extensions::mime_handler::StreamInfoPtr(); | 96 return extensions::mime_handler::StreamInfoPtr(); |
96 | 97 |
97 auto result = extensions::mime_handler::StreamInfo::New(); | 98 auto result = extensions::mime_handler::StreamInfo::New(); |
98 result->embedded = stream.embedded(); | 99 result->embedded = stream.embedded(); |
99 result->tab_id = stream.tab_id(); | 100 result->tab_id = stream.tab_id(); |
100 const content::StreamInfo* info = stream.stream_info(); | 101 const content::StreamInfo* info = stream.stream_info(); |
101 result->mime_type = info->mime_type; | 102 result->mime_type = info->mime_type; |
102 result->original_url = info->original_url.spec(); | 103 |
| 104 // If the URL is too long, mojo will give up on sending the URL. In these |
| 105 // cases truncate it. Only data: URLs should ever really suffer this problem |
| 106 // so only worry about those for now. |
| 107 // TODO(raymes): This appears to be a bug in mojo somewhere. crbug.com/480099. |
| 108 if (info->original_url.SchemeIs(url::kDataScheme) && |
| 109 info->original_url.spec().size() > content::kMaxURLDisplayChars) { |
| 110 result->original_url = info->original_url.scheme() + ":"; |
| 111 } else { |
| 112 result->original_url = info->original_url.spec(); |
| 113 } |
| 114 |
103 result->stream_url = info->handle->GetURL().spec(); | 115 result->stream_url = info->handle->GetURL().spec(); |
104 result->response_headers = | 116 result->response_headers = |
105 extensions::CreateResponseHeadersMap(info->response_headers.get()); | 117 extensions::CreateResponseHeadersMap(info->response_headers.get()); |
106 return result.Pass(); | 118 return result.Pass(); |
107 } | 119 } |
108 | 120 |
109 } // namespace mojo | 121 } // namespace mojo |
OLD | NEW |