| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/web/webui/web_ui_ios_data_source_impl.h" | 5 #include "ios/web/webui/web_ui_ios_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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 void WebUIIOSDataSourceImpl::DisableDenyXFrameOptions() { | 103 void WebUIIOSDataSourceImpl::DisableDenyXFrameOptions() { |
| 104 deny_xframe_options_ = false; | 104 deny_xframe_options_ = false; |
| 105 } | 105 } |
| 106 | 106 |
| 107 std::string WebUIIOSDataSourceImpl::GetSource() const { | 107 std::string WebUIIOSDataSourceImpl::GetSource() const { |
| 108 return source_name_; | 108 return source_name_; |
| 109 } | 109 } |
| 110 | 110 |
| 111 std::string WebUIIOSDataSourceImpl::GetMimeType(const std::string& path) const { | 111 std::string WebUIIOSDataSourceImpl::GetMimeType(const std::string& path) const { |
| 112 if (EndsWith(path, ".js", false)) | 112 if (base::EndsWith(path, ".js", false)) |
| 113 return "application/javascript"; | 113 return "application/javascript"; |
| 114 | 114 |
| 115 if (EndsWith(path, ".json", false)) | 115 if (base::EndsWith(path, ".json", false)) |
| 116 return "application/json"; | 116 return "application/json"; |
| 117 | 117 |
| 118 if (EndsWith(path, ".pdf", false)) | 118 if (base::EndsWith(path, ".pdf", false)) |
| 119 return "application/pdf"; | 119 return "application/pdf"; |
| 120 | 120 |
| 121 if (EndsWith(path, ".css", false)) | 121 if (base::EndsWith(path, ".css", false)) |
| 122 return "text/css"; | 122 return "text/css"; |
| 123 | 123 |
| 124 if (EndsWith(path, ".svg", false)) | 124 if (base::EndsWith(path, ".svg", false)) |
| 125 return "image/svg+xml"; | 125 return "image/svg+xml"; |
| 126 | 126 |
| 127 return "text/html"; | 127 return "text/html"; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void WebUIIOSDataSourceImpl::StartDataRequest( | 130 void WebUIIOSDataSourceImpl::StartDataRequest( |
| 131 const std::string& path, | 131 const std::string& path, |
| 132 const URLDataSourceIOS::GotDataCallback& callback) { | 132 const URLDataSourceIOS::GotDataCallback& callback) { |
| 133 if (!json_path_.empty() && path == json_path_) { | 133 if (!json_path_.empty() && path == json_path_) { |
| 134 SendLocalizedStringsAsJSON(callback); | 134 SendLocalizedStringsAsJSON(callback); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 158 | 158 |
| 159 void WebUIIOSDataSourceImpl::SendFromResourceBundle( | 159 void WebUIIOSDataSourceImpl::SendFromResourceBundle( |
| 160 const URLDataSourceIOS::GotDataCallback& callback, | 160 const URLDataSourceIOS::GotDataCallback& callback, |
| 161 int idr) { | 161 int idr) { |
| 162 scoped_refptr<base::RefCountedStaticMemory> response( | 162 scoped_refptr<base::RefCountedStaticMemory> response( |
| 163 GetWebClient()->GetDataResourceBytes(idr)); | 163 GetWebClient()->GetDataResourceBytes(idr)); |
| 164 callback.Run(response.get()); | 164 callback.Run(response.get()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace web | 167 } // namespace web |
| OLD | NEW |