| OLD | NEW |
| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 return Availability( | 482 return Availability( |
| 483 result, GetAvailabilityMessage(result, Manifest::TYPE_UNKNOWN, GURL(), | 483 result, GetAvailabilityMessage(result, Manifest::TYPE_UNKNOWN, GURL(), |
| 484 context)); | 484 context)); |
| 485 } | 485 } |
| 486 | 486 |
| 487 std::set<Feature::Context>* SimpleFeature::GetContexts() { | 487 std::set<Feature::Context>* SimpleFeature::GetContexts() { |
| 488 return &contexts_; | 488 return &contexts_; |
| 489 } | 489 } |
| 490 | 490 |
| 491 bool SimpleFeature::IsInternal() const { | 491 bool SimpleFeature::IsInternal() const { |
| 492 NOTREACHED(); | |
| 493 return false; | 492 return false; |
| 494 } | 493 } |
| 495 | 494 |
| 495 bool SimpleFeature::IsBlockedInServiceWorker() const { return false; } |
| 496 |
| 496 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { | 497 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { |
| 497 return IsIdInWhitelist(extension_id, whitelist_); | 498 return IsIdInWhitelist(extension_id, whitelist_); |
| 498 } | 499 } |
| 499 | 500 |
| 500 // static | 501 // static |
| 501 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id, | 502 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id, |
| 502 const std::set<std::string>& whitelist) { | 503 const std::set<std::string>& whitelist) { |
| 503 // Belt-and-suspenders philosophy here. We should be pretty confident by this | 504 // Belt-and-suspenders philosophy here. We should be pretty confident by this |
| 504 // point that we've validated the extension ID format, but in case something | 505 // point that we've validated the extension ID format, but in case something |
| 505 // slips through, we avoid a class of attack where creative ID manipulation | 506 // slips through, we avoid a class of attack where creative ID manipulation |
| 506 // leads to hash collisions. | 507 // leads to hash collisions. |
| 507 if (extension_id.length() != 32) // 128 bits / 4 = 32 mpdecimal characters | 508 if (extension_id.length() != 32) // 128 bits / 4 = 32 mpdecimal characters |
| 508 return false; | 509 return false; |
| 509 | 510 |
| 510 if (whitelist.find(extension_id) != whitelist.end() || | 511 if (whitelist.find(extension_id) != whitelist.end() || |
| 511 whitelist.find(HashExtensionId(extension_id)) != whitelist.end()) { | 512 whitelist.find(HashExtensionId(extension_id)) != whitelist.end()) { |
| 512 return true; | 513 return true; |
| 513 } | 514 } |
| 514 | 515 |
| 515 return false; | 516 return false; |
| 516 } | 517 } |
| 517 | 518 |
| 518 } // namespace extensions | 519 } // namespace extensions |
| OLD | NEW |