Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1937)

Unified Diff: content/browser/webui/web_ui_data_source_impl.cc

Issue 2399553002: Gzip compress chrome://accessibility resources (Closed)
Patch Set: showing agrieve@ what didn't work Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.h ('k') | content/content_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.h ('k') | content/content_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698