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/utf_string_conversions.h" | 6 #include "base/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" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/profiles/profile_info_cache.h" | 12 #include "chrome/browser/profiles/profile_info_cache.h" |
13 #include "chrome/browser/profiles/profile_io_data.h" | 13 #include "chrome/browser/profiles/profile_io_data.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/signin/signin_manager.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/browser/signin/signin_manager_fake.h" | 17 #include "chrome/browser/signin/signin_manager_fake.h" |
17 #include "chrome/browser/signin/signin_names_io_thread.h" | 18 #include "chrome/browser/signin/signin_names_io_thread.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_service_mock.h" | 20 #include "chrome/browser/sync/profile_sync_service_mock.h" |
20 #include "chrome/browser/sync/test_profile_sync_service.h" | 21 #include "chrome/browser/sync/test_profile_sync_service.h" |
21 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 22 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
24 #include "chrome/test/base/testing_pref_service_syncable.h" | 25 #include "chrome/test/base/testing_pref_service_syncable.h" |
(...skipping 21 matching lines...) Expand all Loading... |
46 // points. Implicit URLs are those to sign for some Google service, like gmail | 47 // points. Implicit URLs are those to sign for some Google service, like gmail |
47 // or drive. In former case, with a valid URL, we don't want to offer the | 48 // or drive. In former case, with a valid URL, we don't want to offer the |
48 // interstitial. In all other cases we do. | 49 // interstitial. In all other cases we do. |
49 | 50 |
50 const char kImplicitURLString[] = | 51 const char kImplicitURLString[] = |
51 "https://accounts.google.com/ServiceLogin" | 52 "https://accounts.google.com/ServiceLogin" |
52 "?service=foo&continue=http://foo.google.com"; | 53 "?service=foo&continue=http://foo.google.com"; |
53 | 54 |
54 class SigninManagerMock : public FakeSigninManager { | 55 class SigninManagerMock : public FakeSigninManager { |
55 public: | 56 public: |
56 explicit SigninManagerMock(Profile* profile) | 57 explicit SigninManagerMock(Profile* profile) : FakeSigninManager(profile) { |
57 : FakeSigninManager(profile) {} | 58 } |
58 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); | 59 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); |
59 }; | 60 }; |
60 | 61 |
61 class TestProfileIOData : public ProfileIOData { | 62 class TestProfileIOData : public ProfileIOData { |
62 public: | 63 public: |
63 TestProfileIOData(bool is_incognito, PrefService* pref_service, | 64 TestProfileIOData(bool is_incognito, PrefService* pref_service, |
64 PrefService* local_state, CookieSettings* cookie_settings) | 65 PrefService* local_state, CookieSettings* cookie_settings) |
65 : ProfileIOData(is_incognito) { | 66 : ProfileIOData(is_incognito) { |
66 // Initialize the IO members required for these tests, but keep them on | 67 // Initialize the IO members required for these tests, but keep them on |
67 // this thread since we don't use a background thread here. | 68 // this thread since we don't use a background thread here. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 260 |
260 void OneClickSigninHelperTest::CreateSigninManager( | 261 void OneClickSigninHelperTest::CreateSigninManager( |
261 bool use_incognito, | 262 bool use_incognito, |
262 const std::string& username) { | 263 const std::string& username) { |
263 profile_->set_incognito(use_incognito); | 264 profile_->set_incognito(use_incognito); |
264 signin_manager_ = static_cast<SigninManagerMock*>( | 265 signin_manager_ = static_cast<SigninManagerMock*>( |
265 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 266 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
266 profile_, BuildSigninManagerMock)); | 267 profile_, BuildSigninManagerMock)); |
267 if (signin_manager_) | 268 if (signin_manager_) |
268 signin_manager_->SetSigninProcess(trusted_signin_process_id_); | 269 signin_manager_->SetSigninProcess(trusted_signin_process_id_); |
| 270 |
269 if (!username.empty()) { | 271 if (!username.empty()) { |
270 ASSERT_TRUE(signin_manager_); | 272 ASSERT_TRUE(signin_manager_); |
271 signin_manager_->StartSignIn(username, std::string(), std::string(), | 273 signin_manager_->SetAuthenticatedUsername(username); |
272 std::string()); | |
273 } | 274 } |
274 } | 275 } |
275 | 276 |
276 void OneClickSigninHelperTest::EnableOneClick(bool enable) { | 277 void OneClickSigninHelperTest::EnableOneClick(bool enable) { |
277 PrefService* pref_service = Profile::FromBrowserContext( | 278 PrefService* pref_service = Profile::FromBrowserContext( |
278 browser_context_.get())->GetPrefs(); | 279 browser_context_.get())->GetPrefs(); |
279 pref_service->SetBoolean(prefs::kReverseAutologinEnabled, enable); | 280 pref_service->SetBoolean(prefs::kReverseAutologinEnabled, enable); |
280 } | 281 } |
281 | 282 |
282 void OneClickSigninHelperTest::AddEmailToOneClickRejectedList( | 283 void OneClickSigninHelperTest::AddEmailToOneClickRejectedList( |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); | 866 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); |
866 | 867 |
867 // Simulate a policy disabling sync by writing kSyncManaged directly. | 868 // Simulate a policy disabling sync by writing kSyncManaged directly. |
868 // We should still offer to sign in the browser. | 869 // We should still offer to sign in the browser. |
869 profile_->GetTestingPrefService()->SetManagedPref( | 870 profile_->GetTestingPrefService()->SetManagedPref( |
870 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 871 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); |
871 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, | 872 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
872 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 873 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
873 valid_gaia_url_, "", &request_, io_data.get())); | 874 valid_gaia_url_, "", &request_, io_data.get())); |
874 } | 875 } |
OLD | NEW |