| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 URLDataManager::AddWebUIDataSource(browser_context, source); | 52 URLDataManager::AddWebUIDataSource(browser_context, source); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Internal class to hide the fact that WebUIDataSourceImpl implements | 55 // Internal class to hide the fact that WebUIDataSourceImpl implements |
| 56 // URLDataSource. | 56 // URLDataSource. |
| 57 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { | 57 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { |
| 58 public: | 58 public: |
| 59 InternalDataSource(WebUIDataSourceImpl* parent) : parent_(parent) { | 59 InternalDataSource(WebUIDataSourceImpl* parent) : parent_(parent) { |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual ~InternalDataSource() { | 62 ~InternalDataSource() override {} |
| 63 } | |
| 64 | 63 |
| 65 // URLDataSource implementation. | 64 // URLDataSource implementation. |
| 66 virtual std::string GetSource() const override { | 65 std::string GetSource() const override { return parent_->GetSource(); } |
| 67 return parent_->GetSource(); | 66 std::string GetMimeType(const std::string& path) const override { |
| 68 } | |
| 69 virtual std::string GetMimeType(const std::string& path) const override { | |
| 70 return parent_->GetMimeType(path); | 67 return parent_->GetMimeType(path); |
| 71 } | 68 } |
| 72 virtual void StartDataRequest( | 69 void StartDataRequest( |
| 73 const std::string& path, | 70 const std::string& path, |
| 74 int render_process_id, | 71 int render_process_id, |
| 75 int render_frame_id, | 72 int render_frame_id, |
| 76 const URLDataSource::GotDataCallback& callback) override { | 73 const URLDataSource::GotDataCallback& callback) override { |
| 77 return parent_->StartDataRequest(path, render_process_id, render_frame_id, | 74 return parent_->StartDataRequest(path, render_process_id, render_frame_id, |
| 78 callback); | 75 callback); |
| 79 } | 76 } |
| 80 virtual bool ShouldReplaceExistingSource() const override { | 77 bool ShouldReplaceExistingSource() const override { |
| 81 return parent_->replace_existing_source_; | 78 return parent_->replace_existing_source_; |
| 82 } | 79 } |
| 83 virtual bool AllowCaching() const override { | 80 bool AllowCaching() const override { return false; } |
| 84 return false; | 81 bool ShouldAddContentSecurityPolicy() const override { |
| 85 } | |
| 86 virtual bool ShouldAddContentSecurityPolicy() const override { | |
| 87 return parent_->add_csp_; | 82 return parent_->add_csp_; |
| 88 } | 83 } |
| 89 virtual std::string GetContentSecurityPolicyObjectSrc() const override { | 84 std::string GetContentSecurityPolicyObjectSrc() const override { |
| 90 if (parent_->object_src_set_) | 85 if (parent_->object_src_set_) |
| 91 return parent_->object_src_; | 86 return parent_->object_src_; |
| 92 return URLDataSource::GetContentSecurityPolicyObjectSrc(); | 87 return URLDataSource::GetContentSecurityPolicyObjectSrc(); |
| 93 } | 88 } |
| 94 virtual std::string GetContentSecurityPolicyFrameSrc() const override { | 89 std::string GetContentSecurityPolicyFrameSrc() const override { |
| 95 if (parent_->frame_src_set_) | 90 if (parent_->frame_src_set_) |
| 96 return parent_->frame_src_; | 91 return parent_->frame_src_; |
| 97 return URLDataSource::GetContentSecurityPolicyFrameSrc(); | 92 return URLDataSource::GetContentSecurityPolicyFrameSrc(); |
| 98 } | 93 } |
| 99 virtual bool ShouldDenyXFrameOptions() const override { | 94 bool ShouldDenyXFrameOptions() const override { |
| 100 return parent_->deny_xframe_options_; | 95 return parent_->deny_xframe_options_; |
| 101 } | 96 } |
| 102 | 97 |
| 103 private: | 98 private: |
| 104 WebUIDataSourceImpl* parent_; | 99 WebUIDataSourceImpl* parent_; |
| 105 }; | 100 }; |
| 106 | 101 |
| 107 WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name) | 102 WebUIDataSourceImpl::WebUIDataSourceImpl(const std::string& source_name) |
| 108 : URLDataSourceImpl( | 103 : URLDataSourceImpl( |
| 109 source_name, | 104 source_name, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 238 } |
| 244 | 239 |
| 245 void WebUIDataSourceImpl::SendFromResourceBundle( | 240 void WebUIDataSourceImpl::SendFromResourceBundle( |
| 246 const URLDataSource::GotDataCallback& callback, int idr) { | 241 const URLDataSource::GotDataCallback& callback, int idr) { |
| 247 scoped_refptr<base::RefCountedStaticMemory> response( | 242 scoped_refptr<base::RefCountedStaticMemory> response( |
| 248 GetContentClient()->GetDataResourceBytes(idr)); | 243 GetContentClient()->GetDataResourceBytes(idr)); |
| 249 callback.Run(response.get()); | 244 callback.Run(response.get()); |
| 250 } | 245 } |
| 251 | 246 |
| 252 } // namespace content | 247 } // namespace content |
| OLD | NEW |