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/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/content_settings/cookie_settings.h" | 8 #include "chrome/browser/content_settings/cookie_settings.h" |
9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
10 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 10 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 void OneClickSigninHelperTest::AddEmailToOneClickRejectedList( | 281 void OneClickSigninHelperTest::AddEmailToOneClickRejectedList( |
282 const std::string& email) { | 282 const std::string& email) { |
283 PrefService* pref_service = Profile::FromBrowserContext( | 283 PrefService* pref_service = Profile::FromBrowserContext( |
284 browser_context_.get())->GetPrefs(); | 284 browser_context_.get())->GetPrefs(); |
285 ListPrefUpdate updater(pref_service, | 285 ListPrefUpdate updater(pref_service, |
286 prefs::kReverseAutologinRejectedEmailList); | 286 prefs::kReverseAutologinRejectedEmailList); |
287 updater->AppendIfNotPresent(new base::StringValue(email)); | 287 updater->AppendIfNotPresent(new base::StringValue(email)); |
288 } | 288 } |
289 | 289 |
290 void OneClickSigninHelperTest::AllowSigninCookies(bool enable) { | 290 void OneClickSigninHelperTest::AllowSigninCookies(bool enable) { |
291 CookieSettings* cookie_settings = | 291 CookieSettings* cookie_settings = CookieSettings::Factory::GetForProfile( |
292 CookieSettings::Factory::GetForProfile( | 292 Profile::FromBrowserContext(browser_context_.get())).get(); |
293 Profile::FromBrowserContext(browser_context_.get())); | 293 cookie_settings->SetDefaultCookieSetting(enable ? CONTENT_SETTING_ALLOW |
294 cookie_settings->SetDefaultCookieSetting( | 294 : CONTENT_SETTING_BLOCK); |
295 enable ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | |
296 } | 295 } |
297 | 296 |
298 void OneClickSigninHelperTest::SetAllowedUsernamePattern( | 297 void OneClickSigninHelperTest::SetAllowedUsernamePattern( |
299 const std::string& pattern) { | 298 const std::string& pattern) { |
300 PrefService* local_state = g_browser_process->local_state(); | 299 PrefService* local_state = g_browser_process->local_state(); |
301 local_state->SetString(prefs::kGoogleServicesUsernamePattern, pattern); | 300 local_state->SetString(prefs::kGoogleServicesUsernamePattern, pattern); |
302 } | 301 } |
303 | 302 |
304 ProfileSyncServiceMock* | 303 ProfileSyncServiceMock* |
305 OneClickSigninHelperTest::CreateProfileSyncServiceMock() { | 304 OneClickSigninHelperTest::CreateProfileSyncServiceMock() { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 void OneClickSigninHelperIOTest::SetUp() { | 351 void OneClickSigninHelperIOTest::SetUp() { |
353 OneClickSigninHelperTest::SetUp(); | 352 OneClickSigninHelperTest::SetUp(); |
354 ASSERT_TRUE(testing_profile_manager_.SetUp()); | 353 ASSERT_TRUE(testing_profile_manager_.SetUp()); |
355 } | 354 } |
356 | 355 |
357 TestProfileIOData* OneClickSigninHelperIOTest::CreateTestProfileIOData( | 356 TestProfileIOData* OneClickSigninHelperIOTest::CreateTestProfileIOData( |
358 bool is_incognito) { | 357 bool is_incognito) { |
359 PrefService* pref_service = profile_->GetPrefs(); | 358 PrefService* pref_service = profile_->GetPrefs(); |
360 PrefService* local_state = g_browser_process->local_state(); | 359 PrefService* local_state = g_browser_process->local_state(); |
361 CookieSettings* cookie_settings = | 360 CookieSettings* cookie_settings = |
362 CookieSettings::Factory::GetForProfile(profile_); | 361 CookieSettings::Factory::GetForProfile(profile_).get(); |
363 TestProfileIOData* io_data = new TestProfileIOData( | 362 TestProfileIOData* io_data = new TestProfileIOData( |
364 is_incognito, pref_service, local_state, cookie_settings); | 363 is_incognito, pref_service, local_state, cookie_settings); |
365 io_data->set_reverse_autologin_pending_email("user@gmail.com"); | 364 io_data->set_reverse_autologin_pending_email("user@gmail.com"); |
366 return io_data; | 365 return io_data; |
367 } | 366 } |
368 | 367 |
369 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) { | 368 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) { |
370 std::string error_message; | 369 std::string error_message; |
371 EXPECT_FALSE(OneClickSigninHelper::CanOffer( | 370 EXPECT_FALSE(OneClickSigninHelper::CanOffer( |
372 NULL, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, | 371 NULL, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); | 818 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); |
820 | 819 |
821 // Simulate a policy disabling sync by writing kSyncManaged directly. | 820 // Simulate a policy disabling sync by writing kSyncManaged directly. |
822 // We should still offer to sign in the browser. | 821 // We should still offer to sign in the browser. |
823 profile_->GetTestingPrefService()->SetManagedPref( | 822 profile_->GetTestingPrefService()->SetManagedPref( |
824 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 823 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); |
825 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, | 824 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
826 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 825 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
827 valid_gaia_url_, std::string(), &request_, io_data.get())); | 826 valid_gaia_url_, std::string(), &request_, io_data.get())); |
828 } | 827 } |
OLD | NEW |