| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 // URLDataSource implementation. | 37 // URLDataSource implementation. |
| 38 virtual std::string GetSource() OVERRIDE { | 38 virtual std::string GetSource() 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 const URLDataSource::ExtraRequestInfo& info, |
| 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, info, callback); |
| 49 } | 49 } |
| 50 virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { | 50 virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { |
| 51 return parent_->add_csp_; | 51 return parent_->add_csp_; |
| 52 } | 52 } |
| 53 virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE { | 53 virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE { |
| 54 if (parent_->object_src_set_) | 54 if (parent_->object_src_set_) |
| 55 return parent_->object_src_; | 55 return parent_->object_src_; |
| 56 return URLDataSource::GetContentSecurityPolicyObjectSrc(); | 56 return URLDataSource::GetContentSecurityPolicyObjectSrc(); |
| 57 } | 57 } |
| 58 virtual std::string GetContentSecurityPolicyFrameSrc() const OVERRIDE { | 58 virtual std::string GetContentSecurityPolicyFrameSrc() const OVERRIDE { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return "application/json"; | 164 return "application/json"; |
| 165 | 165 |
| 166 if (EndsWith(path, ".pdf", false)) | 166 if (EndsWith(path, ".pdf", false)) |
| 167 return "application/pdf"; | 167 return "application/pdf"; |
| 168 | 168 |
| 169 return "text/html"; | 169 return "text/html"; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void WebUIDataSourceImpl::StartDataRequest( | 172 void WebUIDataSourceImpl::StartDataRequest( |
| 173 const std::string& path, | 173 const std::string& path, |
| 174 bool is_incognito, | 174 const URLDataSource::ExtraRequestInfo& info, |
| 175 const URLDataSource::GotDataCallback& callback) { | 175 const URLDataSource::GotDataCallback& callback) { |
| 176 if (!filter_callback_.is_null() && | 176 if (!filter_callback_.is_null() && |
| 177 filter_callback_.Run(path, callback)) { | 177 filter_callback_.Run(path, callback)) { |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 | 180 |
| 181 if (!json_path_.empty() && path == json_path_) { | 181 if (!json_path_.empty() && path == json_path_) { |
| 182 SendLocalizedStringsAsJSON(callback); | 182 SendLocalizedStringsAsJSON(callback); |
| 183 return; | 183 return; |
| 184 } | 184 } |
| (...skipping 22 matching lines...) Expand all 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 |