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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 signin_manager_ = static_cast<FakeSigninManagerForTesting*>( | 566 signin_manager_ = static_cast<FakeSigninManagerForTesting*>( |
567 SigninManagerFactory::GetInstance()->GetForProfile(profile())); | 567 SigninManagerFactory::GetInstance()->GetForProfile(profile())); |
568 ASSERT_TRUE(signin_manager_); | 568 ASSERT_TRUE(signin_manager_); |
569 token_service_ = static_cast<FakeProfileOAuth2TokenService*>( | 569 token_service_ = static_cast<FakeProfileOAuth2TokenService*>( |
570 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( | 570 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( |
571 profile())); | 571 profile())); |
572 ASSERT_TRUE(token_service_); | 572 ASSERT_TRUE(token_service_); |
573 } | 573 } |
574 | 574 |
575 protected: | 575 protected: |
576 void SignIn(const std::string account_key) { | 576 void SignIn(const std::string& account_key) { |
577 #if defined(OS_CHROMEOS) | 577 SignIn(account_key, account_key); |
578 signin_manager_->SetAuthenticatedUsername(account_key); | |
579 #else | |
580 signin_manager_->SignIn(account_key, "password"); | |
581 #endif | |
582 token_service_->IssueRefreshTokenForUser(account_key, "refresh_token"); | |
583 } | 578 } |
584 | 579 |
585 void SignIn(const std::string& account_key, const std::string& gaia) { | 580 void SignIn(const std::string& email, const std::string& gaia) { |
586 AccountTrackerService* account_tracker = | 581 AccountTrackerService* account_tracker = |
587 AccountTrackerServiceFactory::GetForProfile(profile()); | 582 AccountTrackerServiceFactory::GetForProfile(profile()); |
588 account_tracker->SeedAccountInfo(gaia, account_key); | 583 std::string account_id = |
589 SignIn(account_key); | 584 account_tracker->SeedAccountInfo(gaia, email); |
| 585 |
| 586 #if defined(OS_CHROMEOS) |
| 587 signin_manager_->SetAuthenticatedAccountInfo(gaia, email); |
| 588 #else |
| 589 signin_manager_->SignIn(gaia, email, "password"); |
| 590 #endif |
| 591 token_service_->IssueRefreshTokenForUser(account_id, "refresh_token"); |
590 } | 592 } |
591 | 593 |
592 FakeSigninManagerForTesting* signin_manager_; | 594 FakeSigninManagerForTesting* signin_manager_; |
593 FakeProfileOAuth2TokenService* token_service_; | 595 FakeProfileOAuth2TokenService* token_service_; |
594 | 596 |
595 scoped_ptr<base::CallbackList<void(content::BrowserContext*)>::Subscription> | 597 scoped_ptr<base::CallbackList<void(content::BrowserContext*)>::Subscription> |
596 will_create_browser_context_services_subscription_; | 598 will_create_browser_context_services_subscription_; |
597 }; | 599 }; |
598 | 600 |
599 class IdentityGetProfileUserInfoFunctionTest : public IdentityTestWithSignin { | 601 class IdentityGetProfileUserInfoFunctionTest : public IdentityTestWithSignin { |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1823 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1822 url); | 1824 url); |
1823 } | 1825 } |
1824 | 1826 |
1825 } // namespace extensions | 1827 } // namespace extensions |
1826 | 1828 |
1827 // Tests the chrome.identity API implemented by custom JS bindings . | 1829 // Tests the chrome.identity API implemented by custom JS bindings . |
1828 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1830 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1829 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1831 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1830 } | 1832 } |
OLD | NEW |