1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/webdata/web_database.h"
#include "app/sql/statement.h"
#include "base/logging.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/password_manager/ie7_password.h"
bool WebDatabase::AddIE7Login(const IE7PasswordInfo& info) {
sql::Statement s(db_.GetUniqueStatement(
"INSERT OR REPLACE INTO ie7_logins "
"(url_hash, password_value, date_created) "
"VALUES (?,?,?)"));
if (!s) {
NOTREACHED() << db_.GetErrorMessage();
return false;
}
s.BindString(0, WideToUTF8(info.url_hash));
s.BindBlob(1, &info.encrypted_data.front(),
static_cast<int>(info.encrypted_data.size()));
s.BindInt64(2, info.date_created.ToTimeT());
if (!s.Run()) {
NOTREACHED();
return false;
}
return true;
}
bool WebDatabase::RemoveIE7Login(const IE7PasswordInfo& info) {
// Remove a login by UNIQUE-constrained fields.
sql::Statement s(db_.GetUniqueStatement(
"DELETE FROM ie7_logins WHERE url_hash = ?"));
if (!s) {
NOTREACHED() << db_.GetErrorMessage();
return false;
}
s.BindString(0, WideToUTF8(info.url_hash));
if (!s.Run()) {
NOTREACHED();
return false;
}
return true;
}
bool WebDatabase::GetIE7Login(const IE7PasswordInfo& info,
IE7PasswordInfo* result) {
DCHECK(result);
sql::Statement s(db_.GetUniqueStatement(
"SELECT password_value, date_created FROM ie7_logins "
"WHERE url_hash == ? "));
if (!s) {
NOTREACHED() << db_.GetErrorMessage();
return false;
}
s.BindString(0, WideToUTF8(info.url_hash));
if (s.Step()) {
s.ColumnBlobAsVector(0, &result->encrypted_data);
result->date_created = base::Time::FromTimeT(s.ColumnInt64(1));
result->url_hash = info.url_hash;
}
return s.Succeeded();
}
|