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

Side by Side Diff: components/password_manager/core/browser/password_generation_manager_unittest.cc

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually fix compile failure. Created 6 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <vector> 5 #include <vector>
6 6
7 #include "base/prefs/pref_registry_simple.h" 7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/autofill/core/browser/autofill_field.h" 11 #include "components/autofill/core/browser/autofill_field.h"
12 #include "components/autofill/core/browser/autofill_metrics.h" 12 #include "components/autofill/core/browser/autofill_metrics.h"
13 #include "components/autofill/core/browser/form_structure.h" 13 #include "components/autofill/core/browser/form_structure.h"
14 #include "components/autofill/core/common/form_data.h" 14 #include "components/autofill/core/common/form_data.h"
15 #include "components/autofill/core/common/form_field_data.h" 15 #include "components/autofill/core/common/form_field_data.h"
16 #include "components/password_manager/core/browser/password_autofill_manager.h"
16 #include "components/password_manager/core/browser/password_generation_manager.h " 17 #include "components/password_manager/core/browser/password_generation_manager.h "
17 #include "components/password_manager/core/browser/password_manager.h" 18 #include "components/password_manager/core/browser/password_manager.h"
18 #include "components/password_manager/core/browser/stub_password_manager_client. h" 19 #include "components/password_manager/core/browser/stub_password_manager_client. h"
19 #include "components/password_manager/core/common/password_manager_pref_names.h" 20 #include "components/password_manager/core/common/password_manager_pref_names.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 using base::ASCIIToUTF16; 24 using base::ASCIIToUTF16;
24 25
25 namespace password_manager { 26 namespace password_manager {
26 27
27 namespace { 28 namespace {
28 29
29 class TestPasswordManagerDriver : public PasswordManagerDriver { 30 class TestPasswordManagerDriver : public PasswordManagerDriver {
30 public: 31 public:
31 TestPasswordManagerDriver(PasswordManagerClient* client) 32 TestPasswordManagerDriver(PasswordManagerClient* client)
32 : password_manager_(client), 33 : password_manager_(client),
33 password_generation_manager_(client), 34 password_generation_manager_(client),
35 password_autofill_manager_(client, NULL),
34 is_off_the_record_(false) {} 36 is_off_the_record_(false) {}
35 virtual ~TestPasswordManagerDriver() {} 37 virtual ~TestPasswordManagerDriver() {}
36 38
37 // PasswordManagerDriver implementation. 39 // PasswordManagerDriver implementation.
38 virtual void FillPasswordForm(const autofill::PasswordFormFillData& form_data) 40 virtual void FillPasswordForm(const autofill::PasswordFormFillData& form_data)
39 OVERRIDE {} 41 OVERRIDE {}
40 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } 42 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; }
41 virtual bool IsOffTheRecord() OVERRIDE { return is_off_the_record_; } 43 virtual bool IsOffTheRecord() OVERRIDE { return is_off_the_record_; }
42 virtual PasswordGenerationManager* GetPasswordGenerationManager() OVERRIDE { 44 virtual PasswordGenerationManager* GetPasswordGenerationManager() OVERRIDE {
43 return &password_generation_manager_; 45 return &password_generation_manager_;
44 } 46 }
45 virtual PasswordManager* GetPasswordManager() OVERRIDE { 47 virtual PasswordManager* GetPasswordManager() OVERRIDE {
46 return &password_manager_; 48 return &password_manager_;
47 } 49 }
48 virtual autofill::AutofillManager* GetAutofillManager() OVERRIDE { 50 virtual autofill::AutofillManager* GetAutofillManager() OVERRIDE {
49 return NULL; 51 return NULL;
50 } 52 }
53 virtual PasswordAutofillManager* GetPasswordAutofillManager() OVERRIDE {
54 return &password_autofill_manager_;
55 }
51 virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form) 56 virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form)
52 OVERRIDE {} 57 OVERRIDE {}
53 virtual void AccountCreationFormsFound( 58 virtual void AccountCreationFormsFound(
54 const std::vector<autofill::FormData>& forms) OVERRIDE { 59 const std::vector<autofill::FormData>& forms) OVERRIDE {
55 found_account_creation_forms_.insert( 60 found_account_creation_forms_.insert(
56 found_account_creation_forms_.begin(), forms.begin(), forms.end()); 61 found_account_creation_forms_.begin(), forms.begin(), forms.end());
57 } 62 }
63 virtual void AcceptPasswordAutofillSuggestion(
64 const base::string16& username,
65 const base::string16& password) OVERRIDE {
66 }
58 67
59 const std::vector<autofill::FormData>& GetFoundAccountCreationForms() { 68 const std::vector<autofill::FormData>& GetFoundAccountCreationForms() {
60 return found_account_creation_forms_; 69 return found_account_creation_forms_;
61 } 70 }
62 void set_is_off_the_record(bool is_off_the_record) { 71 void set_is_off_the_record(bool is_off_the_record) {
63 is_off_the_record_ = is_off_the_record; 72 is_off_the_record_ = is_off_the_record;
64 } 73 }
65 74
66 private: 75 private:
67 PasswordManager password_manager_; 76 PasswordManager password_manager_;
68 PasswordGenerationManager password_generation_manager_; 77 PasswordGenerationManager password_generation_manager_;
78 PasswordAutofillManager password_autofill_manager_;
69 std::vector<autofill::FormData> found_account_creation_forms_; 79 std::vector<autofill::FormData> found_account_creation_forms_;
70 bool is_off_the_record_; 80 bool is_off_the_record_;
71 }; 81 };
72 82
73 class TestPasswordManagerClient : public StubPasswordManagerClient { 83 class TestPasswordManagerClient : public StubPasswordManagerClient {
74 public: 84 public:
75 TestPasswordManagerClient(scoped_ptr<PrefService> prefs) 85 TestPasswordManagerClient(scoped_ptr<PrefService> prefs)
76 : prefs_(prefs.Pass()), driver_(this), is_sync_enabled_(false) {} 86 : prefs_(prefs.Pass()), driver_(this), is_sync_enabled_(false) {}
77 87
78 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save) 88 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save)
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // be disabled. 225 // be disabled.
216 GetTestDriver()->set_is_off_the_record(true); 226 GetTestDriver()->set_is_off_the_record(true);
217 PrefService* prefs = client_->GetPrefs(); 227 PrefService* prefs = client_->GetPrefs();
218 prefs->SetBoolean(prefs::kPasswordManagerEnabled, true); 228 prefs->SetBoolean(prefs::kPasswordManagerEnabled, true);
219 client_->set_is_password_sync_enabled(true); 229 client_->set_is_password_sync_enabled(true);
220 230
221 EXPECT_FALSE(IsGenerationEnabled()); 231 EXPECT_FALSE(IsGenerationEnabled());
222 } 232 }
223 233
224 } // namespace password_manager 234 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698