| 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" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 18 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" | 19 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 19 #include "chrome/browser/sync/profile_sync_test_util.h" | 20 #include "chrome/browser/sync/profile_sync_test_util.h" |
| 21 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 22 #include "components/autofill/content/common/autofill_agent.mojom.h" | 24 #include "components/autofill/content/common/autofill_agent.mojom.h" |
| 23 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 25 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
| 24 #include "components/password_manager/core/browser/credentials_filter.h" | 26 #include "components/password_manager/core/browser/credentials_filter.h" |
| 25 #include "components/password_manager/core/browser/log_manager.h" | 27 #include "components/password_manager/core/browser/log_manager.h" |
| 26 #include "components/password_manager/core/browser/log_receiver.h" | 28 #include "components/password_manager/core/browser/log_receiver.h" |
| 27 #include "components/password_manager/core/browser/log_router.h" | 29 #include "components/password_manager/core/browser/log_router.h" |
| 28 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 30 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
| 29 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 31 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 358 |
| 357 // Functionality disabled in Incognito mode also when manager itself is | 359 // Functionality disabled in Incognito mode also when manager itself is |
| 358 // enabled. | 360 // enabled. |
| 359 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 361 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
| 360 new base::Value(true)); | 362 new base::Value(true)); |
| 361 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 363 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
| 362 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 364 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
| 363 profile()->ForceIncognito(false); | 365 profile()->ForceIncognito(false); |
| 364 } | 366 } |
| 365 | 367 |
| 368 TEST_F(ChromePasswordManagerClientTest, SavingDependsOnAutomation) { |
| 369 // Test that saving passwords UI is disabled for automated tests. |
| 370 ChromePasswordManagerClient* client = GetClient(); |
| 371 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); |
| 372 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 373 switches::kEnableAutomation); |
| 374 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
| 375 } |
| 376 |
| 366 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { | 377 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { |
| 367 EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); | 378 EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); |
| 368 } | 379 } |
| 369 | 380 |
| 370 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { | 381 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { |
| 371 GURL kUrl( | 382 GURL kUrl( |
| 372 "https://accounts.google.com/ServiceLogin?continue=" | 383 "https://accounts.google.com/ServiceLogin?continue=" |
| 373 "https://passwords.google.com/settings"); | 384 "https://passwords.google.com/settings"); |
| 374 NavigateAndCommit(kUrl); | 385 NavigateAndCommit(kUrl); |
| 375 EXPECT_EQ(kUrl, GetClient()->GetLastCommittedEntryURL()); | 386 EXPECT_EQ(kUrl, GetClient()->GetLastCommittedEntryURL()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 }; | 549 }; |
| 539 | 550 |
| 540 for (const TestCase& test_case : kTestCases) { | 551 for (const TestCase& test_case : kTestCases) { |
| 541 // CanShowBubbleOnURL currently only depends on the scheme. | 552 // CanShowBubbleOnURL currently only depends on the scheme. |
| 542 GURL url(base::StringPrintf("%s://example.org", test_case.scheme)); | 553 GURL url(base::StringPrintf("%s://example.org", test_case.scheme)); |
| 543 SCOPED_TRACE(url.possibly_invalid_spec()); | 554 SCOPED_TRACE(url.possibly_invalid_spec()); |
| 544 EXPECT_EQ(test_case.can_show_bubble, | 555 EXPECT_EQ(test_case.can_show_bubble, |
| 545 ChromePasswordManagerClient::CanShowBubbleOnURL(url)); | 556 ChromePasswordManagerClient::CanShowBubbleOnURL(url)); |
| 546 } | 557 } |
| 547 } | 558 } |
| OLD | NEW |