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

Unified Diff: third_party/WebKit/Source/platform/network/NetworkUtils.cpp

Issue 2398053003: Compute ResourceResponse::suggestedFileName on the fly. (Closed)
Patch Set: clean up vestigial changes (trybots previous) Created 4 years, 2 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: third_party/WebKit/Source/platform/network/NetworkUtils.cpp
diff --git a/third_party/WebKit/Source/platform/network/NetworkUtils.cpp b/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
index f64443e3fae98967748feadbb01f39d9cb657cc8..83702b1f80351e4d1f87afb5ed496a7e44bd3a63 100644
--- a/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
+++ b/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
@@ -4,9 +4,14 @@
#include "platform/network/NetworkUtils.h"
+#include "base/strings/string16.h"
+#include "net/base/filename_util.h"
#include "net/base/ip_address.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/url_util.h"
+#include "public/platform/URLConversion.h"
+#include "public/platform/WebString.h"
+#include "url/gurl.h"
#include "wtf/text/StringUTF8Adaptor.h"
#include "wtf/text/WTFString.h"
@@ -53,6 +58,20 @@ String getDomainAndRegistry(const String& host, PrivateRegistryFilter filter) {
return String(domain.data(), domain.length());
}
+String getSuggestedFilename(const KURL& url, const String& contentDisposition) {
+ // TODO(jungshik): Thread in the actual value of the referrer charset and pass
+ // it to GetSuggestedFilename.
+ CString disposition = contentDisposition.utf8();
+ base::string16 filename = net::GetSuggestedFilename(
+ WebStringToGURL(WebString(url.getString())),
+ std::string(disposition.data(), disposition.length()),
+ std::string(), // referrer_charset
+ std::string(), // suggested_name
+ std::string(), // mime_type
+ std::string()); // default_name
+ return String(filename.data(), filename.length());
+}
+
} // NetworkUtils
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698