OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/api/declarative/declarative_manifest_data.h" | 5 #include "extensions/common/api/declarative/declarative_manifest_data.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 }; | 54 }; |
55 | 55 |
56 // Converts a rule defined in the manifest into a JSON internal format. The | 56 // Converts a rule defined in the manifest into a JSON internal format. The |
57 // difference is that actions and conditions use a "type" key to define the | 57 // difference is that actions and conditions use a "type" key to define the |
58 // type of rule/condition, while the internal format uses a "instanceType" key | 58 // type of rule/condition, while the internal format uses a "instanceType" key |
59 // for this. This function walks through all the conditions and rules to swap | 59 // for this. This function walks through all the conditions and rules to swap |
60 // the manifest key for the internal key. | 60 // the manifest key for the internal key. |
61 bool ConvertManifestRule(const linked_ptr<DeclarativeManifestData::Rule>& rule, | 61 bool ConvertManifestRule(const linked_ptr<DeclarativeManifestData::Rule>& rule, |
62 ErrorBuilder* error_builder) { | 62 ErrorBuilder* error_builder) { |
63 auto convert_list = | 63 auto convert_list = |
64 [error_builder](std::vector<linked_ptr<base::Value>>& list) { | 64 [error_builder](std::vector<scoped_ptr<base::Value>>& list) { |
65 for (const linked_ptr<base::Value>& value : list) { | 65 for (const scoped_ptr<base::Value>& value : list) { |
66 base::DictionaryValue* dictionary = nullptr; | 66 base::DictionaryValue* dictionary = nullptr; |
67 if (!value->GetAsDictionary(&dictionary)) { | 67 if (!value->GetAsDictionary(&dictionary)) { |
68 error_builder->Append("expected dictionary, got %s", | 68 error_builder->Append("expected dictionary, got %s", |
69 ValueTypeToString(value.get())); | 69 ValueTypeToString(value.get())); |
70 return false; | 70 return false; |
71 } | 71 } |
72 std::string type; | 72 std::string type; |
73 if (!dictionary->GetString("type", &type)) { | 73 if (!dictionary->GetString("type", &type)) { |
74 error_builder->Append("'type' is required and must be a string"); | 74 error_builder->Append("'type' is required and must be a string"); |
75 return false; | 75 return false; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 return result; | 173 return result; |
174 } | 174 } |
175 | 175 |
176 std::vector<linked_ptr<DeclarativeManifestData::Rule>>& | 176 std::vector<linked_ptr<DeclarativeManifestData::Rule>>& |
177 DeclarativeManifestData::RulesForEvent(const std::string& event) { | 177 DeclarativeManifestData::RulesForEvent(const std::string& event) { |
178 return event_rules_map_[event]; | 178 return event_rules_map_[event]; |
179 } | 179 } |
180 | 180 |
181 } // namespace extensions | 181 } // namespace extensions |
OLD | NEW |