| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/webui/identity_internals_ui.h" | 5 #include "chrome/browser/ui/webui/identity_internals_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 DISALLOW_COPY_AND_ASSIGN(IdentityInternalsTokenRevoker); | 134 DISALLOW_COPY_AND_ASSIGN(IdentityInternalsTokenRevoker); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 IdentityInternalsUIMessageHandler::IdentityInternalsUIMessageHandler() {} | 137 IdentityInternalsUIMessageHandler::IdentityInternalsUIMessageHandler() {} |
| 138 | 138 |
| 139 IdentityInternalsUIMessageHandler::~IdentityInternalsUIMessageHandler() {} | 139 IdentityInternalsUIMessageHandler::~IdentityInternalsUIMessageHandler() {} |
| 140 | 140 |
| 141 void IdentityInternalsUIMessageHandler::OnTokenRevokerDone( | 141 void IdentityInternalsUIMessageHandler::OnTokenRevokerDone( |
| 142 IdentityInternalsTokenRevoker* token_revoker) { | 142 IdentityInternalsTokenRevoker* token_revoker) { |
| 143 // Remove token from the cache. | 143 // Remove token from the cache. |
| 144 extensions::IdentityAPI::GetFactoryInstance()->GetForProfile( | 144 extensions::IdentityAPI::GetFactoryInstance() |
| 145 Profile::FromWebUI(web_ui()))->EraseCachedToken( | 145 ->Get(Profile::FromWebUI(web_ui())) |
| 146 token_revoker->extension_id(), token_revoker->access_token()); | 146 ->EraseCachedToken(token_revoker->extension_id(), |
| 147 token_revoker->access_token()); |
| 147 | 148 |
| 148 // Update view about the token being removed. | 149 // Update view about the token being removed. |
| 149 base::ListValue result; | 150 base::ListValue result; |
| 150 result.AppendString(token_revoker->access_token()); | 151 result.AppendString(token_revoker->access_token()); |
| 151 web_ui()->CallJavascriptFunction("identity_internals.tokenRevokeDone", | 152 web_ui()->CallJavascriptFunction("identity_internals.tokenRevokeDone", |
| 152 result); | 153 result); |
| 153 | 154 |
| 154 // Erase the revoker. | 155 // Erase the revoker. |
| 155 ScopedVector<IdentityInternalsTokenRevoker>::iterator iter = | 156 ScopedVector<IdentityInternalsTokenRevoker>::iterator iter = |
| 156 std::find(token_revokers_.begin(), token_revokers_.end(), token_revoker); | 157 std::find(token_revokers_.begin(), token_revokers_.end(), token_revoker); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 token_data->SetString(kAccessToken, token_cache_value.token()); | 214 token_data->SetString(kAccessToken, token_cache_value.token()); |
| 214 token_data->SetString(kTokenExpirationTime, | 215 token_data->SetString(kTokenExpirationTime, |
| 215 GetExpirationTime(token_cache_value)); | 216 GetExpirationTime(token_cache_value)); |
| 216 return token_data; | 217 return token_data; |
| 217 } | 218 } |
| 218 | 219 |
| 219 void IdentityInternalsUIMessageHandler::GetInfoForAllTokens( | 220 void IdentityInternalsUIMessageHandler::GetInfoForAllTokens( |
| 220 const base::ListValue* args) { | 221 const base::ListValue* args) { |
| 221 base::ListValue results; | 222 base::ListValue results; |
| 222 extensions::IdentityAPI::CachedTokens tokens = | 223 extensions::IdentityAPI::CachedTokens tokens = |
| 223 extensions::IdentityAPI::GetFactoryInstance()->GetForProfile( | 224 extensions::IdentityAPI::GetFactoryInstance() |
| 224 Profile::FromWebUI(web_ui()))->GetAllCachedTokens(); | 225 ->Get(Profile::FromWebUI(web_ui())) |
| 226 ->GetAllCachedTokens(); |
| 225 for (extensions::IdentityAPI::CachedTokens::const_iterator | 227 for (extensions::IdentityAPI::CachedTokens::const_iterator |
| 226 iter = tokens.begin(); iter != tokens.end(); ++iter) { | 228 iter = tokens.begin(); iter != tokens.end(); ++iter) { |
| 227 results.Append(GetInfoForToken(iter->first, iter->second)); | 229 results.Append(GetInfoForToken(iter->first, iter->second)); |
| 228 } | 230 } |
| 229 | 231 |
| 230 web_ui()->CallJavascriptFunction("identity_internals.returnTokens", results); | 232 web_ui()->CallJavascriptFunction("identity_internals.returnTokens", results); |
| 231 } | 233 } |
| 232 | 234 |
| 233 void IdentityInternalsUIMessageHandler::RegisterMessages() { | 235 void IdentityInternalsUIMessageHandler::RegisterMessages() { |
| 234 web_ui()->RegisterMessageCallback("identityInternalsGetTokens", | 236 web_ui()->RegisterMessageCallback("identityInternalsGetTokens", |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 html_source->AddResourcePath("identity_internals.js", | 305 html_source->AddResourcePath("identity_internals.js", |
| 304 IDR_IDENTITY_INTERNALS_JS); | 306 IDR_IDENTITY_INTERNALS_JS); |
| 305 html_source->SetDefaultResource(IDR_IDENTITY_INTERNALS_HTML); | 307 html_source->SetDefaultResource(IDR_IDENTITY_INTERNALS_HTML); |
| 306 | 308 |
| 307 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); | 309 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); |
| 308 | 310 |
| 309 web_ui->AddMessageHandler(new IdentityInternalsUIMessageHandler()); | 311 web_ui->AddMessageHandler(new IdentityInternalsUIMessageHandler()); |
| 310 } | 312 } |
| 311 | 313 |
| 312 IdentityInternalsUI::~IdentityInternalsUI() {} | 314 IdentityInternalsUI::~IdentityInternalsUI() {} |
| OLD | NEW |