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/shared_resources_data_source.h" | 5 #include "content/browser/webui/shared_resources_data_source.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 std::string SharedResourcesDataSource::GetMimeType( | 82 std::string SharedResourcesDataSource::GetMimeType( |
83 const std::string& path) const { | 83 const std::string& path) const { |
84 // Requests should not block on the disk! On POSIX this goes to disk. | 84 // Requests should not block on the disk! On POSIX this goes to disk. |
85 // http://code.google.com/p/chromium/issues/detail?id=59849 | 85 // http://code.google.com/p/chromium/issues/detail?id=59849 |
86 | 86 |
87 base::ThreadRestrictions::ScopedAllowIO allow_io; | 87 base::ThreadRestrictions::ScopedAllowIO allow_io; |
88 std::string mime_type; | 88 std::string mime_type; |
89 net::GetMimeTypeFromFile(base::FilePath().AppendASCII(path), &mime_type); | 89 net::GetMimeTypeFromFile(base::FilePath().AppendASCII(path), &mime_type); |
90 return mime_type; | 90 return mime_type; |
91 } | 91 } |
| 92 |
| 93 std::string |
| 94 SharedResourcesDataSource::GetAccessControlAllowOriginForOrigin( |
| 95 const std::string& origin) const { |
| 96 // For now we give access only for "chrome://*" origins. |
| 97 // According to CORS spec, Access-Control-Allow-Origin header doesn't support |
| 98 // wildcards, so we need to set its value explicitly by passing the |origin| |
| 99 // back. |
| 100 std::string allowed_origin_prefix = content::kChromeUIScheme; |
| 101 allowed_origin_prefix += "://"; |
| 102 if (origin.find(allowed_origin_prefix) != 0) |
| 103 return "none"; |
| 104 return origin; |
| 105 } |
OLD | NEW |