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

Side by Side Diff: chrome/browser/password_manager/login_database.cc

Issue 2866023: Linux: delete the unencrypted login database file after a successful password migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/password_manager/login_database.h" 5 #include "chrome/browser/password_manager/login_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "app/sql/statement.h" 10 #include "app/sql/statement.h"
11 #include "app/sql/transaction.h" 11 #include "app/sql/transaction.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util.h"
13 #include "base/histogram.h" 14 #include "base/histogram.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/time.h" 16 #include "base/time.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "chrome/common/sqlite_utils.h" 18 #include "chrome/common/sqlite_utils.h"
18 19
19 using webkit_glue::PasswordForm; 20 using webkit_glue::PasswordForm;
20 21
21 static const int kCurrentVersionNumber = 1; 22 static const int kCurrentVersionNumber = 1;
22 static const int kCompatibleVersionNumber = 1; 23 static const int kCompatibleVersionNumber = 1;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return false; 71 return false;
71 } 72 }
72 73
73 // Initialize the tables. 74 // Initialize the tables.
74 if (!InitLoginsTable()) { 75 if (!InitLoginsTable()) {
75 LOG(WARNING) << "Unable to initialize the password store database."; 76 LOG(WARNING) << "Unable to initialize the password store database.";
76 db_.Close(); 77 db_.Close();
77 return false; 78 return false;
78 } 79 }
79 80
81 // Save the path for DeleteDatabaseFile().
82 db_path_ = db_path;
83
80 // If the file on disk is an older database version, bring it up to date. 84 // If the file on disk is an older database version, bring it up to date.
81 MigrateOldVersionsAsNeeded(); 85 MigrateOldVersionsAsNeeded();
82 86
83 if (!transaction.Commit()) { 87 if (!transaction.Commit()) {
84 db_.Close(); 88 db_.Close();
85 return false; 89 return false;
86 } 90 }
87 return true; 91 return true;
88 } 92 }
89 93
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 s.BindInt(0, blacklisted ? 1 : 0); 387 s.BindInt(0, blacklisted ? 1 : 0);
384 388
385 while (s.Step()) { 389 while (s.Step()) {
386 PasswordForm* new_form = new PasswordForm(); 390 PasswordForm* new_form = new PasswordForm();
387 InitPasswordFormFromStatement(new_form, s); 391 InitPasswordFormFromStatement(new_form, s);
388 392
389 forms->push_back(new_form); 393 forms->push_back(new_form);
390 } 394 }
391 return s.Succeeded(); 395 return s.Succeeded();
392 } 396 }
397
398 bool LoginDatabase::DeleteAndRecreateDatabaseFile() {
399 DCHECK(db_.is_open());
400 meta_table_.Reset();
401 db_.Close();
402 file_util::Delete(db_path_, false);
403 return Init(db_path_);
404 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/login_database.h ('k') | chrome/browser/password_manager/password_store_default.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698