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 03721b0c5e1d1d024c234d0ea0cc90f7f2c5a47a..b312195f6b971f1abc7c5670301a5cf67e5dec2b 100644 |
| --- a/content/browser/webui/shared_resources_data_source.cc |
| +++ b/content/browser/webui/shared_resources_data_source.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/memory/ref_counted_memory.h" |
| #include "base/strings/string_piece.h" |
| #include "base/strings/string_util.h" |
| +#include "content/public/browser/browser_thread.h" |
| #include "content/public/common/content_client.h" |
| #include "content/public/common/url_constants.h" |
| #include "ui/base/layout.h" |
| @@ -69,6 +70,12 @@ const ResourcesMap& GetResourcesMap() { |
| return *resources_map; |
| } |
| +int GetIDRForPath(const std::string& path) { |
|
Dan Beam
2017/02/23 02:11:30
GetIdrForPath()
tzik
2017/02/23 03:31:40
Done.
|
| + const ResourcesMap& resources_map = GetResourcesMap(); |
| + auto it = resources_map.find(path); |
| + return (it != resources_map.end()) ? it->second : -1; |
|
Dan Beam
2017/02/23 02:11:30
nit: return it != resources_map.end() ? it->second
tzik
2017/02/23 03:31:40
Done.
|
| +} |
| + |
| } // namespace |
| SharedResourcesDataSource::SharedResourcesDataSource() { |
| @@ -85,9 +92,7 @@ void SharedResourcesDataSource::StartDataRequest( |
| const std::string& path, |
| const ResourceRequestInfo::WebContentsGetter& wc_getter, |
| const URLDataSource::GotDataCallback& callback) { |
| - const ResourcesMap& resources_map = GetResourcesMap(); |
| - auto it = resources_map.find(path); |
| - int idr = (it != resources_map.end()) ? it->second : -1; |
| + int idr = GetIDRForPath(path); |
| DCHECK_NE(-1, idr) << " path: " << path; |
| scoped_refptr<base::RefCountedMemory> bytes; |
| @@ -148,6 +153,14 @@ std::string SharedResourcesDataSource::GetMimeType( |
| scoped_refptr<base::SingleThreadTaskRunner> |
| SharedResourcesDataSource::TaskRunnerForRequestPath( |
| const std::string& path) const { |
| + int idr = GetIDRForPath(path); |
| + if (idr == IDR_WEBUI_CSS_TEXT_DEFAULTS || |
| + idr == IDR_WEBUI_CSS_TEXT_DEFAULTS_MD) { |
| + // Use UI thread to load CSS since its construction touches non-thread-safe |
| + // gfx::Font names in ui::ResourceBundle. |
| + return URLDataSource::TaskRunnerForRequestPath(path); |
| + } |
| + |
| return nullptr; |
| } |