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

Side by Side Diff: chrome/browser/component_updater/component_unpacker.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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/browser/component_updater/component_unpacker.h" 5 #include "chrome/browser/component_updater/component_unpacker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 scoped_ptr<SecureHash> sha256(SecureHash::Create(SecureHash::SHA256)); 129 scoped_ptr<SecureHash> sha256(SecureHash::Create(SecureHash::SHA256));
130 sha256->Update(&(validator.public_key()[0]), validator.public_key().size()); 130 sha256->Update(&(validator.public_key()[0]), validator.public_key().size());
131 sha256->Finish(hash, arraysize(hash)); 131 sha256->Finish(hash, arraysize(hash));
132 132
133 if (!std::equal(pk_hash.begin(), pk_hash.end(), hash)) { 133 if (!std::equal(pk_hash.begin(), pk_hash.end(), hash)) {
134 error_ = kInvalidId; 134 error_ = kInvalidId;
135 return; 135 return;
136 } 136 }
137 // We want the temporary directory to be unique and yet predictable, so 137 // We want the temporary directory to be unique and yet predictable, so
138 // we can easily find the package in a end user machine. 138 // we can easily find the package in a end user machine.
139 std::string dir(StringPrintf("CRX_%s", base::HexEncode(hash, 6).c_str())); 139 std::string dir(
140 base::StringPrintf("CRX_%s", base::HexEncode(hash, 6).c_str()));
140 unpack_path_ = path.DirName().AppendASCII(dir.c_str()); 141 unpack_path_ = path.DirName().AppendASCII(dir.c_str());
141 if (file_util::DirectoryExists(unpack_path_)) { 142 if (file_util::DirectoryExists(unpack_path_)) {
142 if (!file_util::Delete(unpack_path_, true)) { 143 if (!file_util::Delete(unpack_path_, true)) {
143 unpack_path_.clear(); 144 unpack_path_.clear();
144 error_ = kUzipPathError; 145 error_ = kUzipPathError;
145 return; 146 return;
146 } 147 }
147 } 148 }
148 if (!file_util::CreateDirectory(unpack_path_)) { 149 if (!file_util::CreateDirectory(unpack_path_)) {
149 unpack_path_.clear(); 150 unpack_path_.clear();
(...skipping 15 matching lines...) Expand all
165 } 166 }
166 // Installation successful. The directory is not our concern now. 167 // Installation successful. The directory is not our concern now.
167 unpack_path_.clear(); 168 unpack_path_.clear();
168 } 169 }
169 170
170 ComponentUnpacker::~ComponentUnpacker() { 171 ComponentUnpacker::~ComponentUnpacker() {
171 if (!unpack_path_.empty()) { 172 if (!unpack_path_.empty()) {
172 file_util::Delete(unpack_path_, true); 173 file_util::Delete(unpack_path_, true);
173 } 174 }
174 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698