OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/test/base/test_switches.h" | 28 #include "chrome/test/base/test_switches.h" |
29 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
30 #include "components/autofill/content/common/autofill_messages.h" | 30 #include "components/autofill/content/common/autofill_messages.h" |
31 #include "components/autofill/core/browser/autofill_test_utils.h" | 31 #include "components/autofill/core/browser/autofill_test_utils.h" |
32 #include "components/autofill/core/browser/test_autofill_client.h" | 32 #include "components/autofill/core/browser/test_autofill_client.h" |
33 #include "components/autofill/core/common/password_form.h" | 33 #include "components/autofill/core/common/password_form.h" |
34 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 34 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
35 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" | 35 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" |
36 #include "components/password_manager/core/browser/login_model.h" | 36 #include "components/password_manager/core/browser/login_model.h" |
37 #include "components/password_manager/core/browser/test_password_store.h" | 37 #include "components/password_manager/core/browser/test_password_store.h" |
| 38 #include "components/password_manager/core/common/password_manager_features.h" |
38 #include "components/password_manager/core/common/password_manager_switches.h" | 39 #include "components/password_manager/core/common/password_manager_switches.h" |
39 #include "components/version_info/version_info.h" | 40 #include "components/version_info/version_info.h" |
40 #include "content/public/browser/navigation_controller.h" | 41 #include "content/public/browser/navigation_controller.h" |
41 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/render_frame_host.h" | 43 #include "content/public/browser/render_frame_host.h" |
43 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
44 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
46 #include "content/public/browser/web_contents_observer.h" | 47 #include "content/public/browser/web_contents_observer.h" |
47 #include "content/public/common/content_switches.h" | 48 #include "content/public/common/content_switches.h" |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { | 1184 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { |
1184 scoped_refptr<password_manager::TestPasswordStore> password_store = | 1185 scoped_refptr<password_manager::TestPasswordStore> password_store = |
1185 static_cast<password_manager::TestPasswordStore*>( | 1186 static_cast<password_manager::TestPasswordStore*>( |
1186 PasswordStoreFactory::GetForProfile( | 1187 PasswordStoreFactory::GetForProfile( |
1187 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 1188 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
1188 | 1189 |
1189 EXPECT_TRUE(password_store->IsEmpty()); | 1190 EXPECT_TRUE(password_store->IsEmpty()); |
1190 | 1191 |
1191 NavigateToFile("/password/password_form.html"); | 1192 NavigateToFile("/password/password_form.html"); |
1192 | 1193 |
1193 // Add the enable-automatic-password-saving switch. | 1194 // Add the enable-automatic-password-saving feature. |
1194 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1195 base::FeatureList::ClearInstanceForTesting(); |
1195 password_manager::switches::kEnableAutomaticPasswordSaving); | 1196 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 1197 feature_list->InitializeFromCommandLine( |
| 1198 password_manager::features::kEnableAutomaticPasswordSaving.name, ""); |
| 1199 base::FeatureList::SetInstance(std::move(feature_list)); |
1196 | 1200 |
1197 // Fill a form and submit through a <input type="submit"> button. | 1201 // Fill a form and submit through a <input type="submit"> button. |
1198 NavigationObserver observer(WebContents()); | 1202 NavigationObserver observer(WebContents()); |
1199 scoped_ptr<PromptObserver> prompt_observer( | 1203 scoped_ptr<PromptObserver> prompt_observer( |
1200 PromptObserver::Create(WebContents())); | 1204 PromptObserver::Create(WebContents())); |
1201 // Make sure that the only passwords saved are the auto-saved ones. | 1205 // Make sure that the only passwords saved are the auto-saved ones. |
1202 std::string fill_and_submit = | 1206 std::string fill_and_submit = |
1203 "document.getElementById('username_field').value = 'temp';" | 1207 "document.getElementById('username_field').value = 'temp';" |
1204 "document.getElementById('password_field').value = 'random';" | 1208 "document.getElementById('password_field').value = 'random';" |
1205 "document.getElementById('input_submit_button').click()"; | 1209 "document.getElementById('input_submit_button').click()"; |
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2861 // Spin the message loop to make sure the password store had a chance to | 2865 // Spin the message loop to make sure the password store had a chance to |
2862 // update the password. | 2866 // update the password. |
2863 base::RunLoop run_loop; | 2867 base::RunLoop run_loop; |
2864 run_loop.RunUntilIdle(); | 2868 run_loop.RunUntilIdle(); |
2865 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2869 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), |
2866 base::ASCIIToUTF16("new_pw")); | 2870 base::ASCIIToUTF16("new_pw")); |
2867 } | 2871 } |
2868 #endif | 2872 #endif |
2869 | 2873 |
2870 } // namespace password_manager | 2874 } // namespace password_manager |
OLD | NEW |