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

Unified Diff: extensions/browser/api/mime_handler_private/mime_handler_private.cc

Issue 1062283003: Ensure MimeHandlerView plugins load properly with long URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/mime_handler_private/mime_handler_private.cc
diff --git a/extensions/browser/api/mime_handler_private/mime_handler_private.cc b/extensions/browser/api/mime_handler_private/mime_handler_private.cc
index 4b9c5e382d723600598d70f380760f4c3a89ceb5..13caee208f0557a23542b4848829c463f6668de1 100644
--- a/extensions/browser/api/mime_handler_private/mime_handler_private.cc
+++ b/extensions/browser/api/mime_handler_private/mime_handler_private.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_util.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/browser/stream_info.h"
+#include "content/public/common/content_constants.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "extensions/common/constants.h"
#include "net/http/http_response_headers.h"
@@ -99,7 +100,18 @@ extensions::mime_handler::StreamInfoPtr TypeConverter<
result->tab_id = stream.tab_id();
const content::StreamInfo* info = stream.stream_info();
result->mime_type = info->mime_type;
- result->original_url = info->original_url.spec();
+
+ // If the URL is too long, mojo will give up on sending the URL. In these
+ // cases truncate it. Only data: URLs should ever really suffer this problem
+ // so only worry about those for now.
+ // TODO(raymes): This appears to be a bug in mojo somewhere. crbug.com/480099.
+ if (info->original_url.SchemeIs(url::kDataScheme) &&
+ info->original_url.spec().size() > content::kMaxURLDisplayChars) {
+ result->original_url = info->original_url.scheme() + ":";
+ } else {
+ result->original_url = info->original_url.spec();
+ }
+
result->stream_url = info->handle->GetURL().spec();
result->response_headers =
extensions::CreateResponseHeadersMap(info->response_headers.get());

Powered by Google App Engine
This is Rietveld 408576698