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

Side by Side Diff: chrome/browser/importer/nss_decryptor_system_nss.cc

Issue 7004007: iwyu: Include stringprintf.h where appropriate, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2. Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/importer/nss_decryptor_system_nss.h" 5 #include "chrome/browser/importer/nss_decryptor_system_nss.h"
6 6
7 #include <pk11pub.h> 7 #include <pk11pub.h>
8 #include <pk11sdr.h> 8 #include <pk11sdr.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/string_util.h" 12 #include "base/stringprintf.h"
13 #include "base/sys_string_conversions.h" 13 #include "base/sys_string_conversions.h"
14 #include "crypto/nss_util.h" 14 #include "crypto/nss_util.h"
15 15
16 NSSDecryptor::NSSDecryptor() : is_nss_initialized_(false), db_slot_(NULL) {} 16 NSSDecryptor::NSSDecryptor() : is_nss_initialized_(false), db_slot_(NULL) {}
17 NSSDecryptor::~NSSDecryptor() { 17 NSSDecryptor::~NSSDecryptor() {
18 if (db_slot_) { 18 if (db_slot_) {
19 // Deliberately leave the user db open, just in case we need to open more 19 // Deliberately leave the user db open, just in case we need to open more
20 // than one, because there's an NSS bug with reopening user dbs. 20 // than one, because there's an NSS bug with reopening user dbs.
21 // https://bugzilla.mozilla.org/show_bug.cgi?id=506140 21 // https://bugzilla.mozilla.org/show_bug.cgi?id=506140
22 // SECMOD_CloseUserDB(db_slot_); 22 // SECMOD_CloseUserDB(db_slot_);
23 PK11_FreeSlot(db_slot_); 23 PK11_FreeSlot(db_slot_);
24 } 24 }
25 } 25 }
26 26
27 bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { 27 bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) {
28 crypto::EnsureNSSInit(); 28 crypto::EnsureNSSInit();
29 is_nss_initialized_ = true; 29 is_nss_initialized_ = true;
30 const std::string modspec = 30 const std::string modspec =
31 StringPrintf("configDir='%s' tokenDescription='Firefox NSS database' " 31 base::StringPrintf(
32 "flags=readOnly", db_path.value().c_str()); 32 "configDir='%s' tokenDescription='Firefox NSS database' "
33 "flags=readOnly",
34 db_path.value().c_str());
33 db_slot_ = SECMOD_OpenUserDB(modspec.c_str()); 35 db_slot_ = SECMOD_OpenUserDB(modspec.c_str());
34 return db_slot_ != NULL; 36 return db_slot_ != NULL;
35 } 37 }
36 38
37 // This method is based on some NSS code in 39 // This method is based on some NSS code in
38 // security/nss/lib/pk11wrap/pk11sdr.c, CVS revision 1.22 40 // security/nss/lib/pk11wrap/pk11sdr.c, CVS revision 1.22
39 // This code is copied because the implementation assumes the use of the 41 // This code is copied because the implementation assumes the use of the
40 // internal key slot for decryption, but we need to use another slot. 42 // internal key slot for decryption, but we need to use another slot.
41 // The license block is: 43 // The license block is:
42 /* ***** BEGIN LICENSE BLOCK ***** 44 /* ***** BEGIN LICENSE BLOCK *****
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 262 }
261 263
262 loser: 264 loser:
263 if (arena) PORT_FreeArena(arena, PR_TRUE); 265 if (arena) PORT_FreeArena(arena, PR_TRUE);
264 if (key) PK11_FreeSymKey(key); 266 if (key) PK11_FreeSymKey(key);
265 if (params) SECITEM_ZfreeItem(params, PR_TRUE); 267 if (params) SECITEM_ZfreeItem(params, PR_TRUE);
266 if (possibleResult.data) SECITEM_ZfreeItem(&possibleResult, PR_FALSE); 268 if (possibleResult.data) SECITEM_ZfreeItem(&possibleResult, PR_FALSE);
267 269
268 return rv; 270 return rv;
269 } 271 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/firefox_importer_utils.cc ('k') | chrome/browser/importer/profile_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698