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

Side by Side Diff: chrome/common/extensions/manifest.cc

Issue 8890086: Issue 71980: Extensions code should use UTF-16 for user-visible Unicode strings (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 std::set<std::string> keys; 105 std::set<std::string> keys;
106 const RestrictionMap& map = g_restrictions.Get().map; 106 const RestrictionMap& map = g_restrictions.Get().map;
107 for (RestrictionMap::const_iterator i = map.begin(); i != map.end(); i++) 107 for (RestrictionMap::const_iterator i = map.begin(); i != map.end(); i++)
108 keys.insert(i->first); 108 keys.insert(i->first);
109 return keys; 109 return keys;
110 } 110 }
111 111
112 Manifest::Manifest(DictionaryValue* value) : value_(value) {} 112 Manifest::Manifest(DictionaryValue* value) : value_(value) {}
113 Manifest::~Manifest() {} 113 Manifest::~Manifest() {}
114 114
115 bool Manifest::ValidateManifest(std::string* error) const { 115 bool Manifest::ValidateManifest(string16* error) const {
116 Restrictions restrictions = g_restrictions.Get(); 116 Restrictions restrictions = g_restrictions.Get();
117 Type type = GetType(); 117 Type type = GetType();
118 118
119 for (DictionaryValue::key_iterator key = value_->begin_keys(); 119 for (DictionaryValue::key_iterator key = value_->begin_keys();
120 key != value_->end_keys(); ++key) { 120 key != value_->end_keys(); ++key) {
121 // When validating the extension manifests, we ignore keys that are not 121 // When validating the extension manifests, we ignore keys that are not
122 // recognized for forward compatibility. 122 // recognized for forward compatibility.
123 if (!restrictions.IsKnownKey(*key)) { 123 if (!restrictions.IsKnownKey(*key)) {
124 // TODO(aa): Consider having an error here in the case of strict error 124 // TODO(aa): Consider having an error here in the case of strict error
125 // checking to let developers know when they screw up. 125 // checking to let developers know when they screw up.
126 continue; 126 continue;
127 } 127 }
128 128
129 if (!restrictions.CanAccessKey(*key, type)) { 129 if (!restrictions.CanAccessKey(*key, type)) {
130 *error = ExtensionErrorUtils::FormatErrorMessage( 130 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
131 errors::kFeatureNotAllowed, *key); 131 errors::kFeatureNotAllowed, *key);
132 return false; 132 return false;
133 } 133 }
134 } 134 }
135 135
136 return true; 136 return true;
137 } 137 }
138 138
139 bool Manifest::HasKey(const std::string& key) const { 139 bool Manifest::HasKey(const std::string& key) const {
140 Restrictions restrictions = g_restrictions.Get(); 140 Restrictions restrictions = g_restrictions.Get();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 bool Manifest::CanAccessPath(const std::string& path) const { 221 bool Manifest::CanAccessPath(const std::string& path) const {
222 std::vector<std::string> components; 222 std::vector<std::string> components;
223 base::SplitString(path, '.', &components); 223 base::SplitString(path, '.', &components);
224 224
225 Restrictions restrictions = g_restrictions.Get(); 225 Restrictions restrictions = g_restrictions.Get();
226 return restrictions.CanAccessKey(components[0], GetType()); 226 return restrictions.CanAccessKey(components[0], GetType());
227 } 227 }
228 228
229 } // namespace extensions 229 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698