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 "chrome/common/extensions/api/extension_api.h" | 5 #include "chrome/common/extensions/api/extension_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 void ExtensionAPI::LoadSchema(const std::string& name, | 199 void ExtensionAPI::LoadSchema(const std::string& name, |
200 const base::StringPiece& schema) { | 200 const base::StringPiece& schema) { |
201 scoped_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema)); | 201 scoped_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema)); |
202 std::string schema_namespace; | 202 std::string schema_namespace; |
203 | 203 |
204 while (!schema_list->empty()) { | 204 while (!schema_list->empty()) { |
205 base::DictionaryValue* schema = NULL; | 205 base::DictionaryValue* schema = NULL; |
206 { | 206 { |
207 base::Value* value = NULL; | 207 scoped_ptr<base::Value> value; |
208 schema_list->Remove(schema_list->GetSize() - 1, &value); | 208 schema_list->Remove(schema_list->GetSize() - 1, &value); |
209 CHECK(value->IsType(base::Value::TYPE_DICTIONARY)); | 209 CHECK(value.release()->GetAsDictionary(&schema)); |
210 schema = static_cast<base::DictionaryValue*>(value); | |
211 } | 210 } |
212 | 211 |
213 CHECK(schema->GetString("namespace", &schema_namespace)); | 212 CHECK(schema->GetString("namespace", &schema_namespace)); |
214 PrefixWithNamespace(schema_namespace, schema); | 213 PrefixWithNamespace(schema_namespace, schema); |
215 schemas_[schema_namespace] = make_linked_ptr(schema); | 214 schemas_[schema_namespace] = make_linked_ptr(schema); |
216 if (!GeneratedSchemas::IsGenerated(schema_namespace)) | 215 if (!GeneratedSchemas::IsGenerated(schema_namespace)) |
217 CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace)); | 216 CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace)); |
218 } | 217 } |
219 } | 218 } |
220 | 219 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 break; | 414 break; |
416 | 415 |
417 api_name_candidate = api_name_candidate.substr(0, last_dot_index); | 416 api_name_candidate = api_name_candidate.substr(0, last_dot_index); |
418 } | 417 } |
419 | 418 |
420 *child_name = ""; | 419 *child_name = ""; |
421 return std::string(); | 420 return std::string(); |
422 } | 421 } |
423 | 422 |
424 } // namespace extensions | 423 } // namespace extensions |
OLD | NEW |