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

Side by Side Diff: extensions/browser/content_hash_reader.cc

Issue 512573003: Content verification: Don't fail on non-existence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « extensions/browser/content_hash_reader.h ('k') | extensions/browser/content_verify_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/content_hash_reader.h" 5 #include "extensions/browser/content_hash_reader.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 17 matching lines...) Expand all
28 const base::Version& extension_version, 28 const base::Version& extension_version,
29 const base::FilePath& extension_root, 29 const base::FilePath& extension_root,
30 const base::FilePath& relative_path, 30 const base::FilePath& relative_path,
31 const ContentVerifierKey& key) 31 const ContentVerifierKey& key)
32 : extension_id_(extension_id), 32 : extension_id_(extension_id),
33 extension_version_(extension_version.GetString()), 33 extension_version_(extension_version.GetString()),
34 extension_root_(extension_root), 34 extension_root_(extension_root),
35 relative_path_(relative_path), 35 relative_path_(relative_path),
36 key_(key), 36 key_(key),
37 status_(NOT_INITIALIZED), 37 status_(NOT_INITIALIZED),
38 content_exists_(false),
38 have_verified_contents_(false), 39 have_verified_contents_(false),
39 have_computed_hashes_(false), 40 have_computed_hashes_(false),
40 block_size_(0) { 41 block_size_(0) {
41 } 42 }
42 43
43 ContentHashReader::~ContentHashReader() { 44 ContentHashReader::~ContentHashReader() {
44 } 45 }
45 46
46 bool ContentHashReader::Init() { 47 bool ContentHashReader::Init() {
47 base::ElapsedTimer timer; 48 base::ElapsedTimer timer;
48 DCHECK_EQ(status_, NOT_INITIALIZED); 49 DCHECK_EQ(status_, NOT_INITIALIZED);
49 status_ = FAILURE; 50 status_ = FAILURE;
50 base::FilePath verified_contents_path = 51 base::FilePath verified_contents_path =
51 file_util::GetVerifiedContentsPath(extension_root_); 52 file_util::GetVerifiedContentsPath(extension_root_);
52 53
54 // Check that this is a valid resource to verify (i.e., it exists).
55 base::FilePath content_path = extension_root_.Append(relative_path_);
56 if (!base::PathExists(content_path))
57 return false;
58
59 content_exists_ = true;
60
53 if (!base::PathExists(verified_contents_path)) 61 if (!base::PathExists(verified_contents_path))
54 return false; 62 return false;
55 63
56 verified_contents_.reset(new VerifiedContents(key_.data, key_.size)); 64 verified_contents_.reset(new VerifiedContents(key_.data, key_.size));
57 if (!verified_contents_->InitFrom(verified_contents_path, false) || 65 if (!verified_contents_->InitFrom(verified_contents_path, false) ||
58 !verified_contents_->valid_signature() || 66 !verified_contents_->valid_signature() ||
59 !verified_contents_->version().Equals(extension_version_) || 67 !verified_contents_->version().Equals(extension_version_) ||
60 verified_contents_->extension_id() != extension_id_) 68 verified_contents_->extension_id() != extension_id_)
61 return false; 69 return false;
62 70
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 DCHECK(block_index >= 0); 118 DCHECK(block_index >= 0);
111 119
112 if (static_cast<unsigned>(block_index) >= hashes_.size()) 120 if (static_cast<unsigned>(block_index) >= hashes_.size())
113 return false; 121 return false;
114 *result = &hashes_[block_index]; 122 *result = &hashes_[block_index];
115 123
116 return true; 124 return true;
117 } 125 }
118 126
119 } // namespace extensions 127 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_hash_reader.h ('k') | extensions/browser/content_verify_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698