Chromium Code Reviews| Index: content/browser/webui/web_ui_data_source_impl.cc |
| diff --git a/content/browser/webui/web_ui_data_source_impl.cc b/content/browser/webui/web_ui_data_source_impl.cc |
| index f62ade45501f5228f9d59ce9ffd1a18ec3106e64..e8820d15a6e0ed60a0f83ddd6fde27ce6a061910 100644 |
| --- a/content/browser/webui/web_ui_data_source_impl.cc |
| +++ b/content/browser/webui/web_ui_data_source_impl.cc |
| @@ -74,9 +74,8 @@ class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { |
| return parent_->deny_xframe_options_; |
| } |
| bool IsGzipped(const std::string& path) const override { |
| - if (!parent_->json_path_.empty() && path == parent_->json_path_) |
| - return false; |
| - return parent_->use_gzip_for_all_paths_; |
| + return parent_->use_gzip_for_all_paths_ && |
| + parent_->GetResourceIdFromPath(path) != -1; |
|
agrieve
2016/10/12 14:19:36
I think this would have worked:
if (path == json_
Dan Beam
2016/10/12 16:26:32
this breaks when no json_path_ is set, but a .empt
|
| } |
| private: |
| @@ -240,13 +239,7 @@ void WebUIDataSourceImpl::StartDataRequest( |
| return; |
| } |
| - int resource_id = default_resource_; |
| - std::map<std::string, int>::iterator result; |
| - // Remove the query string for named resource lookups. |
| - std::string file_path = path.substr(0, path.find_first_of('?')); |
| - result = path_to_idr_map_.find(file_path); |
| - if (result != path_to_idr_map_.end()) |
| - resource_id = result->second; |
| + int resource_id = GetResourceIdFromPath(path); |
| DCHECK_NE(resource_id, -1); |
| scoped_refptr<base::RefCountedMemory> response( |
| GetContentClient()->GetDataResourceBytes(resource_id)); |
| @@ -272,4 +265,11 @@ void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( |
| callback.Run(base::RefCountedString::TakeString(&template_data)); |
| } |
| +int WebUIDataSourceImpl::GetResourceIdFromPath(const std::string& path) const { |
| + // Remove the query string for named resource lookups. |
| + std::string file_path = path.substr(0, path.find_first_of('?')); |
| + auto result = path_to_idr_map_.find(file_path); |
| + return result != path_to_idr_map_.end() ? result->second : default_resource_; |
| +} |
| + |
| } // namespace content |