| OLD | NEW |
| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 return parent_->GetMimeType(path); | 42 return parent_->GetMimeType(path); |
| 43 } | 43 } |
| 44 virtual void StartDataRequest( | 44 virtual void StartDataRequest( |
| 45 const std::string& path, | 45 const std::string& path, |
| 46 int render_process_id, | 46 int render_process_id, |
| 47 int render_view_id, | 47 int render_view_id, |
| 48 const URLDataSource::GotDataCallback& callback) OVERRIDE { | 48 const URLDataSource::GotDataCallback& callback) OVERRIDE { |
| 49 return parent_->StartDataRequest(path, render_process_id, render_view_id, | 49 return parent_->StartDataRequest(path, render_process_id, render_view_id, |
| 50 callback); | 50 callback); |
| 51 } | 51 } |
| 52 virtual bool ShouldReplaceExistingSource() const OVERRIDE { |
| 53 return parent_->replace_existing_source_; |
| 54 } |
| 52 virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { | 55 virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { |
| 53 return parent_->add_csp_; | 56 return parent_->add_csp_; |
| 54 } | 57 } |
| 55 virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE { | 58 virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE { |
| 56 if (parent_->object_src_set_) | 59 if (parent_->object_src_set_) |
| 57 return parent_->object_src_; | 60 return parent_->object_src_; |
| 58 return URLDataSource::GetContentSecurityPolicyObjectSrc(); | 61 return URLDataSource::GetContentSecurityPolicyObjectSrc(); |
| 59 } | 62 } |
| 60 virtual std::string GetContentSecurityPolicyFrameSrc() const OVERRIDE { | 63 virtual std::string GetContentSecurityPolicyFrameSrc() const OVERRIDE { |
| 61 if (parent_->frame_src_set_) | 64 if (parent_->frame_src_set_) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 : URLDataSourceImpl( | 77 : URLDataSourceImpl( |
| 75 source_name, | 78 source_name, |
| 76 new InternalDataSource(this)), | 79 new InternalDataSource(this)), |
| 77 source_name_(source_name), | 80 source_name_(source_name), |
| 78 default_resource_(-1), | 81 default_resource_(-1), |
| 79 json_js_format_v2_(false), | 82 json_js_format_v2_(false), |
| 80 add_csp_(true), | 83 add_csp_(true), |
| 81 object_src_set_(false), | 84 object_src_set_(false), |
| 82 frame_src_set_(false), | 85 frame_src_set_(false), |
| 83 deny_xframe_options_(true), | 86 deny_xframe_options_(true), |
| 84 disable_set_font_strings_(false) { | 87 disable_set_font_strings_(false), |
| 88 replace_existing_source_(true) { |
| 85 } | 89 } |
| 86 | 90 |
| 87 WebUIDataSourceImpl::~WebUIDataSourceImpl() { | 91 WebUIDataSourceImpl::~WebUIDataSourceImpl() { |
| 88 } | 92 } |
| 89 | 93 |
| 90 void WebUIDataSourceImpl::AddString(const std::string& name, | 94 void WebUIDataSourceImpl::AddString(const std::string& name, |
| 91 const string16& value) { | 95 const string16& value) { |
| 92 localized_strings_.SetString(name, value); | 96 localized_strings_.SetString(name, value); |
| 93 } | 97 } |
| 94 | 98 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 131 |
| 128 void WebUIDataSourceImpl::SetDefaultResource(int resource_id) { | 132 void WebUIDataSourceImpl::SetDefaultResource(int resource_id) { |
| 129 default_resource_ = resource_id; | 133 default_resource_ = resource_id; |
| 130 } | 134 } |
| 131 | 135 |
| 132 void WebUIDataSourceImpl::SetRequestFilter( | 136 void WebUIDataSourceImpl::SetRequestFilter( |
| 133 const WebUIDataSource::HandleRequestCallback& callback) { | 137 const WebUIDataSource::HandleRequestCallback& callback) { |
| 134 filter_callback_ = callback; | 138 filter_callback_ = callback; |
| 135 } | 139 } |
| 136 | 140 |
| 141 void WebUIDataSourceImpl::DisableReplaceExistingSource() { |
| 142 replace_existing_source_ = false; |
| 143 } |
| 144 |
| 137 void WebUIDataSourceImpl::DisableContentSecurityPolicy() { | 145 void WebUIDataSourceImpl::DisableContentSecurityPolicy() { |
| 138 add_csp_ = false; | 146 add_csp_ = false; |
| 139 } | 147 } |
| 140 | 148 |
| 141 void WebUIDataSourceImpl::OverrideContentSecurityPolicyObjectSrc( | 149 void WebUIDataSourceImpl::OverrideContentSecurityPolicyObjectSrc( |
| 142 const std::string& data) { | 150 const std::string& data) { |
| 143 object_src_set_ = true; | 151 object_src_set_ = true; |
| 144 object_src_ = data; | 152 object_src_ = data; |
| 145 } | 153 } |
| 146 | 154 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 218 } |
| 211 | 219 |
| 212 void WebUIDataSourceImpl::SendFromResourceBundle( | 220 void WebUIDataSourceImpl::SendFromResourceBundle( |
| 213 const URLDataSource::GotDataCallback& callback, int idr) { | 221 const URLDataSource::GotDataCallback& callback, int idr) { |
| 214 scoped_refptr<base::RefCountedStaticMemory> response( | 222 scoped_refptr<base::RefCountedStaticMemory> response( |
| 215 GetContentClient()->GetDataResourceBytes(idr)); | 223 GetContentClient()->GetDataResourceBytes(idr)); |
| 216 callback.Run(response.get()); | 224 callback.Run(response.get()); |
| 217 } | 225 } |
| 218 | 226 |
| 219 } // namespace content | 227 } // namespace content |
| OLD | NEW |