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

Side by Side Diff: content/browser/webui/web_ui_data_source_impl.cc

Issue 2399553002: Gzip compress chrome://accessibility resources (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/webui/web_ui_data_source_impl.h" 5 #include "content/browser/webui/web_ui_data_source_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 std::string GetContentSecurityPolicyChildSrc() const override { 67 std::string GetContentSecurityPolicyChildSrc() const override {
68 if (parent_->frame_src_set_) 68 if (parent_->frame_src_set_)
69 return parent_->frame_src_; 69 return parent_->frame_src_;
70 return URLDataSource::GetContentSecurityPolicyChildSrc(); 70 return URLDataSource::GetContentSecurityPolicyChildSrc();
71 } 71 }
72 bool ShouldDenyXFrameOptions() const override { 72 bool ShouldDenyXFrameOptions() const override {
73 return parent_->deny_xframe_options_; 73 return parent_->deny_xframe_options_;
74 } 74 }
75 bool IsGzipped(const std::string& path) const override { 75 bool IsGzipped(const std::string& path) const override {
76 if (!parent_->json_path_.empty() && path == parent_->json_path_) 76 return parent_->IsGzipped(path);
77 return false;
78 return parent_->use_gzip_for_all_paths_;
79 } 77 }
80 78
81 private: 79 private:
82 WebUIDataSourceImpl* parent_; 80 WebUIDataSourceImpl* parent_;
83 }; 81 };
84 82
85 WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name) 83 WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name)
86 : URLDataSourceImpl(source_name, new InternalDataSource(this)), 84 : URLDataSourceImpl(source_name, new InternalDataSource(this)),
87 source_name_(source_name), 85 source_name_(source_name),
88 default_resource_(-1), 86 default_resource_(-1),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 178 }
181 179
182 void WebUIDataSourceImpl::DisableDenyXFrameOptions() { 180 void WebUIDataSourceImpl::DisableDenyXFrameOptions() {
183 deny_xframe_options_ = false; 181 deny_xframe_options_ = false;
184 } 182 }
185 183
186 void WebUIDataSourceImpl::DisableI18nAndUseGzipForAllPaths() { 184 void WebUIDataSourceImpl::DisableI18nAndUseGzipForAllPaths() {
187 use_gzip_for_all_paths_ = true; 185 use_gzip_for_all_paths_ = true;
188 } 186 }
189 187
188 bool WebUIDataSourceImpl::IsGzipped(const std::string& path) const {
189 if (!json_path_.empty() && path == json_path_)
190 return false;
191 return use_gzip_for_all_paths_;
192 }
193
190 std::string WebUIDataSourceImpl::GetSource() const { 194 std::string WebUIDataSourceImpl::GetSource() const {
191 return source_name_; 195 return source_name_;
192 } 196 }
193 197
194 std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const { 198 std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const {
195 // Remove the query string for to determine the mime type. 199 // Remove the query string for to determine the mime type.
196 std::string file_path = path.substr(0, path.find_first_of('?')); 200 std::string file_path = path.substr(0, path.find_first_of('?'));
197 201
198 if (base::EndsWith(file_path, ".css", base::CompareCase::INSENSITIVE_ASCII)) 202 if (base::EndsWith(file_path, ".css", base::CompareCase::INSENSITIVE_ASCII))
199 return "text/css"; 203 return "text/css";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 265 }
262 266
263 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( 267 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON(
264 const URLDataSource::GotDataCallback& callback) { 268 const URLDataSource::GotDataCallback& callback) {
265 std::string template_data; 269 std::string template_data;
266 webui::AppendJsonJS(&localized_strings_, &template_data); 270 webui::AppendJsonJS(&localized_strings_, &template_data);
267 callback.Run(base::RefCountedString::TakeString(&template_data)); 271 callback.Run(base::RefCountedString::TakeString(&template_data));
268 } 272 }
269 273
270 } // namespace content 274 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698