OLD | NEW |
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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DATA_BLOB output = {0}; | 90 DATA_BLOB output = {0}; |
91 | 91 |
92 input.pbData = data; | 92 input.pbData = data; |
93 input.cbData = sizeof(data); | 93 input.cbData = sizeof(data); |
94 | 94 |
95 url_key.pbData = reinterpret_cast<unsigned char*>( | 95 url_key.pbData = reinterpret_cast<unsigned char*>( |
96 const_cast<wchar_t*>(url.data())); | 96 const_cast<wchar_t*>(url.data())); |
97 url_key.cbData = static_cast<DWORD>((url.size() + 1) * | 97 url_key.cbData = static_cast<DWORD>((url.size() + 1) * |
98 sizeof(std::wstring::value_type)); | 98 sizeof(std::wstring::value_type)); |
99 | 99 |
100 if (!CryptProtectData(&input, NULL, &url_key, NULL, NULL, | 100 if (!CryptProtectData(&input, nullptr, &url_key, nullptr, nullptr, |
101 CRYPTPROTECT_UI_FORBIDDEN, &output)) | 101 CRYPTPROTECT_UI_FORBIDDEN, &output)) |
102 return false; | 102 return false; |
103 | 103 |
104 std::vector<unsigned char> encrypted_data; | 104 std::vector<unsigned char> encrypted_data; |
105 encrypted_data.resize(output.cbData); | 105 encrypted_data.resize(output.cbData); |
106 memcpy(&encrypted_data.front(), output.pbData, output.cbData); | 106 memcpy(&encrypted_data.front(), output.pbData, output.cbData); |
107 | 107 |
108 LocalFree(output.pbData); | 108 LocalFree(output.pbData); |
109 | 109 |
110 info->url_hash = ie7_password::GetUrlHash(url); | 110 info->url_hash = ie7_password::GetUrlHash(url); |
(...skipping 21 matching lines...) Expand all Loading... |
132 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 132 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
133 WebDataServiceBase::ProfileErrorCallback()); | 133 WebDataServiceBase::ProfileErrorCallback()); |
134 wds_->Init(); | 134 wds_->Init(); |
135 } | 135 } |
136 | 136 |
137 virtual void TearDown() { | 137 virtual void TearDown() { |
138 if (store_.get()) | 138 if (store_.get()) |
139 store_->Shutdown(); | 139 store_->Shutdown(); |
140 wds_->ShutdownOnUIThread(); | 140 wds_->ShutdownOnUIThread(); |
141 wdbs_->ShutdownDatabase(); | 141 wdbs_->ShutdownDatabase(); |
142 wds_ = NULL; | 142 wds_ = nullptr; |
143 wdbs_ = NULL; | 143 wdbs_ = nullptr; |
144 base::WaitableEvent done(false, false); | 144 base::WaitableEvent done(false, false); |
145 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 145 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
146 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 146 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
147 done.Wait(); | 147 done.Wait(); |
148 base::MessageLoop::current()->PostTask(FROM_HERE, | 148 base::MessageLoop::current()->PostTask(FROM_HERE, |
149 base::MessageLoop::QuitClosure()); | 149 base::MessageLoop::QuitClosure()); |
150 base::MessageLoop::current()->Run(); | 150 base::MessageLoop::current()->Run(); |
151 db_thread_.Stop(); | 151 db_thread_.Stop(); |
152 } | 152 } |
153 | 153 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 true, false, 1, | 277 true, false, 1, |
278 }; | 278 }; |
279 scoped_ptr<PasswordForm> form = | 279 scoped_ptr<PasswordForm> form = |
280 CreatePasswordFormFromDataForTesting(form_data); | 280 CreatePasswordFormFromDataForTesting(form_data); |
281 | 281 |
282 MockPasswordStoreConsumer consumer; | 282 MockPasswordStoreConsumer consumer; |
283 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); | 283 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
284 | 284 |
285 // Release the PSW and the WDS before the query can return. | 285 // Release the PSW and the WDS before the query can return. |
286 store_->Shutdown(); | 286 store_->Shutdown(); |
287 store_ = NULL; | 287 store_ = nullptr; |
288 wds_ = NULL; | 288 wds_ = nullptr; |
289 | 289 |
290 base::MessageLoop::current()->RunUntilIdle(); | 290 base::MessageLoop::current()->RunUntilIdle(); |
291 } | 291 } |
292 | 292 |
293 // Hangs flakily, see http://crbug.com/43836. | 293 // Hangs flakily, see http://crbug.com/43836. |
294 TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { | 294 TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
295 IE7PasswordInfo password_info; | 295 IE7PasswordInfo password_info; |
296 ASSERT_TRUE(CreateIE7PasswordInfo(L"http://example.com/origin", | 296 ASSERT_TRUE(CreateIE7PasswordInfo(L"http://example.com/origin", |
297 base::Time::FromDoubleT(1), | 297 base::Time::FromDoubleT(1), |
298 &password_info)); | 298 &password_info)); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 420 |
421 // Make sure we quit the MessageLoop even if the test fails. | 421 // Make sure we quit the MessageLoop even if the test fails. |
422 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 422 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
423 .WillByDefault(QuitUIMessageLoop()); | 423 .WillByDefault(QuitUIMessageLoop()); |
424 | 424 |
425 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 425 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
426 | 426 |
427 store_->GetAutofillableLogins(&consumer); | 427 store_->GetAutofillableLogins(&consumer); |
428 base::MessageLoop::current()->Run(); | 428 base::MessageLoop::current()->Run(); |
429 } | 429 } |
OLD | NEW |