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

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

Issue 2255833003: DO NOT COMMIT: hack hack hacking on preloading md-settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: to show dave Created 4 years, 4 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return URLDataSource::GetContentSecurityPolicyObjectSrc(); 67 return URLDataSource::GetContentSecurityPolicyObjectSrc();
68 } 68 }
69 std::string GetContentSecurityPolicyChildSrc() const override { 69 std::string GetContentSecurityPolicyChildSrc() const override {
70 if (parent_->frame_src_set_) 70 if (parent_->frame_src_set_)
71 return parent_->frame_src_; 71 return parent_->frame_src_;
72 return URLDataSource::GetContentSecurityPolicyChildSrc(); 72 return URLDataSource::GetContentSecurityPolicyChildSrc();
73 } 73 }
74 bool ShouldDenyXFrameOptions() const override { 74 bool ShouldDenyXFrameOptions() const override {
75 return parent_->deny_xframe_options_; 75 return parent_->deny_xframe_options_;
76 } 76 }
77 std::vector<std::string> GetPreloadHeaders() const override {
78 return parent_->preload_headers_;
79 }
77 80
78 private: 81 private:
79 WebUIDataSourceImpl* parent_; 82 WebUIDataSourceImpl* parent_;
80 }; 83 };
81 84
82 WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name) 85 WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name)
83 : URLDataSourceImpl(source_name, new InternalDataSource(this)), 86 : URLDataSourceImpl(source_name, new InternalDataSource(this)),
84 source_name_(source_name), 87 source_name_(source_name),
85 default_resource_(-1), 88 default_resource_(-1),
86 add_csp_(true), 89 add_csp_(true),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 151
149 void WebUIDataSourceImpl::SetDefaultResource(int resource_id) { 152 void WebUIDataSourceImpl::SetDefaultResource(int resource_id) {
150 default_resource_ = resource_id; 153 default_resource_ = resource_id;
151 } 154 }
152 155
153 void WebUIDataSourceImpl::SetRequestFilter( 156 void WebUIDataSourceImpl::SetRequestFilter(
154 const WebUIDataSource::HandleRequestCallback& callback) { 157 const WebUIDataSource::HandleRequestCallback& callback) {
155 filter_callback_ = callback; 158 filter_callback_ = callback;
156 } 159 }
157 160
161 void WebUIDataSourceImpl::AddPreloadHeader(const std::string& preload_header) {
162 preload_headers_.push_back(preload_header);
163 }
164
158 void WebUIDataSourceImpl::DisableReplaceExistingSource() { 165 void WebUIDataSourceImpl::DisableReplaceExistingSource() {
159 replace_existing_source_ = false; 166 replace_existing_source_ = false;
160 } 167 }
161 168
162 void WebUIDataSourceImpl::DisableContentSecurityPolicy() { 169 void WebUIDataSourceImpl::DisableContentSecurityPolicy() {
163 add_csp_ = false; 170 add_csp_ = false;
164 } 171 }
165 172
166 void WebUIDataSourceImpl::OverrideContentSecurityPolicyObjectSrc( 173 void WebUIDataSourceImpl::OverrideContentSecurityPolicyObjectSrc(
167 const std::string& data) { 174 const std::string& data) {
168 object_src_set_ = true; 175 object_src_set_ = true;
169 object_src_ = data; 176 object_src_ = data;
170 } 177 }
171 178
172 void WebUIDataSourceImpl::OverrideContentSecurityPolicyChildSrc( 179 void WebUIDataSourceImpl::OverrideContentSecurityPolicyChildSrc(
173 const std::string& data) { 180 const std::string& data) {
174 frame_src_set_ = true; 181 frame_src_set_ = true;
175 frame_src_ = data; 182 frame_src_ = data;
176 } 183 }
177 184
178 void WebUIDataSourceImpl::DisableDenyXFrameOptions() { 185 void WebUIDataSourceImpl::DisableDenyXFrameOptions() {
179 deny_xframe_options_ = false; 186 deny_xframe_options_ = false;
180 } 187 }
181 188
189 const std::map<std::string, int>& WebUIDataSourceImpl::path_to_idr_map() const {
190 return path_to_idr_map_;
191 }
192
182 std::string WebUIDataSourceImpl::GetSource() const { 193 std::string WebUIDataSourceImpl::GetSource() const {
183 return source_name_; 194 return source_name_;
184 } 195 }
185 196
186 std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const { 197 std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const {
187 // Remove the query string for to determine the mime type. 198 // Remove the query string for to determine the mime type.
188 std::string file_path = path.substr(0, path.find_first_of('?')); 199 std::string file_path = path.substr(0, path.find_first_of('?'));
189 200
190 if (base::EndsWith(file_path, ".css", base::CompareCase::INSENSITIVE_ASCII)) 201 if (base::EndsWith(file_path, ".css", base::CompareCase::INSENSITIVE_ASCII))
191 return "text/css"; 202 return "text/css";
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 263 }
253 264
254 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( 265 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON(
255 const URLDataSource::GotDataCallback& callback) { 266 const URLDataSource::GotDataCallback& callback) {
256 std::string template_data; 267 std::string template_data;
257 webui::AppendJsonJS(&localized_strings_, &template_data); 268 webui::AppendJsonJS(&localized_strings_, &template_data);
258 callback.Run(base::RefCountedString::TakeString(&template_data)); 269 callback.Run(base::RefCountedString::TakeString(&template_data));
259 } 270 }
260 271
261 } // namespace content 272 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.h ('k') | content/public/browser/url_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698