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

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

Issue 2399553002: Gzip compress chrome://accessibility resources (Closed)
Patch Set: asdf 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..a5364fbf2b2810e36be883d8a3bb4c7fc156ca31 100644
--- a/content/browser/webui/web_ui_data_source_impl.cc
+++ b/content/browser/webui/web_ui_data_source_impl.cc
@@ -10,6 +10,7 @@
#include <string>
#include "base/bind.h"
+#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_util.h"
@@ -74,9 +75,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_->excluded_paths_.find(path) == parent_->excluded_paths_.end();
}
private:
@@ -147,7 +147,11 @@ void WebUIDataSourceImpl::AddInteger(const std::string& name, int32_t value) {
}
void WebUIDataSourceImpl::SetJsonPath(const std::string& path) {
+ DCHECK(json_path_.empty());
+ DCHECK(!path.empty());
+
json_path_ = path;
+ ExcludePathFromGzip(json_path_);
}
void WebUIDataSourceImpl::AddResourcePath(const std::string &path,
@@ -168,6 +172,10 @@ void WebUIDataSourceImpl::DisableReplaceExistingSource() {
replace_existing_source_ = false;
}
+void WebUIDataSourceImpl::ExcludePathFromGzip(const std::string& path) {
+ excluded_paths_.insert(path);
+}
+
void WebUIDataSourceImpl::DisableContentSecurityPolicy() {
add_csp_ = false;
}
« 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