address review comments
This commit is contained in:
parent
ee80313666
commit
0df464e16a
1 changed files with 7 additions and 20 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "grit/pdf_viewer_resources_map.h"
|
#include "grit/pdf_viewer_resources_map.h"
|
||||||
#include "net/base/load_flags.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.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
#include "net/url_request/url_request_context.h"
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
#include "ui/base/resource/resource_bundle.h"
|
||||||
|
@ -77,26 +78,12 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetMimeType(const std::string& path) const override {
|
std::string GetMimeType(const std::string& path) const override {
|
||||||
std::string filename = PathWithoutParams(path);
|
auto file = base::FilePath(PathWithoutParams(path));
|
||||||
if (base::EndsWith(filename, ".html",
|
base::FilePath::StringType ext = file.Extension();
|
||||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
std::string mime_type;
|
||||||
return "text/html";
|
if (!ext.empty() &&
|
||||||
} else if (base::EndsWith(filename, ".css",
|
net::GetWellKnownMimeTypeFromExtension(ext.substr(1), &mime_type))
|
||||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
return mime_type;
|
||||||
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";
|
return "text/html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue