OLD | NEW |
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_generation_manager.h
" | 16 #include "components/password_manager/core/browser/password_generation_manager.h
" |
17 #include "components/password_manager/core/browser/password_manager.h" | 17 #include "components/password_manager/core/browser/password_manager.h" |
18 #include "components/password_manager/core/browser/password_manager_client.h" | 18 #include "components/password_manager/core/browser/stub_password_manager_client.
h" |
19 #include "components/password_manager/core/common/password_manager_pref_names.h" | 19 #include "components/password_manager/core/common/password_manager_pref_names.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
22 | 22 |
23 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
24 | 24 |
25 namespace password_manager { | 25 namespace password_manager { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 is_off_the_record_ = is_off_the_record; | 63 is_off_the_record_ = is_off_the_record; |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 PasswordManager password_manager_; | 67 PasswordManager password_manager_; |
68 PasswordGenerationManager password_generation_manager_; | 68 PasswordGenerationManager password_generation_manager_; |
69 std::vector<autofill::FormData> found_account_creation_forms_; | 69 std::vector<autofill::FormData> found_account_creation_forms_; |
70 bool is_off_the_record_; | 70 bool is_off_the_record_; |
71 }; | 71 }; |
72 | 72 |
73 class TestPasswordManagerClient : public PasswordManagerClient { | 73 class TestPasswordManagerClient : public StubPasswordManagerClient { |
74 public: | 74 public: |
75 TestPasswordManagerClient(scoped_ptr<PrefService> prefs) | 75 TestPasswordManagerClient(scoped_ptr<PrefService> prefs) |
76 : prefs_(prefs.Pass()), driver_(this), is_sync_enabled_(false) {} | 76 : prefs_(prefs.Pass()), driver_(this), is_sync_enabled_(false) {} |
77 | 77 |
78 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save) | 78 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save) |
79 OVERRIDE {} | 79 OVERRIDE {} |
80 virtual PasswordStore* GetPasswordStore() OVERRIDE { return NULL; } | 80 virtual PasswordStore* GetPasswordStore() OVERRIDE { return NULL; } |
81 virtual PrefService* GetPrefs() OVERRIDE { return prefs_.get(); } | 81 virtual PrefService* GetPrefs() OVERRIDE { return prefs_.get(); } |
82 virtual PasswordManagerDriver* GetDriver() OVERRIDE { return &driver_; } | 82 virtual PasswordManagerDriver* GetDriver() OVERRIDE { return &driver_; } |
83 virtual void AuthenticateAutofillAndFillForm( | 83 virtual void AuthenticateAutofillAndFillForm( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // be disabled. | 215 // be disabled. |
216 GetTestDriver()->set_is_off_the_record(true); | 216 GetTestDriver()->set_is_off_the_record(true); |
217 PrefService* prefs = client_->GetPrefs(); | 217 PrefService* prefs = client_->GetPrefs(); |
218 prefs->SetBoolean(prefs::kPasswordManagerEnabled, true); | 218 prefs->SetBoolean(prefs::kPasswordManagerEnabled, true); |
219 client_->set_is_password_sync_enabled(true); | 219 client_->set_is_password_sync_enabled(true); |
220 | 220 |
221 EXPECT_FALSE(IsGenerationEnabled()); | 221 EXPECT_FALSE(IsGenerationEnabled()); |
222 } | 222 } |
223 | 223 |
224 } // namespace password_manager | 224 } // namespace password_manager |
OLD | NEW |