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 <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void ManifestHandler::FinalizeRegistration() { | 72 void ManifestHandler::FinalizeRegistration() { |
73 GetRegistry()->Finalize(); | 73 GetRegistry()->Finalize(); |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 bool ManifestHandler::IsRegistrationFinalized() { | 77 bool ManifestHandler::IsRegistrationFinalized() { |
78 return GetRegistry()->is_finalized_; | 78 return GetRegistry()->is_finalized_; |
79 } | 79 } |
80 | 80 |
81 // static | 81 // static |
82 bool ManifestHandler::ParseExtension(Extension* extension, string16* error) { | 82 bool ManifestHandler::ParseExtension(Extension* extension, |
| 83 base::string16* error) { |
83 return GetRegistry()->ParseExtension(extension, error); | 84 return GetRegistry()->ParseExtension(extension, error); |
84 } | 85 } |
85 | 86 |
86 // static | 87 // static |
87 bool ManifestHandler::ValidateExtension(const Extension* extension, | 88 bool ManifestHandler::ValidateExtension(const Extension* extension, |
88 std::string* error, | 89 std::string* error, |
89 std::vector<InstallWarning>* warnings) { | 90 std::vector<InstallWarning>* warnings) { |
90 return GetRegistry()->ValidateExtension(extension, error, warnings); | 91 return GetRegistry()->ValidateExtension(extension, error, warnings); |
91 } | 92 } |
92 | 93 |
(...skipping 27 matching lines...) Expand all Loading... |
120 is_finalized_ = true; | 121 is_finalized_ = true; |
121 } | 122 } |
122 | 123 |
123 void ManifestHandlerRegistry::RegisterManifestHandler( | 124 void ManifestHandlerRegistry::RegisterManifestHandler( |
124 const std::string& key, linked_ptr<ManifestHandler> handler) { | 125 const std::string& key, linked_ptr<ManifestHandler> handler) { |
125 CHECK(!is_finalized_); | 126 CHECK(!is_finalized_); |
126 handlers_[key] = handler; | 127 handlers_[key] = handler; |
127 } | 128 } |
128 | 129 |
129 bool ManifestHandlerRegistry::ParseExtension(Extension* extension, | 130 bool ManifestHandlerRegistry::ParseExtension(Extension* extension, |
130 string16* error) { | 131 base::string16* error) { |
131 std::map<int, ManifestHandler*> handlers_by_priority; | 132 std::map<int, ManifestHandler*> handlers_by_priority; |
132 for (ManifestHandlerMap::iterator iter = handlers_.begin(); | 133 for (ManifestHandlerMap::iterator iter = handlers_.begin(); |
133 iter != handlers_.end(); ++iter) { | 134 iter != handlers_.end(); ++iter) { |
134 ManifestHandler* handler = iter->second.get(); | 135 ManifestHandler* handler = iter->second.get(); |
135 if (extension->manifest()->HasPath(iter->first) || | 136 if (extension->manifest()->HasPath(iter->first) || |
136 handler->AlwaysParseForType(extension->GetType())) { | 137 handler->AlwaysParseForType(extension->GetType())) { |
137 handlers_by_priority[priority_map_[handler]] = handler; | 138 handlers_by_priority[priority_map_[handler]] = handler; |
138 } | 139 } |
139 } | 140 } |
140 for (std::map<int, ManifestHandler*>::iterator iter = | 141 for (std::map<int, ManifestHandler*>::iterator iter = |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 unsorted_handlers.swap(next_unsorted_handlers); | 241 unsorted_handlers.swap(next_unsorted_handlers); |
241 } | 242 } |
242 | 243 |
243 // If there are any leftover unsorted handlers, they must have had | 244 // If there are any leftover unsorted handlers, they must have had |
244 // circular dependencies. | 245 // circular dependencies. |
245 CHECK(unsorted_handlers.size() == 0) << "Extension manifest handlers have " | 246 CHECK(unsorted_handlers.size() == 0) << "Extension manifest handlers have " |
246 << "circular dependencies!"; | 247 << "circular dependencies!"; |
247 } | 248 } |
248 | 249 |
249 } // namespace extensions | 250 } // namespace extensions |
OLD | NEW |