Chromium Code Reviews| Index: content/browser/webui/shared_resources_data_source.cc |
| diff --git a/content/browser/webui/shared_resources_data_source.cc b/content/browser/webui/shared_resources_data_source.cc |
| index d30e03f6c2ef21922a2c9020c969aea22fa9007a..71a06d272596cc3855783a312d9faef13a45253a 100644 |
| --- a/content/browser/webui/shared_resources_data_source.cc |
| +++ b/content/browser/webui/shared_resources_data_source.cc |
| @@ -7,14 +7,13 @@ |
| #include <stddef.h> |
| #include "base/containers/hash_tables.h" |
| +#include "base/files/file_path.h" |
| #include "base/logging.h" |
| #include "base/memory/ref_counted_memory.h" |
| #include "base/strings/string_piece.h" |
| #include "base/strings/string_util.h" |
| -#include "base/threading/thread_restrictions.h" |
| #include "content/public/common/content_client.h" |
| #include "content/public/common/url_constants.h" |
| -#include "net/base/mime_util.h" |
| #include "ui/base/layout.h" |
| #include "ui/base/webui/web_ui_util.h" |
| #include "ui/resources/grit/webui_resources.h" |
| @@ -104,13 +103,33 @@ void SharedResourcesDataSource::StartDataRequest( |
| std::string SharedResourcesDataSource::GetMimeType( |
| const std::string& path) const { |
|
groby-ooo-7-16
2016/04/29 23:39:15
I still fail to understand why we couldn't run thi
Dan Beam
2016/04/30 00:32:34
Done.
|
| - // Requests should not block on the disk! On POSIX this goes to disk. |
| - // http://code.google.com/p/chromium/issues/detail?id=59849 |
| + if (path.empty()) |
| + return "text/html"; |
| - base::ThreadRestrictions::ScopedAllowIO allow_io; |
| - std::string mime_type; |
| - net::GetMimeTypeFromFile(base::FilePath().AppendASCII(path), &mime_type); |
| - return mime_type; |
| + base::FilePath filepath(path); |
|
groby-ooo-7-16
2016/04/29 23:39:16
I'd minimally prefer getting the extension once (p
Dan Beam
2016/04/30 00:32:34
Done.
|
| + if (filepath.MatchesExtension(".html")) |
|
Dan Beam
2016/04/29 22:39:36
list derived via magic
(`find ui/webui/resources/
|
| + return "text/html"; |
| + |
| + if (filepath.MatchesExtension(".css")) |
| + return "text/css"; |
| + |
| + if (filepath.MatchesExtension(".js")) |
| + return "application/javascript"; |
| + |
| + if (filepath.MatchesExtension(".png")) |
| + return "image/png"; |
| + |
| + if (filepath.MatchesExtension(".gif")) |
| + return "image/gif"; |
| + |
| + if (filepath.MatchesExtension(".svg")) |
| + return "image/svg+xml"; |
| + |
| + if (filepath.MatchesExtension(".woff2")) |
| + return "application/font-woff2"; |
| + |
| + NOTREACHED(); |
|
groby-ooo-7-16
2016/04/29 23:39:15
You want to do a CHECK here to force people to not
Dan Beam
2016/04/30 00:32:34
Done.
|
| + return "text/plain"; |
| } |
| std::string |