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

Side by Side Diff: chrome/common/extensions/features/simple_feature.cc

Issue 15091002: Lazily load API schemas from resource files and convert all APIs to features (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: optimize and "parent" property Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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/features/simple_feature.h" 5 #include "chrome/common/extensions/features/simple_feature.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ParseEnum(*iter, &enum_value, mapping); 134 ParseEnum(*iter, &enum_value, mapping);
135 enum_set->insert(enum_value); 135 enum_set->insert(enum_value);
136 } 136 }
137 } 137 }
138 138
139 void ParseURLPatterns(const DictionaryValue* value, 139 void ParseURLPatterns(const DictionaryValue* value,
140 const std::string& key, 140 const std::string& key,
141 URLPatternSet* set) { 141 URLPatternSet* set) {
142 const ListValue* matches = NULL; 142 const ListValue* matches = NULL;
143 if (value->GetList(key, &matches)) { 143 if (value->GetList(key, &matches)) {
144 set->ClearPatterns();
not at google - send to devlin 2013/05/23 00:09:40 is this cleanup or was there a bug?
cduvall 2013/05/24 03:13:49 There could have been a bug when I was parsing the
144 for (size_t i = 0; i < matches->GetSize(); ++i) { 145 for (size_t i = 0; i < matches->GetSize(); ++i) {
145 std::string pattern; 146 std::string pattern;
146 CHECK(matches->GetString(i, &pattern)); 147 CHECK(matches->GetString(i, &pattern));
147 set->AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern)); 148 set->AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern));
148 } 149 }
149 } 150 }
150 } 151 }
151 152
152 // Gets a human-readable name for the given extension type. 153 // Gets a human-readable name for the given extension type.
153 std::string GetDisplayTypeName(Manifest::Type type) { 154 std::string GetDisplayTypeName(Manifest::Type type) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 417
417 std::set<Feature::Context>* SimpleFeature::GetContexts() { 418 std::set<Feature::Context>* SimpleFeature::GetContexts() {
418 return &contexts_; 419 return &contexts_;
419 } 420 }
420 421
421 bool SimpleFeature::IsInternal() const { 422 bool SimpleFeature::IsInternal() const {
422 NOTREACHED(); 423 NOTREACHED();
423 return false; 424 return false;
424 } 425 }
425 426
427 bool SimpleFeature::HasParent() const {
428 return false;
429 }
430
426 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { 431 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const {
427 // Belt-and-suspenders philosophy here. We should be pretty confident by this 432 // Belt-and-suspenders philosophy here. We should be pretty confident by this
428 // point that we've validated the extension ID format, but in case something 433 // point that we've validated the extension ID format, but in case something
429 // slips through, we avoid a class of attack where creative ID manipulation 434 // slips through, we avoid a class of attack where creative ID manipulation
430 // leads to hash collisions. 435 // leads to hash collisions.
431 if (extension_id.length() != 32) // 128 bits / 4 = 32 mpdecimal characters 436 if (extension_id.length() != 32) // 128 bits / 4 = 32 mpdecimal characters
432 return false; 437 return false;
433 438
434 if (whitelist_.find(extension_id) != whitelist_.end() || 439 if (whitelist_.find(extension_id) != whitelist_.end() ||
435 whitelist_.find(HashExtensionId(extension_id)) != whitelist_.end()) 440 whitelist_.find(HashExtensionId(extension_id)) != whitelist_.end())
436 return true; 441 return true;
437 442
438 return false; 443 return false;
439 } 444 }
440 445
441 } // namespace extensions 446 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698