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 17 matching lines...) Expand all Loading... |
28 // path to ui/resources instead. | 28 // path to ui/resources instead. |
29 // TODO(rkc): Once we have a separate source for apps, remove this code. | 29 // TODO(rkc): Once we have a separate source for apps, remove this code. |
30 bool AppsRelativePathMatch(const std::string& path, | 30 bool AppsRelativePathMatch(const std::string& path, |
31 const std::string& compareto) { | 31 const std::string& compareto) { |
32 if (StartsWithASCII(path, kAppImagesPath, false)) { | 32 if (StartsWithASCII(path, kAppImagesPath, false)) { |
33 if (compareto == | 33 if (compareto == |
34 (kReplacement + path.substr(arraysize(kAppImagesPath) - 1))) | 34 (kReplacement + path.substr(arraysize(kAppImagesPath) - 1))) |
35 return true; | 35 return true; |
36 } else if (StartsWithASCII(path, kAppImagesPath2x, false)) { | 36 } else if (StartsWithASCII(path, kAppImagesPath2x, false)) { |
37 if (compareto == | 37 if (compareto == |
38 (kReplacement2x + path.substr(arraysize(kAppImagesPath) - 1))) | 38 (kReplacement2x + path.substr(arraysize(kAppImagesPath2x) - 1))) |
39 return true; | 39 return true; |
40 } | 40 } |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 int PathToIDR(const std::string& path) { | 44 int PathToIDR(const std::string& path) { |
45 int idr = -1; | 45 int idr = -1; |
46 for (size_t i = 0; i < kWebuiResourcesSize; ++i) { | 46 for (size_t i = 0; i < kWebuiResourcesSize; ++i) { |
47 if ((path == kWebuiResources[i].name) || | 47 if ((path == kWebuiResources[i].name) || |
48 AppsRelativePathMatch(path, kWebuiResources[i].name)) { | 48 AppsRelativePathMatch(path, kWebuiResources[i].name)) { |
(...skipping 33 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 } |
OLD | NEW |