| 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 17 matching lines...) Expand all Loading... |
| 28 // URLDataSource. | 28 // URLDataSource. |
| 29 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { | 29 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { |
| 30 public: | 30 public: |
| 31 InternalDataSource(WebUIDataSourceImpl* parent) : parent_(parent) { | 31 InternalDataSource(WebUIDataSourceImpl* parent) : parent_(parent) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual ~InternalDataSource() { | 34 virtual ~InternalDataSource() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 // URLDataSource implementation. | 37 // URLDataSource implementation. |
| 38 virtual std::string GetSource() OVERRIDE { | 38 virtual std::string GetSource() const OVERRIDE { |
| 39 return parent_->GetSource(); | 39 return parent_->GetSource(); |
| 40 } | 40 } |
| 41 virtual std::string GetMimeType(const std::string& path) const OVERRIDE { | 41 virtual std::string GetMimeType(const std::string& path) const OVERRIDE { |
| 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 bool is_incognito, | 46 bool is_incognito, |
| 47 const URLDataSource::GotDataCallback& callback) OVERRIDE { | 47 const URLDataSource::GotDataCallback& callback) OVERRIDE { |
| 48 return parent_->StartDataRequest(path, is_incognito, callback); | 48 return parent_->StartDataRequest(path, is_incognito, callback); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void WebUIDataSourceImpl::OverrideContentSecurityPolicyFrameSrc( | 145 void WebUIDataSourceImpl::OverrideContentSecurityPolicyFrameSrc( |
| 146 const std::string& data) { | 146 const std::string& data) { |
| 147 frame_src_set_ = true; | 147 frame_src_set_ = true; |
| 148 frame_src_ = data; | 148 frame_src_ = data; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void WebUIDataSourceImpl::DisableDenyXFrameOptions() { | 151 void WebUIDataSourceImpl::DisableDenyXFrameOptions() { |
| 152 deny_xframe_options_ = false; | 152 deny_xframe_options_ = false; |
| 153 } | 153 } |
| 154 | 154 |
| 155 std::string WebUIDataSourceImpl::GetSource() { | 155 std::string WebUIDataSourceImpl::GetSource() const { |
| 156 return source_name_; | 156 return source_name_; |
| 157 } | 157 } |
| 158 | 158 |
| 159 std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const { | 159 std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const { |
| 160 if (EndsWith(path, ".js", false)) | 160 if (EndsWith(path, ".js", false)) |
| 161 return "application/javascript"; | 161 return "application/javascript"; |
| 162 | 162 |
| 163 if (EndsWith(path, ".json", false)) | 163 if (EndsWith(path, ".json", false)) |
| 164 return "application/json"; | 164 return "application/json"; |
| 165 | 165 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 207 } |
| 208 | 208 |
| 209 void WebUIDataSourceImpl::SendFromResourceBundle( | 209 void WebUIDataSourceImpl::SendFromResourceBundle( |
| 210 const URLDataSource::GotDataCallback& callback, int idr) { | 210 const URLDataSource::GotDataCallback& callback, int idr) { |
| 211 scoped_refptr<base::RefCountedStaticMemory> response( | 211 scoped_refptr<base::RefCountedStaticMemory> response( |
| 212 GetContentClient()->GetDataResourceBytes(idr)); | 212 GetContentClient()->GetDataResourceBytes(idr)); |
| 213 callback.Run(response); | 213 callback.Run(response); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace content | 216 } // namespace content |
| OLD | NEW |