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/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 NOTREACHED() << "Redefinition of '" << path << "'"; | 40 NOTREACHED() << "Redefinition of '" << path << "'"; |
41 } | 41 } |
42 | 42 |
43 const ResourcesMap* CreateResourcesMap() { | 43 const ResourcesMap* CreateResourcesMap() { |
44 ResourcesMap* result = new ResourcesMap(); | 44 ResourcesMap* result = new ResourcesMap(); |
45 for (size_t i = 0; i < kWebuiResourcesSize; ++i) { | 45 for (size_t i = 0; i < kWebuiResourcesSize; ++i) { |
46 const std::string resource_name = kWebuiResources[i].name; | 46 const std::string resource_name = kWebuiResources[i].name; |
47 const int resource_id = kWebuiResources[i].value; | 47 const int resource_id = kWebuiResources[i].value; |
48 AddResource(resource_name, resource_id, result); | 48 AddResource(resource_name, resource_id, result); |
49 for (const char* (&alias)[2]: kPathAliases) { | 49 for (const char* (&alias)[2]: kPathAliases) { |
50 if (base::StartsWithASCII(resource_name, alias[0], true)) { | 50 if (base::StartsWith(resource_name, alias[0], |
| 51 base::CompareCase::SENSITIVE)) { |
51 AddResource(alias[1] + resource_name.substr(strlen(alias[0])), | 52 AddResource(alias[1] + resource_name.substr(strlen(alias[0])), |
52 resource_id, result); | 53 resource_id, result); |
53 } | 54 } |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 return result; | 58 return result; |
58 } | 59 } |
59 | 60 |
60 const ResourcesMap& GetResourcesMap() { | 61 const ResourcesMap& GetResourcesMap() { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // wildcards, so we need to set its value explicitly by passing the |origin| | 116 // wildcards, so we need to set its value explicitly by passing the |origin| |
116 // back. | 117 // back. |
117 std::string allowed_origin_prefix = kChromeUIScheme; | 118 std::string allowed_origin_prefix = kChromeUIScheme; |
118 allowed_origin_prefix += "://"; | 119 allowed_origin_prefix += "://"; |
119 if (origin.find(allowed_origin_prefix) != 0) | 120 if (origin.find(allowed_origin_prefix) != 0) |
120 return "null"; | 121 return "null"; |
121 return origin; | 122 return origin; |
122 } | 123 } |
123 | 124 |
124 } // namespace content | 125 } // namespace content |
OLD | NEW |