| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "chrome/browser/content_settings/cookie_settings.h" | 7 #include "chrome/browser/content_settings/cookie_settings.h" |
| 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 EnableOneClick(true); | 531 EnableOneClick(true); |
| 532 EXPECT_TRUE(OneClickSigninHelper::CanOffer( | 532 EXPECT_TRUE(OneClickSigninHelper::CanOffer( |
| 533 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, | 533 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, |
| 534 "user@gmail.com", NULL)); | 534 "user@gmail.com", NULL)); |
| 535 | 535 |
| 536 // Simulate a policy disabling sync by writing kSyncManaged directly. | 536 // Simulate a policy disabling sync by writing kSyncManaged directly. |
| 537 profile_->GetTestingPrefService()->SetManagedPref( | 537 profile_->GetTestingPrefService()->SetManagedPref( |
| 538 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 538 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); |
| 539 | 539 |
| 540 EXPECT_FALSE(OneClickSigninHelper::CanOffer( | 540 // Should still offer even if sync is disabled by policy. |
| 541 EXPECT_TRUE(OneClickSigninHelper::CanOffer( |
| 541 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, | 542 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, |
| 542 "user@gmail.com", NULL)); | 543 "user@gmail.com", NULL)); |
| 543 } | 544 } |
| 544 | 545 |
| 545 // Should not crash if a helper instance is not associated with an incognito | 546 // Should not crash if a helper instance is not associated with an incognito |
| 546 // web contents. | 547 // web contents. |
| 547 TEST_F(OneClickSigninHelperTest, ShowInfoBarUIThreadIncognito) { | 548 TEST_F(OneClickSigninHelperTest, ShowInfoBarUIThreadIncognito) { |
| 548 CreateSigninManager(true, ""); | 549 CreateSigninManager(true, ""); |
| 549 OneClickSigninHelper* helper = | 550 OneClickSigninHelper* helper = |
| 550 OneClickSigninHelper::FromWebContents(web_contents()); | 551 OneClickSigninHelper::FromWebContents(web_contents()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 valid_gaia_url_, "", &request_, io_data.get())); | 684 valid_gaia_url_, "", &request_, io_data.get())); |
| 684 } | 685 } |
| 685 | 686 |
| 686 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) { | 687 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) { |
| 687 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false)); | 688 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false)); |
| 688 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, | 689 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
| 689 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 690 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
| 690 valid_gaia_url_, "", &request_, io_data.get())); | 691 valid_gaia_url_, "", &request_, io_data.get())); |
| 691 | 692 |
| 692 // Simulate a policy disabling sync by writing kSyncManaged directly. | 693 // Simulate a policy disabling sync by writing kSyncManaged directly. |
| 694 // We should still offer to sign in the browser. |
| 693 profile_->GetTestingPrefService()->SetManagedPref( | 695 profile_->GetTestingPrefService()->SetManagedPref( |
| 694 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 696 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); |
| 695 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, | 697 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
| 696 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 698 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
| 697 valid_gaia_url_, "", &request_, io_data.get())); | 699 valid_gaia_url_, "", &request_, io_data.get())); |
| 698 } | 700 } |
| OLD | NEW |