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 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 profile()->ForceIncognito(false); | 313 profile()->ForceIncognito(false); |
314 EXPECT_FALSE(client->IsOffTheRecord()); | 314 EXPECT_FALSE(client->IsOffTheRecord()); |
315 } | 315 } |
316 | 316 |
317 TEST_F(ChromePasswordManagerClientTest, | 317 TEST_F(ChromePasswordManagerClientTest, |
318 SavingDependsOnManagerEnabledPreference) { | 318 SavingDependsOnManagerEnabledPreference) { |
319 // Test that saving passwords depends on the password manager enabled | 319 // Test that saving passwords depends on the password manager enabled |
320 // preference. | 320 // preference. |
321 ChromePasswordManagerClient* client = GetClient(); | 321 ChromePasswordManagerClient* client = GetClient(); |
322 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 322 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
323 new base::FundamentalValue(true)); | 323 new base::Value(true)); |
324 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); | 324 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); |
325 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 325 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
326 new base::FundamentalValue(false)); | 326 new base::Value(false)); |
327 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 327 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
328 } | 328 } |
329 | 329 |
330 TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) { | 330 TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) { |
331 std::unique_ptr<WebContents> test_web_contents( | 331 std::unique_ptr<WebContents> test_web_contents( |
332 content::WebContentsTester::CreateTestWebContents( | 332 content::WebContentsTester::CreateTestWebContents( |
333 web_contents()->GetBrowserContext(), nullptr)); | 333 web_contents()->GetBrowserContext(), nullptr)); |
334 std::unique_ptr<MockChromePasswordManagerClient> client( | 334 std::unique_ptr<MockChromePasswordManagerClient> client( |
335 new MockChromePasswordManagerClient(test_web_contents.get())); | 335 new MockChromePasswordManagerClient(test_web_contents.get())); |
336 // Functionality disabled if there is SSL errors. | 336 // Functionality disabled if there is SSL errors. |
337 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) | 337 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) |
338 .WillRepeatedly(Return(true)); | 338 .WillRepeatedly(Return(true)); |
339 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 339 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
340 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); | 340 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); |
341 | 341 |
342 // Functionality disabled if there are SSL errors and the manager itself is | 342 // Functionality disabled if there are SSL errors and the manager itself is |
343 // disabled. | 343 // disabled. |
344 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 344 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
345 new base::FundamentalValue(false)); | 345 new base::Value(false)); |
346 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 346 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
347 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); | 347 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); |
348 | 348 |
349 // Functionality disabled if there are no SSL errors, but the manager itself | 349 // Functionality disabled if there are no SSL errors, but the manager itself |
350 // is disabled. | 350 // is disabled. |
351 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) | 351 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) |
352 .WillRepeatedly(Return(false)); | 352 .WillRepeatedly(Return(false)); |
353 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 353 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
354 new base::FundamentalValue(false)); | 354 new base::Value(false)); |
355 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 355 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
356 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 356 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
357 | 357 |
358 // Functionality enabled if there are no SSL errors and the manager is | 358 // Functionality enabled if there are no SSL errors and the manager is |
359 // enabled. | 359 // enabled. |
360 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) | 360 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) |
361 .WillRepeatedly(Return(false)); | 361 .WillRepeatedly(Return(false)); |
362 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 362 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
363 new base::FundamentalValue(true)); | 363 new base::Value(true)); |
364 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); | 364 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); |
365 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 365 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
366 | 366 |
367 // Functionality disabled in Incognito mode. | 367 // Functionality disabled in Incognito mode. |
368 profile()->ForceIncognito(true); | 368 profile()->ForceIncognito(true); |
369 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 369 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
370 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 370 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
371 | 371 |
372 // Functionality disabled in Incognito mode also when manager itself is | 372 // Functionality disabled in Incognito mode also when manager itself is |
373 // enabled. | 373 // enabled. |
374 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 374 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
375 new base::FundamentalValue(true)); | 375 new base::Value(true)); |
376 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 376 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
377 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 377 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
378 profile()->ForceIncognito(false); | 378 profile()->ForceIncognito(false); |
379 } | 379 } |
380 | 380 |
381 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { | 381 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { |
382 EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); | 382 EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); |
383 } | 383 } |
384 | 384 |
385 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { | 385 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // In particular, this WebContent should not have the | 519 // In particular, this WebContent should not have the |
520 // ChromePasswordManagerClient. | 520 // ChromePasswordManagerClient. |
521 ASSERT_FALSE( | 521 ASSERT_FALSE( |
522 ChromePasswordManagerClient::FromWebContents(web_contents.get())); | 522 ChromePasswordManagerClient::FromWebContents(web_contents.get())); |
523 | 523 |
524 // This call should not crash. | 524 // This call should not crash. |
525 ChromePasswordManagerClient::BindCredentialManager( | 525 ChromePasswordManagerClient::BindCredentialManager( |
526 web_contents->GetMainFrame(), | 526 web_contents->GetMainFrame(), |
527 password_manager::mojom::CredentialManagerRequest()); | 527 password_manager::mojom::CredentialManagerRequest()); |
528 } | 528 } |
OLD | NEW |