| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 scoped_ptr<OAuth2MintTokenFlow> flow_; | 389 scoped_ptr<OAuth2MintTokenFlow> flow_; |
| 390 | 390 |
| 391 std::string login_access_token_; | 391 std::string login_access_token_; |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 class MockQueuedMintRequest : public IdentityMintRequestQueue::Request { | 394 class MockQueuedMintRequest : public IdentityMintRequestQueue::Request { |
| 395 public: | 395 public: |
| 396 MOCK_METHOD1(StartMintToken, void(IdentityMintRequestQueue::MintType)); | 396 MOCK_METHOD1(StartMintToken, void(IdentityMintRequestQueue::MintType)); |
| 397 }; | 397 }; |
| 398 | 398 |
| 399 gaia::AccountIds CreateIds(std::string email, std::string obfid) { | 399 gaia::AccountIds CreateIds(const std::string& email, const std::string& obfid) { |
| 400 gaia::AccountIds ids; | 400 gaia::AccountIds ids; |
| 401 ids.account_key = email; | 401 ids.account_key = email; |
| 402 ids.email = email; | 402 ids.email = email; |
| 403 ids.gaia = obfid; | 403 ids.gaia = obfid; |
| 404 return ids; | 404 return ids; |
| 405 } | 405 } |
| 406 | 406 |
| 407 class IdentityGetAccountsFunctionTest : public ExtensionBrowserTest { | 407 class IdentityGetAccountsFunctionTest : public ExtensionBrowserTest { |
| 408 void SetUpCommandLine(base::CommandLine* command_line) override { | 408 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 409 ExtensionBrowserTest::SetUpCommandLine(command_line); | 409 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 EXPECT_TRUE(info->id.empty()); | 663 EXPECT_TRUE(info->id.empty()); |
| 664 } | 664 } |
| 665 | 665 |
| 666 class GetAuthTokenFunctionTest : public IdentityTestWithSignin { | 666 class GetAuthTokenFunctionTest : public IdentityTestWithSignin { |
| 667 public: | 667 public: |
| 668 void SetUpCommandLine(base::CommandLine* command_line) override { | 668 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 669 IdentityTestWithSignin::SetUpCommandLine(command_line); | 669 IdentityTestWithSignin::SetUpCommandLine(command_line); |
| 670 command_line->AppendSwitch(switches::kExtensionsMultiAccount); | 670 command_line->AppendSwitch(switches::kExtensionsMultiAccount); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void IssueLoginRefreshTokenForAccount(const std::string account_key) { | 673 void IssueLoginRefreshTokenForAccount(const std::string& account_key) { |
| 674 token_service_->UpdateCredentials(account_key, "refresh_token"); | 674 token_service_->UpdateCredentials(account_key, "refresh_token"); |
| 675 } | 675 } |
| 676 | 676 |
| 677 void IssueLoginAccessTokenForAccount(const std::string account_key) { | 677 void IssueLoginAccessTokenForAccount(const std::string& account_key) { |
| 678 token_service_->IssueAllTokensForAccount( | 678 token_service_->IssueAllTokensForAccount( |
| 679 account_key, | 679 account_key, |
| 680 "access_token-" + account_key, | 680 "access_token-" + account_key, |
| 681 base::Time::Now() + base::TimeDelta::FromSeconds(3600)); | 681 base::Time::Now() + base::TimeDelta::FromSeconds(3600)); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void SetAccountState(gaia::AccountIds ids, bool is_signed_in) { | 684 void SetAccountState(gaia::AccountIds ids, bool is_signed_in) { |
| 685 IdentityAPI::GetFactoryInstance()->Get(profile())->SetAccountStateForTest( | 685 IdentityAPI::GetFactoryInstance()->Get(profile())->SetAccountStateForTest( |
| 686 ids, is_signed_in); | 686 ids, is_signed_in); |
| 687 } | 687 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 SigninManagerBase* signin_manager = | 731 SigninManagerBase* signin_manager = |
| 732 SigninManagerFactory::GetForProfile(browser()->profile()); | 732 SigninManagerFactory::GetForProfile(browser()->profile()); |
| 733 return signin_manager->GetAuthenticatedAccountId(); | 733 return signin_manager->GetAuthenticatedAccountId(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 void SetCachedToken(const IdentityTokenCacheValue& token_data) { | 736 void SetCachedToken(const IdentityTokenCacheValue& token_data) { |
| 737 ExtensionTokenKey key(extension_id_, GetPrimaryAccountId(), oauth_scopes_); | 737 ExtensionTokenKey key(extension_id_, GetPrimaryAccountId(), oauth_scopes_); |
| 738 id_api()->SetCachedToken(key, token_data); | 738 id_api()->SetCachedToken(key, token_data); |
| 739 } | 739 } |
| 740 | 740 |
| 741 const IdentityTokenCacheValue& GetCachedToken(std::string account_id) { | 741 const IdentityTokenCacheValue& GetCachedToken(const std::string& account_id) { |
| 742 if (account_id.empty()) | 742 ExtensionTokenKey key( |
| 743 account_id = GetPrimaryAccountId(); | 743 extension_id_, account_id.empty() ? GetPrimaryAccountId() : account_id, |
| 744 ExtensionTokenKey key(extension_id_, account_id, oauth_scopes_); | 744 oauth_scopes_); |
| 745 return id_api()->GetCachedToken(key); | 745 return id_api()->GetCachedToken(key); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void QueueRequestStart(IdentityMintRequestQueue::MintType type, | 748 void QueueRequestStart(IdentityMintRequestQueue::MintType type, |
| 749 IdentityMintRequestQueue::Request* request) { | 749 IdentityMintRequestQueue::Request* request) { |
| 750 ExtensionTokenKey key(extension_id_, GetPrimaryAccountId(), oauth_scopes_); | 750 ExtensionTokenKey key(extension_id_, GetPrimaryAccountId(), oauth_scopes_); |
| 751 id_api()->mint_queue()->RequestStart(type, key, request); | 751 id_api()->mint_queue()->RequestStart(type, key, request); |
| 752 } | 752 } |
| 753 | 753 |
| 754 void QueueRequestComplete(IdentityMintRequestQueue::MintType type, | 754 void QueueRequestComplete(IdentityMintRequestQueue::MintType type, |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1837 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
| 1838 url); | 1838 url); |
| 1839 } | 1839 } |
| 1840 | 1840 |
| 1841 } // namespace extensions | 1841 } // namespace extensions |
| 1842 | 1842 |
| 1843 // Tests the chrome.identity API implemented by custom JS bindings . | 1843 // Tests the chrome.identity API implemented by custom JS bindings . |
| 1844 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1844 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
| 1845 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1845 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
| 1846 } | 1846 } |
| OLD | NEW |