| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "extensions/common/manifest_handler.h" | 5 #include "extensions/common/manifest_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 void ManifestHandlerRegistry::RegisterManifestHandler( | 126 void ManifestHandlerRegistry::RegisterManifestHandler( |
| 127 const std::string& key, linked_ptr<ManifestHandler> handler) { | 127 const std::string& key, linked_ptr<ManifestHandler> handler) { |
| 128 CHECK(!is_finalized_); | 128 CHECK(!is_finalized_); |
| 129 handlers_[key] = handler; | 129 handlers_[key] = handler; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool ManifestHandlerRegistry::ParseExtension(Extension* extension, | 132 bool ManifestHandlerRegistry::ParseExtension(Extension* extension, |
| 133 base::string16* error) { | 133 base::string16* error) { |
| 134 LOG(ERROR) << "ParseExtension " << extension->id(); |
| 134 std::map<int, ManifestHandler*> handlers_by_priority; | 135 std::map<int, ManifestHandler*> handlers_by_priority; |
| 135 for (ManifestHandlerMap::iterator iter = handlers_.begin(); | 136 for (ManifestHandlerMap::iterator iter = handlers_.begin(); |
| 136 iter != handlers_.end(); ++iter) { | 137 iter != handlers_.end(); ++iter) { |
| 137 ManifestHandler* handler = iter->second.get(); | 138 ManifestHandler* handler = iter->second.get(); |
| 138 if (extension->manifest()->HasPath(iter->first) || | 139 if (extension->manifest()->HasPath(iter->first) || |
| 139 handler->AlwaysParseForType(extension->GetType())) { | 140 handler->AlwaysParseForType(extension->GetType())) { |
| 141 LOG(ERROR) << "ParseExtension " << extension->id() << " using handler " |
| 142 << iter->first; |
| 140 handlers_by_priority[priority_map_[handler]] = handler; | 143 handlers_by_priority[priority_map_[handler]] = handler; |
| 144 } else { |
| 145 LOG(ERROR) << "ParseExtension " << extension->id() << " skip handler " |
| 146 << iter->first; |
| 141 } | 147 } |
| 142 } | 148 } |
| 143 for (std::map<int, ManifestHandler*>::iterator iter = | 149 for (std::map<int, ManifestHandler*>::iterator iter = |
| 144 handlers_by_priority.begin(); | 150 handlers_by_priority.begin(); |
| 145 iter != handlers_by_priority.end(); ++iter) { | 151 iter != handlers_by_priority.end(); ++iter) { |
| 146 if (!(iter->second)->Parse(extension, error)) | 152 if (!(iter->second)->Parse(extension, error)) |
| 147 return false; | 153 return false; |
| 148 } | 154 } |
| 149 return true; | 155 return true; |
| 150 } | 156 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 unsorted_handlers.swap(next_unsorted_handlers); | 249 unsorted_handlers.swap(next_unsorted_handlers); |
| 244 } | 250 } |
| 245 | 251 |
| 246 // If there are any leftover unsorted handlers, they must have had | 252 // If there are any leftover unsorted handlers, they must have had |
| 247 // circular dependencies. | 253 // circular dependencies. |
| 248 CHECK_EQ(unsorted_handlers.size(), std::set<ManifestHandler*>::size_type(0)) | 254 CHECK_EQ(unsorted_handlers.size(), std::set<ManifestHandler*>::size_type(0)) |
| 249 << "Extension manifest handlers have circular dependencies!"; | 255 << "Extension manifest handlers have circular dependencies!"; |
| 250 } | 256 } |
| 251 | 257 |
| 252 } // namespace extensions | 258 } // namespace extensions |
| OLD | NEW |