| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/api/identity/identity_api.h" | 5 #include "extensions/shell/browser/api/identity/identity_api.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() { | 55 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 void IdentityGetAuthTokenFunction::SetMintTokenFlowForTesting( | 58 void IdentityGetAuthTokenFunction::SetMintTokenFlowForTesting( |
| 59 OAuth2MintTokenFlow* flow) { | 59 OAuth2MintTokenFlow* flow) { |
| 60 mint_token_flow_.reset(flow); | 60 mint_token_flow_.reset(flow); |
| 61 } | 61 } |
| 62 | 62 |
| 63 ExtensionFunction::ResponseAction IdentityGetAuthTokenFunction::Run() { | 63 ExtensionFunction::ResponseAction IdentityGetAuthTokenFunction::Run() { |
| 64 scoped_ptr<api::identity::GetAuthToken::Params> params( | 64 std::unique_ptr<api::identity::GetAuthToken::Params> params( |
| 65 api::identity::GetAuthToken::Params::Create(*args_)); | 65 api::identity::GetAuthToken::Params::Create(*args_)); |
| 66 EXTENSION_FUNCTION_VALIDATE(params.get()); | 66 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 67 | 67 |
| 68 ShellOAuth2TokenService* service = ShellOAuth2TokenService::GetInstance(); | 68 ShellOAuth2TokenService* service = ShellOAuth2TokenService::GetInstance(); |
| 69 std::string account_id = service->AccountId(); | 69 std::string account_id = service->AccountId(); |
| 70 if (account_id.empty()) | 70 if (account_id.empty()) |
| 71 return RespondNow(Error(kErrorNoUserAccount)); | 71 return RespondNow(Error(kErrorNoUserAccount)); |
| 72 | 72 |
| 73 if (!service->RefreshTokenIsAvailable(account_id)) | 73 if (!service->RefreshTokenIsAvailable(account_id)) |
| 74 return RespondNow(Error(kErrorNoRefreshToken)); | 74 return RespondNow(Error(kErrorNoRefreshToken)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 /////////////////////////////////////////////////////////////////////////////// | 145 /////////////////////////////////////////////////////////////////////////////// |
| 146 | 146 |
| 147 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() { | 147 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() { |
| 148 } | 148 } |
| 149 | 149 |
| 150 IdentityRemoveCachedAuthTokenFunction:: | 150 IdentityRemoveCachedAuthTokenFunction:: |
| 151 ~IdentityRemoveCachedAuthTokenFunction() { | 151 ~IdentityRemoveCachedAuthTokenFunction() { |
| 152 } | 152 } |
| 153 | 153 |
| 154 ExtensionFunction::ResponseAction IdentityRemoveCachedAuthTokenFunction::Run() { | 154 ExtensionFunction::ResponseAction IdentityRemoveCachedAuthTokenFunction::Run() { |
| 155 scoped_ptr<api::identity::RemoveCachedAuthToken::Params> params( | 155 std::unique_ptr<api::identity::RemoveCachedAuthToken::Params> params( |
| 156 api::identity::RemoveCachedAuthToken::Params::Create(*args_)); | 156 api::identity::RemoveCachedAuthToken::Params::Create(*args_)); |
| 157 EXTENSION_FUNCTION_VALIDATE(params.get()); | 157 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 158 // This stub identity API does not maintain a token cache, so there is nothing | 158 // This stub identity API does not maintain a token cache, so there is nothing |
| 159 // to remove. | 159 // to remove. |
| 160 return RespondNow(NoArguments()); | 160 return RespondNow(NoArguments()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace shell | 163 } // namespace shell |
| 164 } // namespace extensions | 164 } // namespace extensions |
| OLD | NEW |