REVIEW: obtain mime type from file path only on IO allowed sequence
This commit is contained in:
parent
e072213923
commit
d29c27dc78
3 changed files with 55 additions and 40 deletions
|
@ -29,7 +29,6 @@
|
|||
#include "content/public/browser/web_contents.h"
|
||||
#include "grit/pdf_viewer_resources_map.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/mime_util.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
@ -79,10 +78,26 @@ class BundledDataSource : public content::URLDataSource {
|
|||
|
||||
std::string GetMimeType(const std::string& path) const override {
|
||||
std::string filename = PathWithoutParams(path);
|
||||
std::string mime_type;
|
||||
net::GetMimeTypeFromFile(
|
||||
base::FilePath::FromUTF8Unsafe(filename), &mime_type);
|
||||
return mime_type;
|
||||
if (base::EndsWith(filename, ".html",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "text/html";
|
||||
} else if (base::EndsWith(filename, ".css",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "text/css";
|
||||
} else if (base::EndsWith(filename, ".js",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "application/javascript";
|
||||
} else if (base::EndsWith(filename, ".png",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "image/png";
|
||||
} else if (base::EndsWith(filename, ".gif",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "image/gif";
|
||||
} else if (base::EndsWith(filename, ".svg",
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
return "image/svg+xml";
|
||||
}
|
||||
return "text/html";
|
||||
}
|
||||
|
||||
bool ShouldAddContentSecurityPolicy() const override { return false; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue