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 "chrome/browser/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/command_line.h" | |
12 #include "base/macros.h" | 11 #include "base/macros.h" |
13 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
17 #include "chrome/browser/sync/profile_sync_test_util.h" | 16 #include "chrome/browser/sync/profile_sync_test_util.h" |
18 #include "chrome/common/channel_info.h" | 17 #include "chrome/common/channel_info.h" |
19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
20 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
21 #include "components/autofill/content/common/autofill_messages.h" | 20 #include "components/autofill/content/common/autofill_messages.h" |
22 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 21 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
23 #include "components/password_manager/content/common/credential_manager_messages
.h" | 22 #include "components/password_manager/content/common/credential_manager_messages
.h" |
24 #include "components/password_manager/core/browser/credentials_filter.h" | 23 #include "components/password_manager/core/browser/credentials_filter.h" |
25 #include "components/password_manager/core/browser/log_manager.h" | 24 #include "components/password_manager/core/browser/log_manager.h" |
26 #include "components/password_manager/core/browser/log_receiver.h" | 25 #include "components/password_manager/core/browser/log_receiver.h" |
27 #include "components/password_manager/core/browser/log_router.h" | 26 #include "components/password_manager/core/browser/log_router.h" |
28 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 27 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
| 28 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
29 #include "components/password_manager/core/common/credential_manager_types.h" | 29 #include "components/password_manager/core/common/credential_manager_types.h" |
30 #include "components/password_manager/core/common/password_manager_features.h" | 30 #include "components/password_manager/core/common/password_manager_features.h" |
31 #include "components/password_manager/core/common/password_manager_pref_names.h" | 31 #include "components/password_manager/core/common/password_manager_pref_names.h" |
32 #include "components/password_manager/core/common/password_manager_switches.h" | |
33 #include "components/prefs/pref_registry_simple.h" | 32 #include "components/prefs/pref_registry_simple.h" |
34 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
35 #include "components/prefs/testing_pref_service.h" | 34 #include "components/prefs/testing_pref_service.h" |
36 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 35 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
37 #include "components/version_info/version_info.h" | 36 #include "components/version_info/version_info.h" |
38 #include "content/public/browser/browser_context.h" | 37 #include "content/public/browser/browser_context.h" |
39 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
40 #include "content/public/test/mock_render_process_host.h" | 39 #include "content/public/test/mock_render_process_host.h" |
41 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
42 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 160 } |
162 | 161 |
163 TEST_F(ChromePasswordManagerClientTest, | 162 TEST_F(ChromePasswordManagerClientTest, |
164 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { | 163 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { |
165 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 164 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
166 } | 165 } |
167 | 166 |
168 TEST_F(ChromePasswordManagerClientTest, | 167 TEST_F(ChromePasswordManagerClientTest, |
169 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { | 168 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { |
170 // Add the enable-automatic-password-saving feature. | 169 // Add the enable-automatic-password-saving feature. |
171 base::FeatureList::ClearInstanceForTesting(); | 170 EnableFeature(password_manager::features::kEnableAutomaticPasswordSaving, |
172 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); | 171 true); |
173 feature_list->InitializeFromCommandLine( | |
174 password_manager::features::kEnableAutomaticPasswordSaving.name, ""); | |
175 base::FeatureList::SetInstance(std::move(feature_list)); | |
176 | 172 |
177 if (chrome::GetChannel() == version_info::Channel::UNKNOWN) | 173 if (chrome::GetChannel() == version_info::Channel::UNKNOWN) |
178 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 174 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
179 else | 175 else |
180 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 176 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
181 } | 177 } |
182 | 178 |
183 TEST_F(ChromePasswordManagerClientTest, GetPasswordSyncState) { | 179 TEST_F(ChromePasswordManagerClientTest, GetPasswordSyncState) { |
184 ChromePasswordManagerClient* client = GetClient(); | 180 ChromePasswordManagerClient* client = GetClient(); |
185 | 181 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile()); | 343 PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile()); |
348 DummyLogReceiver log_receiver; | 344 DummyLogReceiver log_receiver; |
349 EXPECT_EQ(std::string(), log_router->RegisterReceiver(&log_receiver)); | 345 EXPECT_EQ(std::string(), log_router->RegisterReceiver(&log_receiver)); |
350 | 346 |
351 // But then navigate to a WebUI, there the logging should not be active. | 347 // But then navigate to a WebUI, there the logging should not be active. |
352 NavigateAndCommit(GURL("about:password-manager-internals")); | 348 NavigateAndCommit(GURL("about:password-manager-internals")); |
353 EXPECT_FALSE(GetClient()->GetLogManager()->IsLoggingActive()); | 349 EXPECT_FALSE(GetClient()->GetLogManager()->IsLoggingActive()); |
354 | 350 |
355 log_router->UnregisterReceiver(&log_receiver); | 351 log_router->UnregisterReceiver(&log_receiver); |
356 } | 352 } |
OLD | NEW |