| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { | 28 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { |
| 29 return new WebUIDataSourceImpl(source_name); | 29 return new WebUIDataSourceImpl(source_name); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 void WebUIDataSource::Add(BrowserContext* browser_context, | 33 void WebUIDataSource::Add(BrowserContext* browser_context, |
| 34 WebUIDataSource* source) { | 34 WebUIDataSource* source) { |
| 35 URLDataManager::AddWebUIDataSource(browser_context, source); | 35 URLDataManager::AddWebUIDataSource(browser_context, source); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // static |
| 39 void WebUIDataSource::Update(BrowserContext* browser_context, |
| 40 const std::string& source_name, |
| 41 std::unique_ptr<base::DictionaryValue> update) { |
| 42 URLDataManager::UpdateWebUIDataSource(browser_context, source_name, |
| 43 std::move(update)); |
| 44 } |
| 45 |
| 38 // Internal class to hide the fact that WebUIDataSourceImpl implements | 46 // Internal class to hide the fact that WebUIDataSourceImpl implements |
| 39 // URLDataSource. | 47 // URLDataSource. |
| 40 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { | 48 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { |
| 41 public: | 49 public: |
| 42 explicit InternalDataSource(WebUIDataSourceImpl* parent) : parent_(parent) {} | 50 explicit InternalDataSource(WebUIDataSourceImpl* parent) : parent_(parent) {} |
| 43 | 51 |
| 44 ~InternalDataSource() override {} | 52 ~InternalDataSource() override {} |
| 45 | 53 |
| 46 // URLDataSource implementation. | 54 // URLDataSource implementation. |
| 47 std::string GetSource() const override { return parent_->GetSource(); } | 55 std::string GetSource() const override { return parent_->GetSource(); } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 177 } |
| 170 | 178 |
| 171 void WebUIDataSourceImpl::DisableReplaceExistingSource() { | 179 void WebUIDataSourceImpl::DisableReplaceExistingSource() { |
| 172 replace_existing_source_ = false; | 180 replace_existing_source_ = false; |
| 173 } | 181 } |
| 174 | 182 |
| 175 void WebUIDataSourceImpl::ExcludePathFromGzip(const std::string& path) { | 183 void WebUIDataSourceImpl::ExcludePathFromGzip(const std::string& path) { |
| 176 excluded_paths_.insert(path); | 184 excluded_paths_.insert(path); |
| 177 } | 185 } |
| 178 | 186 |
| 187 bool WebUIDataSourceImpl::IsWebUIDataSourceImpl() const { |
| 188 return true; |
| 189 } |
| 190 |
| 179 void WebUIDataSourceImpl::DisableContentSecurityPolicy() { | 191 void WebUIDataSourceImpl::DisableContentSecurityPolicy() { |
| 180 add_csp_ = false; | 192 add_csp_ = false; |
| 181 } | 193 } |
| 182 | 194 |
| 183 void WebUIDataSourceImpl::OverrideContentSecurityPolicyObjectSrc( | 195 void WebUIDataSourceImpl::OverrideContentSecurityPolicyObjectSrc( |
| 184 const std::string& data) { | 196 const std::string& data) { |
| 185 object_src_set_ = true; | 197 object_src_set_ = true; |
| 186 object_src_ = data; | 198 object_src_ = data; |
| 187 } | 199 } |
| 188 | 200 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 286 } |
| 275 | 287 |
| 276 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( | 288 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( |
| 277 const URLDataSource::GotDataCallback& callback) { | 289 const URLDataSource::GotDataCallback& callback) { |
| 278 std::string template_data; | 290 std::string template_data; |
| 279 webui::AppendJsonJS(&localized_strings_, &template_data); | 291 webui::AppendJsonJS(&localized_strings_, &template_data); |
| 280 callback.Run(base::RefCountedString::TakeString(&template_data)); | 292 callback.Run(base::RefCountedString::TakeString(&template_data)); |
| 281 } | 293 } |
| 282 | 294 |
| 283 } // namespace content | 295 } // namespace content |
| OLD | NEW |