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