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" |
11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "content/public/browser/storage_partition.h" | |
13 #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" | 12 #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" |
14 #include "extensions/shell/browser/shell_oauth2_token_service.h" | 13 #include "extensions/shell/browser/shell_oauth2_token_service.h" |
15 #include "extensions/shell/common/api/identity.h" | 14 #include "extensions/shell/common/api/identity.h" |
16 #include "google_apis/gaia/gaia_auth_util.h" | 15 #include "google_apis/gaia/gaia_auth_util.h" |
17 | 16 |
18 namespace extensions { | 17 namespace extensions { |
19 namespace shell { | 18 namespace shell { |
20 | 19 |
21 namespace { | 20 namespace { |
22 const char kIdentityApiId[] = "identity_api"; | 21 const char kIdentityApiId[] = "identity_api"; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 this, | 102 this, |
104 OAuth2MintTokenFlow::Parameters( | 103 OAuth2MintTokenFlow::Parameters( |
105 extension()->id(), | 104 extension()->id(), |
106 oauth2_info.client_id, | 105 oauth2_info.client_id, |
107 oauth2_info.scopes, | 106 oauth2_info.scopes, |
108 IdentityAPI::Get(browser_context())->device_id(), | 107 IdentityAPI::Get(browser_context())->device_id(), |
109 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE))); | 108 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE))); |
110 } | 109 } |
111 | 110 |
112 // Use the logging-in-user access token to mint an access token for this app. | 111 // Use the logging-in-user access token to mint an access token for this app. |
113 mint_token_flow_->Start( | 112 mint_token_flow_->Start(browser_context()->GetRequestContext(), access_token); |
114 content::BrowserContext::GetDefaultStoragePartition(browser_context())-> | |
115 GetURLRequestContext(), | |
116 access_token); | |
117 } | 113 } |
118 | 114 |
119 void IdentityGetAuthTokenFunction::OnGetTokenFailure( | 115 void IdentityGetAuthTokenFunction::OnGetTokenFailure( |
120 const OAuth2TokenService::Request* request, | 116 const OAuth2TokenService::Request* request, |
121 const GoogleServiceAuthError& error) { | 117 const GoogleServiceAuthError& error) { |
122 Respond(Error(error.ToString())); | 118 Respond(Error(error.ToString())); |
123 Release(); // Balanced in Run(). | 119 Release(); // Balanced in Run(). |
124 } | 120 } |
125 | 121 |
126 void IdentityGetAuthTokenFunction::OnMintTokenSuccess( | 122 void IdentityGetAuthTokenFunction::OnMintTokenSuccess( |
(...skipping 28 matching lines...) Expand all Loading... |
155 scoped_ptr<api::identity::RemoveCachedAuthToken::Params> params( | 151 scoped_ptr<api::identity::RemoveCachedAuthToken::Params> params( |
156 api::identity::RemoveCachedAuthToken::Params::Create(*args_)); | 152 api::identity::RemoveCachedAuthToken::Params::Create(*args_)); |
157 EXTENSION_FUNCTION_VALIDATE(params.get()); | 153 EXTENSION_FUNCTION_VALIDATE(params.get()); |
158 // This stub identity API does not maintain a token cache, so there is nothing | 154 // This stub identity API does not maintain a token cache, so there is nothing |
159 // to remove. | 155 // to remove. |
160 return RespondNow(NoArguments()); | 156 return RespondNow(NoArguments()); |
161 } | 157 } |
162 | 158 |
163 } // namespace shell | 159 } // namespace shell |
164 } // namespace extensions | 160 } // namespace extensions |
OLD | NEW |