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

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

Issue 2607413003: Add security feature to ProvisionalSavePassword (Closed)
Patch Set: More explicit unittest, log origins, and update histogram description. Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/password_manager/password_manager_test_base.h" 8 #include "chrome/browser/password_manager/password_manager_test_base.h"
9 #include "chrome/browser/password_manager/password_store_factory.h" 9 #include "chrome/browser/password_manager/password_store_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_io_data.h" 11 #include "chrome/browser/profiles/profile_io_data.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" 13 #include "chrome/browser/ui/passwords/passwords_model_delegate.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "components/password_manager/core/browser/password_bubble_experiment.h" 15 #include "components/password_manager/core/browser/password_bubble_experiment.h"
16 #include "components/password_manager/core/browser/password_store_consumer.h"
17 #include "components/password_manager/core/browser/test_password_store.h" 16 #include "components/password_manager/core/browser/test_password_store.h"
18 #include "content/public/test/browser_test.h" 17 #include "content/public/test/browser_test.h"
19 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
20 #include "net/cert/cert_verify_result.h" 19 #include "net/cert/cert_verify_result.h"
21 #include "net/cert/mock_cert_verifier.h" 20 #include "net/cert/mock_cert_verifier.h"
22 #include "net/dns/mock_host_resolver.h" 21 #include "net/dns/mock_host_resolver.h"
23 22
24 namespace { 23 namespace {
25 24
26 // A helper class that synchronously waits until the password store handles a
27 // GetLogins() request.
28 class PasswordStoreResultsObserver
29 : public password_manager::PasswordStoreConsumer {
30 public:
31 PasswordStoreResultsObserver() = default;
32
33 void OnGetPasswordStoreResults(
34 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override {
35 run_loop_.Quit();
36 }
37
38 void Wait() {
39 run_loop_.Run();
40 }
41
42 private:
43 base::RunLoop run_loop_;
44
45 DISALLOW_COPY_AND_ASSIGN(PasswordStoreResultsObserver);
46 };
47
48 class CredentialManagerBrowserTest : public PasswordManagerBrowserTestBase { 25 class CredentialManagerBrowserTest : public PasswordManagerBrowserTestBase {
49 public: 26 public:
50 CredentialManagerBrowserTest() = default; 27 CredentialManagerBrowserTest() = default;
51 28
52 bool IsShowingAccountChooser() { 29 bool IsShowingAccountChooser() {
53 return PasswordsModelDelegateFromWebContents(WebContents())-> 30 return PasswordsModelDelegateFromWebContents(WebContents())->
54 GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE; 31 GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE;
55 } 32 }
56 33
57 // Make sure that the password store processed all the previous calls which 34 // Make sure that the password store processed all the previous calls which
58 // are executed on another thread. 35 // are executed on another thread.
59 void WaitForPasswordStore() { 36 void WaitForPasswordStore() {
vasilii 2017/01/12 14:59:20 It's now unused.
jdoerrie 2017/01/12 17:40:58 Done. I thought I had removed it, thanks for catch
60 scoped_refptr<password_manager::PasswordStore> password_store = 37 scoped_refptr<password_manager::PasswordStore> password_store =
61 PasswordStoreFactory::GetForProfile( 38 PasswordStoreFactory::GetForProfile(
62 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS); 39 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS);
63 PasswordStoreResultsObserver syncer; 40 PasswordStoreResultsObserver syncer;
64 password_store->GetAutofillableLoginsWithAffiliatedRealms(&syncer); 41 password_store->GetAutofillableLoginsWithAffiliatedRealms(&syncer);
65 syncer.Wait(); 42 syncer.Wait();
66 } 43 }
67 44
68 // Similarly to PasswordManagerBrowserTestBase::NavigateToFile this is a 45 // Similarly to PasswordManagerBrowserTestBase::NavigateToFile this is a
69 // wrapper around ui_test_utils::NavigateURL that waits until DidFinishLoad() 46 // wrapper around ui_test_utils::NavigateURL that waits until DidFinishLoad()
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 signin_form.skip_zero_click = false; 330 signin_form.skip_zero_click = false;
354 signin_form.times_used = 1; 331 signin_form.times_used = 1;
355 signin_form.password_value = base::ASCIIToUTF16("API"); 332 signin_form.password_value = base::ASCIIToUTF16("API");
356 password_manager::TestPasswordStore::PasswordMap stored = 333 password_manager::TestPasswordStore::PasswordMap stored =
357 password_store->stored_passwords(); 334 password_store->stored_passwords();
358 ASSERT_EQ(1u, stored.size()); 335 ASSERT_EQ(1u, stored.size());
359 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); 336 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]);
360 } 337 }
361 338
362 } // namespace 339 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698