OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/manifest.h" | 5 #include "chrome/common/extensions/manifest.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 std::set<std::string> keys; | 107 std::set<std::string> keys; |
108 const RestrictionMap& map = g_restrictions.Get().map; | 108 const RestrictionMap& map = g_restrictions.Get().map; |
109 for (RestrictionMap::const_iterator i = map.begin(); i != map.end(); i++) | 109 for (RestrictionMap::const_iterator i = map.begin(); i != map.end(); i++) |
110 keys.insert(i->first); | 110 keys.insert(i->first); |
111 return keys; | 111 return keys; |
112 } | 112 } |
113 | 113 |
114 Manifest::Manifest(DictionaryValue* value) : value_(value) {} | 114 Manifest::Manifest(DictionaryValue* value) : value_(value) {} |
115 Manifest::~Manifest() {} | 115 Manifest::~Manifest() {} |
116 | 116 |
117 bool Manifest::ValidateManifest(std::string* error) const { | 117 bool Manifest::ValidateManifest(string16* error) const { |
118 Restrictions restrictions = g_restrictions.Get(); | 118 Restrictions restrictions = g_restrictions.Get(); |
119 Type type = GetType(); | 119 Type type = GetType(); |
120 | 120 |
121 for (DictionaryValue::key_iterator key = value_->begin_keys(); | 121 for (DictionaryValue::key_iterator key = value_->begin_keys(); |
122 key != value_->end_keys(); ++key) { | 122 key != value_->end_keys(); ++key) { |
123 // When validating the extension manifests, we ignore keys that are not | 123 // When validating the extension manifests, we ignore keys that are not |
124 // recognized for forward compatibility. | 124 // recognized for forward compatibility. |
125 if (!restrictions.IsKnownKey(*key)) { | 125 if (!restrictions.IsKnownKey(*key)) { |
126 // TODO(aa): Consider having an error here in the case of strict error | 126 // TODO(aa): Consider having an error here in the case of strict error |
127 // checking to let developers know when they screw up. | 127 // checking to let developers know when they screw up. |
128 continue; | 128 continue; |
129 } | 129 } |
130 | 130 |
131 if (!restrictions.CanAccessKey(*key, type)) { | 131 if (!restrictions.CanAccessKey(*key, type)) { |
132 *error = ExtensionErrorUtils::FormatErrorMessage( | 132 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
133 errors::kFeatureNotAllowed, *key); | 133 errors::kFeatureNotAllowed, *key); |
134 return false; | 134 return false; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 bool Manifest::HasKey(const std::string& key) const { | 141 bool Manifest::HasKey(const std::string& key) const { |
142 Restrictions restrictions = g_restrictions.Get(); | 142 Restrictions restrictions = g_restrictions.Get(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 bool Manifest::CanAccessPath(const std::string& path) const { | 223 bool Manifest::CanAccessPath(const std::string& path) const { |
224 std::vector<std::string> components; | 224 std::vector<std::string> components; |
225 base::SplitString(path, '.', &components); | 225 base::SplitString(path, '.', &components); |
226 | 226 |
227 Restrictions restrictions = g_restrictions.Get(); | 227 Restrictions restrictions = g_restrictions.Get(); |
228 return restrictions.CanAccessKey(components[0], GetType()); | 228 return restrictions.CanAccessKey(components[0], GetType()); |
229 } | 229 } |
230 | 230 |
231 } // namespace extensions | 231 } // namespace extensions |
OLD | NEW |