Chromium Code Reviews| Index: extensions/browser/verified_contents.cc |
| diff --git a/extensions/browser/verified_contents.cc b/extensions/browser/verified_contents.cc |
| index 47c94662a166ca18d999ef9a32992318d9b4e9ad..f55abc91ad538359b4904b90e8633d516a656372 100644 |
| --- a/extensions/browser/verified_contents.cc |
| +++ b/extensions/browser/verified_contents.cc |
| @@ -186,8 +186,9 @@ bool VerifiedContents::InitFrom(const base::FilePath& path, |
| return false; |
| base::FilePath file_path = |
| base::FilePath::FromUTF8Unsafe(file_path_string); |
| - root_hashes_[file_path] = std::string(); |
| - root_hashes_[file_path].swap(root_hash); |
| + RootHashes::iterator i = root_hashes_.insert(std::make_pair( |
| + base::StringToLowerASCII(file_path.value()), std::string())); |
| + i->second.swap(root_hash); |
| } |
| break; |
| @@ -195,14 +196,36 @@ bool VerifiedContents::InitFrom(const base::FilePath& path, |
| return true; |
| } |
| +bool VerifiedContents::HasTreeHashRoot( |
| + const base::FilePath& relative_path) const { |
| + base::FilePath::StringType path = base::StringToLowerASCII( |
| + relative_path.NormalizePathSeparatorsTo('/').value()); |
| + return root_hashes_.find(path) != root_hashes_.end(); |
| +} |
| + |
| +bool VerifiedContents::TreeHashRootEquals(const base::FilePath& relative_path, |
| + const std::string& expected) const { |
| + base::FilePath::StringType path = base::StringToLowerASCII( |
| + relative_path.NormalizePathSeparatorsTo('/').value()); |
| + for (RootHashes::const_iterator i = root_hashes_.find(path); |
| + i != root_hashes_.end(); |
| + ++i) { |
| + if (expected == i->second) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +#if 0 |
| const std::string* VerifiedContents::GetTreeHashRoot( |
|
Ken Rockot(use gerrit already)
2014/09/26 18:48:13
Do you really want to keep this around for some re
asargent_no_longer_on_chrome
2014/09/26 18:51:55
No.
|
| const base::FilePath& relative_path) { |
| - std::map<base::FilePath, std::string>::const_iterator i = |
| + RootHashes::const_iterator i = |
| root_hashes_.find(relative_path.NormalizePathSeparatorsTo('/')); |
| if (i == root_hashes_.end()) |
| return NULL; |
| return &i->second; |
| } |
| +#endif |
| // We're loosely following the "JSON Web Signature" draft spec for signing |
| // a JSON payload: |