| Index: chrome/browser/extensions/api/identity/identity_apitest.cc
|
| diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
|
| index 1ca9740ade6f2a4faec962f48dec86c998dad384..aeda52f1aede10fcae0870a11540945ecab87270 100644
|
| --- a/chrome/browser/extensions/api/identity/identity_apitest.cc
|
| +++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
|
| @@ -383,9 +383,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| NonInteractiveMintAdviceSuccess) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| - EXPECT_CALL(*func.get(), HasLoginToken())
|
| - .WillOnce(Return(true));
|
| + func->set_extension(extension.get());
|
| + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
|
| EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
|
| @@ -395,10 +394,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| EXPECT_FALSE(func->login_ui_shown());
|
| EXPECT_FALSE(func->scope_ui_shown());
|
|
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| - EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_ADVICE,
|
| - id_api()->GetCachedToken(extension->id(),
|
| - oauth2_info.scopes).status());
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| + EXPECT_EQ(
|
| + IdentityTokenCacheValue::CACHE_STATUS_ADVICE,
|
| + id_api()->GetCachedToken(extension->id(), oauth2_info.scopes).status());
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| @@ -421,10 +420,9 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| NonInteractiveSuccess) {
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| - func->set_extension(extension);
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| - EXPECT_CALL(*func.get(), HasLoginToken())
|
| - .WillOnce(Return(true));
|
| + func->set_extension(extension.get());
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::MINT_TOKEN_SUCCESS, func.get());
|
| EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
|
| @@ -541,9 +539,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| InteractiveLoginSuccessApprovalSuccess) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| - EXPECT_CALL(*func.get(), HasLoginToken())
|
| - .WillOnce(Return(false));
|
| + func->set_extension(extension.get());
|
| + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(false));
|
| func->set_login_ui_result(true);
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
|
| @@ -643,7 +640,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| ++it) {
|
| scoped_refptr<MockGetAuthTokenFunction> func(
|
| new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
| EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
|
| @@ -660,11 +657,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| InteractiveApprovalSuccess) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| - EXPECT_CALL(*func.get(), HasLoginToken())
|
| - .WillOnce(Return(true));
|
| + func->set_extension(extension.get());
|
| + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
|
| EXPECT_CALL(*func.get(), CreateMintTokenFlow(_))
|
| @@ -686,10 +682,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // Create a fake request to block the queue.
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| std::set<std::string> scopes(oauth2_info.scopes.begin(),
|
| oauth2_info.scopes.end());
|
| IdentityAPI* id_api =
|
| @@ -706,9 +702,9 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
|
| // The real request will start processing, but wait in the queue behind
|
| // the blocker.
|
| EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
|
| - RunFunctionAsync(func, "[{}]");
|
| + RunFunctionAsync(func.get(), "[{}]");
|
| // Verify that we have fetched the login token at this point.
|
| - testing::Mock::VerifyAndClearExpectations(func);
|
| + testing::Mock::VerifyAndClearExpectations(func.get());
|
|
|
| // The flow will be created after the first queued request clears.
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| @@ -717,7 +713,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
|
|
|
| queue->RequestComplete(type, extension->id(), scopes, &queued_request);
|
|
|
| - scoped_ptr<base::Value> value(WaitForSingleResult(func));
|
| + scoped_ptr<base::Value> value(WaitForSingleResult(func.get()));
|
| std::string access_token;
|
| EXPECT_TRUE(value->GetAsString(&access_token));
|
| EXPECT_EQ(std::string(kAccessToken), access_token);
|
| @@ -728,10 +724,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
|
| IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueue) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // Create a fake request to block the queue.
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| std::set<std::string> scopes(oauth2_info.scopes.begin(),
|
| oauth2_info.scopes.end());
|
| IdentityAPI* id_api =
|
| @@ -751,16 +747,16 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueue) {
|
| TestOAuth2MintTokenFlow* flow1 = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
|
| EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow1));
|
| - RunFunctionAsync(func, "[{\"interactive\": true}]");
|
| + RunFunctionAsync(func.get(), "[{\"interactive\": true}]");
|
| // Verify that we have fetched the login token and run the first flow.
|
| - testing::Mock::VerifyAndClearExpectations(func);
|
| + testing::Mock::VerifyAndClearExpectations(func.get());
|
| EXPECT_FALSE(func->scope_ui_shown());
|
|
|
| // The UI will be displayed and a token retrieved after the first
|
| // queued request clears.
|
| queue->RequestComplete(type, extension->id(), scopes, &queued_request);
|
|
|
| - scoped_ptr<base::Value> value(WaitForSingleResult(func));
|
| + scoped_ptr<base::Value> value(WaitForSingleResult(func.get()));
|
| std::string access_token;
|
| EXPECT_TRUE(value->GetAsString(&access_token));
|
| EXPECT_EQ(std::string(kAccessToken), access_token);
|
| @@ -772,10 +768,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| InteractiveQueuedNoninteractiveFails) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // Create a fake request to block the interactive queue.
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| std::set<std::string> scopes(oauth2_info.scopes.begin(),
|
| oauth2_info.scopes.end());
|
| IdentityAPI* id_api =
|
| @@ -805,10 +801,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| NonInteractiveCacheHit) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // pre-populate the cache with a token
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| IdentityTokenCacheValue token(kAccessToken,
|
| base::TimeDelta::FromSeconds(3600));
|
| id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token);
|
| @@ -829,10 +825,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| NonInteractiveIssueAdviceCacheHit) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // pre-populate the cache with advice
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| IssueAdviceInfo info;
|
| IdentityTokenCacheValue token(info);
|
| id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token);
|
| @@ -851,10 +847,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| InteractiveCacheHit) {
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // Create a fake request to block the queue.
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| std::set<std::string> scopes(oauth2_info.scopes.begin(),
|
| oauth2_info.scopes.end());
|
| IdentityMintRequestQueue* queue = id_api()->mint_queue();
|
| @@ -871,7 +867,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
|
| TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
|
| EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
|
| - RunFunctionAsync(func, "[{\"interactive\": true}]");
|
| + RunFunctionAsync(func.get(), "[{\"interactive\": true}]");
|
|
|
| // Populate the cache with a token while the request is blocked.
|
| IdentityTokenCacheValue token(kAccessToken,
|
| @@ -883,7 +879,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
|
|
| queue->RequestComplete(type, extension->id(), scopes, &queued_request);
|
|
|
| - scoped_ptr<base::Value> value(WaitForSingleResult(func));
|
| + scoped_ptr<base::Value> value(WaitForSingleResult(func.get()));
|
| std::string access_token;
|
| EXPECT_TRUE(value->GetAsString(&access_token));
|
| EXPECT_EQ(std::string(kAccessToken), access_token);
|
| @@ -895,10 +891,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
|
| LoginInvalidatesTokenCache) {
|
| scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
|
| - func->set_extension(extension);
|
| + func->set_extension(extension.get());
|
|
|
| // pre-populate the cache with a token
|
| - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
|
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
|
| IdentityTokenCacheValue token(kAccessToken,
|
| base::TimeDelta::FromSeconds(3600));
|
| id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token);
|
| @@ -932,7 +928,9 @@ class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest {
|
| new IdentityRemoveCachedAuthTokenFunction);
|
| func->set_extension(utils::CreateEmptyExtension(kExtensionId));
|
| return utils::RunFunction(
|
| - func, std::string("[{\"token\": \"") + kAccessToken + "\"}]", browser(),
|
| + func.get(),
|
| + std::string("[{\"token\": \"") + kAccessToken + "\"}]",
|
| + browser(),
|
| extension_function_test_utils::NONE);
|
| }
|
|
|
| @@ -1014,11 +1012,11 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, UserCloseWindow) {
|
|
|
| std::string args = "[{\"interactive\": true, \"url\": \"" +
|
| auth_url.spec() + "\"}]";
|
| - RunFunctionAsync(function, args);
|
| + RunFunctionAsync(function.get(), args);
|
|
|
| popup_observer.Wait();
|
|
|
| - EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function));
|
| + EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get()));
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) {
|
| @@ -1038,8 +1036,8 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) {
|
|
|
| std::string args = "[{\"interactive\": false, \"url\": \"" +
|
| auth_url.spec() + "\"}]";
|
| - std::string error = utils::RunFunctionAndReturnError(function, args,
|
| - browser());
|
| + std::string error =
|
| + utils::RunFunctionAndReturnError(function.get(), args, browser());
|
|
|
| EXPECT_EQ(std::string(errors::kInteractionRequired), error);
|
| }
|
| @@ -1076,7 +1074,7 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) {
|
|
|
| function->InitFinalRedirectURLPrefixForTest("abcdefghij");
|
| scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
|
| - function,
|
| + function.get(),
|
| "[{\"interactive\": false,"
|
| "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]",
|
| browser()));
|
| @@ -1097,7 +1095,7 @@ IN_PROC_BROWSER_TEST_F(
|
|
|
| function->InitFinalRedirectURLPrefixForTest("abcdefghij");
|
| scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
|
| - function,
|
| + function.get(),
|
| "[{\"interactive\": true,"
|
| "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]",
|
| browser()));
|
| @@ -1127,8 +1125,8 @@ IN_PROC_BROWSER_TEST_F(
|
| function->InitFinalRedirectURLPrefixForTest("abcdefghij");
|
| std::string args = "[{\"interactive\": true, \"url\": \"" +
|
| auth_url.spec() + "\"}]";
|
| - scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
|
| - function, args, browser()));
|
| + scoped_ptr<base::Value> value(
|
| + utils::RunFunctionAndReturnSingleResult(function.get(), args, browser()));
|
|
|
| std::string url;
|
| EXPECT_TRUE(value->GetAsString(&url));
|
|
|