Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: extensions/common/api/declarative/declarative_manifest_data.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 new DeclarativeManifestData()); 122 new DeclarativeManifestData());
123 const base::ListValue* list = nullptr; 123 const base::ListValue* list = nullptr;
124 if (!value.GetAsList(&list)) { 124 if (!value.GetAsList(&list)) {
125 error_builder.Append("'event_rules' expected list, got %s", 125 error_builder.Append("'event_rules' expected list, got %s",
126 base::Value::GetTypeName(value.GetType())); 126 base::Value::GetTypeName(value.GetType()));
127 return std::unique_ptr<DeclarativeManifestData>(); 127 return std::unique_ptr<DeclarativeManifestData>();
128 } 128 }
129 129
130 for (const auto& element : *list) { 130 for (const auto& element : *list) {
131 const base::DictionaryValue* dict = nullptr; 131 const base::DictionaryValue* dict = nullptr;
132 if (!element.GetAsDictionary(&dict)) { 132 if (!element->GetAsDictionary(&dict)) {
133 error_builder.Append("expected dictionary, got %s", 133 error_builder.Append("expected dictionary, got %s",
134 base::Value::GetTypeName(element.GetType())); 134 base::Value::GetTypeName(element->GetType()));
135 return std::unique_ptr<DeclarativeManifestData>(); 135 return std::unique_ptr<DeclarativeManifestData>();
136 } 136 }
137 std::string event; 137 std::string event;
138 if (!dict->GetString("event", &event)) { 138 if (!dict->GetString("event", &event)) {
139 error_builder.Append("'event' is required"); 139 error_builder.Append("'event' is required");
140 return std::unique_ptr<DeclarativeManifestData>(); 140 return std::unique_ptr<DeclarativeManifestData>();
141 } 141 }
142 142
143 linked_ptr<Rule> rule(new Rule()); 143 linked_ptr<Rule> rule(new Rule());
144 if (!Rule::Populate(*dict, rule.get())) { 144 if (!Rule::Populate(*dict, rule.get())) {
145 error_builder.Append("rule failed to populate"); 145 error_builder.Append("rule failed to populate");
146 return std::unique_ptr<DeclarativeManifestData>(); 146 return std::unique_ptr<DeclarativeManifestData>();
147 } 147 }
148 148
149 if (!ConvertManifestRule(rule, &error_builder)) 149 if (!ConvertManifestRule(rule, &error_builder))
150 return std::unique_ptr<DeclarativeManifestData>(); 150 return std::unique_ptr<DeclarativeManifestData>();
151 151
152 result->event_rules_map_[event].push_back(rule); 152 result->event_rules_map_[event].push_back(rule);
153 } 153 }
154 return result; 154 return result;
155 } 155 }
156 156
157 std::vector<linked_ptr<DeclarativeManifestData::Rule>>& 157 std::vector<linked_ptr<DeclarativeManifestData::Rule>>&
158 DeclarativeManifestData::RulesForEvent(const std::string& event) { 158 DeclarativeManifestData::RulesForEvent(const std::string& event) {
159 return event_rules_map_[event]; 159 return event_rules_map_[event];
160 } 160 }
161 161
162 } // namespace extensions 162 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/verified_contents.cc ('k') | extensions/common/extension_l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698