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

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

Issue 481433005: Extensions: Move id_util functions to crx_file component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert last patchset. function returns Extension* and can't use an assert. Created 6 years, 4 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
« no previous file with comments | « extensions/browser/file_reader_unittest.cc ('k') | extensions/common/BUILD.gn » ('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/verified_contents.h" 5 #include "extensions/browser/verified_contents.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/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/crx_file/id_util.h"
12 #include "crypto/signature_verifier.h" 13 #include "crypto/signature_verifier.h"
13 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
14 15
15 using base::DictionaryValue; 16 using base::DictionaryValue;
16 using base::ListValue; 17 using base::ListValue;
17 using base::Value; 18 using base::Value;
18 19
19 namespace { 20 namespace {
20 21
21 // Note: this structure is an ASN.1 which encodes the algorithm used with its 22 // Note: this structure is an ASN.1 which encodes the algorithm used with its
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (!GetPayload(path, &payload, ignore_invalid_signature)) 125 if (!GetPayload(path, &payload, ignore_invalid_signature))
125 return false; 126 return false;
126 127
127 scoped_ptr<base::Value> value(base::JSONReader::Read(payload)); 128 scoped_ptr<base::Value> value(base::JSONReader::Read(payload));
128 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) 129 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY))
129 return false; 130 return false;
130 DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.get()); 131 DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.get());
131 132
132 std::string item_id; 133 std::string item_id;
133 if (!dictionary->GetString(kItemIdKey, &item_id) || 134 if (!dictionary->GetString(kItemIdKey, &item_id) ||
134 !Extension::IdIsValid(item_id)) 135 !crx_file::id_util::IdIsValid(item_id))
135 return false; 136 return false;
136 extension_id_ = item_id; 137 extension_id_ = item_id;
137 138
138 std::string version_string; 139 std::string version_string;
139 if (!dictionary->GetString(kItemVersionKey, &version_string)) 140 if (!dictionary->GetString(kItemVersionKey, &version_string))
140 return false; 141 return false;
141 version_ = base::Version(version_string); 142 version_ = base::Version(version_string);
142 if (!version_.IsValid()) 143 if (!version_.IsValid())
143 return false; 144 return false;
144 145
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 reinterpret_cast<const uint8*>(payload.data()), payload.size()); 336 reinterpret_cast<const uint8*>(payload.data()), payload.size());
336 337
337 if (!signature_verifier.VerifyFinal()) { 338 if (!signature_verifier.VerifyFinal()) {
338 VLOG(1) << "Could not verify signature - VerifyFinal failure"; 339 VLOG(1) << "Could not verify signature - VerifyFinal failure";
339 return false; 340 return false;
340 } 341 }
341 return true; 342 return true;
342 } 343 }
343 344
344 } // namespace extensions 345 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/file_reader_unittest.cc ('k') | extensions/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698