diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 21:11:20 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-03 21:11:20 +0000 |
commit | 2d8099cf56475b6989911ea8e573cbeb26724f3d (patch) | |
tree | 05b33ac2edbaf2bddddf7f75f904b3c9949ccab7 /net/base | |
parent | 9df79fddac6dc70909ac16207c9e63f2660ca5d1 (diff) | |
download | chromium_src-2d8099cf56475b6989911ea8e573cbeb26724f3d.zip chromium_src-2d8099cf56475b6989911ea8e573cbeb26724f3d.tar.gz chromium_src-2d8099cf56475b6989911ea8e573cbeb26724f3d.tar.bz2 |
Allow data URLs to trigger downloads, as they do in Firefox.
Unfortunately, many of our tests rely on being able to use WebURLLoader to load
data: URLs when there is no ResourceLoaderBridge implementation. In those tests,
we would crash if we try to use the ResourceLoaderBridge. To workaround that,
and because it probably a good optimization anyways, I decided to check if the
data URL has a supported MIME type, and if it does, then I let it load directly
as before.
Since data URLs may be very large, I modified DataURL::Parse to skip parsing the
'data' section of the URL if the corresponding out param is null.
R=tony
BUG=38546
TEST=none (I would like to add a download test, but they are all disabled or flaky.)
Review URL: http://codereview.chromium.org/5542001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/data_url.cc | 4 | ||||
-rw-r--r-- | net/base/data_url.h | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/net/base/data_url.cc b/net/base/data_url.cc index e30f7da..e387cd1 100644 --- a/net/base/data_url.cc +++ b/net/base/data_url.cc @@ -60,6 +60,10 @@ bool DataURL::Parse(const GURL& url, std::string* mime_type, if (charset->empty()) charset->assign("US-ASCII"); + // The caller may not be interested in receiving the data. + if (!data) + return true; + // Preserve spaces if dealing with text or xml input, same as mozilla: // https://bugzilla.mozilla.org/show_bug.cgi?id=138052 // but strip them otherwise: diff --git a/net/base/data_url.h b/net/base/data_url.h index b40878a..65a211a 100644 --- a/net/base/data_url.h +++ b/net/base/data_url.h @@ -37,6 +37,9 @@ class DataURL { // If the URL is malformed, then this method will return false, and its // output variables will remain unchanged. On success, true is returned. // + // OPTIONAL: If |data| is NULL, then the <data> section will not be parsed + // or validated. + // static bool Parse(const GURL& url, std::string* mime_type, std::string* charset, |