Commit 5e5ce0fa authored by fgorski@chromium.org's avatar fgorski@chromium.org

* Updating the code comments

* Renaming tokend ID to access token (including the id of the resource).
* Updating Token Id => Access Token in the resource file.

BUG=243143

Review URL: https://chromiumcodereview.appspot.com/17468008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207860 0039d316-1c4b-4281-b951-d872f2087c98
parent fd970f53
......@@ -15472,8 +15472,8 @@ Do you accept?
<message name="IDS_IDENTITY_INTERNALS_TOKEN_CACHE_TEXT" desc="The title of the token cache of the Identity API.">
Identity API Token Cache
</message>
<message name="IDS_IDENTITY_INTERNALS_TOKEN_ID" desc="Label of the row containing the token id.">
Token Id
<message name="IDS_IDENTITY_INTERNALS_ACCESS_TOKEN" desc="Label of the row containing the access token.">
Access Token
</message>
<message name="IDS_IDENTITY_INTERNALS_EXTENSION_NAME" desc="Label of the row containing a name of an extension related to the identity token.">
Extension Name
......
......@@ -7,7 +7,7 @@ cr.define('identity_internals', function() {
/**
* Creates an identity token item.
* @param {Object} tokenInfo Object containing token information.
* @param {!Object} tokenInfo Object containing token information.
* @constructor
*/
function TokenListItem(tokenInfo) {
......@@ -24,12 +24,12 @@ cr.define('identity_internals', function() {
/** @override */
decorate: function() {
this.textContent = '';
this.id = this.data_.tokenId;
this.id = this.data_.accessToken;
var table = this.ownerDocument.createElement('table');
var tbody = this.ownerDocument.createElement('tbody');
tbody.appendChild(this.createEntry_(
'tokenId', this.data_.tokenId, 'token-id'));
'accessToken', this.data_.accessToken, 'access-token'));
tbody.appendChild(this.createEntry_(
'extensionName', this.data_.extensionName, 'extension-name'));
tbody.appendChild(this.createEntry_(
......@@ -114,7 +114,7 @@ cr.define('identity_internals', function() {
revokeButton.classList.add('revoke-button');
revokeButton.addEventListener('click', function() {
chrome.send('identityInternalsRevokeToken',
[this.data_.extensionId, this.data_.tokenId]);
[this.data_.extensionId, this.data_.accessToken]);
}.bind(this));
revokeButton.textContent = loadTimeData.getString('revoke');
return revokeButton;
......@@ -150,13 +150,13 @@ cr.define('identity_internals', function() {
/**
* Removes a token node related to the specifed token ID from both the
* internals data source as well as the user internface.
* @param {string} tokenId The id of the token to remove.
* @param {string} accessToken The id of the token to remove.
* @private
*/
removeTokenNode_: function(tokenId) {
removeTokenNode_: function(accessToken) {
var tokenIndex;
for (var index = 0; index < this.data_.length; index++) {
if (this.data_[index].tokenId == tokenId) {
if (this.data_[index].accessToken == accessToken) {
tokenIndex = index;
break;
}
......@@ -167,7 +167,7 @@ cr.define('identity_internals', function() {
this.data_.splice(tokenIndex, 1);
// Remove from the user interface.
var tokenNode = $(tokenId);
var tokenNode = $(accessToken);
if (tokenNode)
this.removeChild(tokenNode);
},
......@@ -188,7 +188,7 @@ cr.define('identity_internals', function() {
/**
* Callback function accepting a list of tokens to be displayed.
* @param {Token[]} tokens A list of tokens to be displayed
* @param {!Token[]} tokens A list of tokens to be displayed
*/
function returnTokens(tokens) {
tokenList_.data_ = tokens;
......@@ -197,12 +197,12 @@ cr.define('identity_internals', function() {
/**
* Callback function that removes a token from UI once it has been revoked.
* @param {!Array.<string>} tokenIds Array with a single element, which is a
* token ID, of the token to be removed.
* @param {!Array.<string>} accessTokens Array with a single element, which is
* an access token to be removed.
*/
function tokenRevokeDone(tokenIds) {
assert(tokenIds.length > 0);
tokenList_.removeTokenNode_(tokenIds[0]);
function tokenRevokeDone(accessTokens) {
assert(accessTokens.length > 0);
tokenList_.removeTokenNode_(accessTokens[0]);
}
// Return an object with all of the exports.
......
......@@ -32,7 +32,7 @@ const char kExtensionName[] = "extensionName";
const char kScopes[] = "scopes";
const char kStatus[] = "status";
const char kTokenExpirationTime[] = "expirationTime";
const char kTokenId[] = "tokenId";
const char kAccessToken[] = "accessToken";
// RevokeToken message parameter offsets.
const int kRevokeTokenExtensionOffset = 0;
......@@ -40,6 +40,7 @@ const int kRevokeTokenTokenOffset = 1;
class IdentityInternalsTokenRevoker;
// Class acting as a controller of the chrome://identity-internals WebUI.
class IdentityInternalsUIMessageHandler : public content::WebUIMessageHandler {
public:
IdentityInternalsUIMessageHandler();
......@@ -54,26 +55,41 @@ class IdentityInternalsUIMessageHandler : public content::WebUIMessageHandler {
virtual void RegisterMessages() OVERRIDE;
private:
// Gets the name of an extension referred to by |token_cache_key| as a string.
const std::string GetExtensionName(
const extensions::IdentityAPI::TokenCacheKey& token_cache_key);
// Gets a list of scopes specified in |token_cache_key| and returns a pointer
// to a ListValue containing the scopes. The caller gets ownership of the
// returned object.
ListValue* GetScopes(
const extensions::IdentityAPI::TokenCacheKey& token_cache_key);
// Gets a localized status of the access token in |token_cache_value|.
const base::string16 GetStatus(
const extensions::IdentityTokenCacheValue& token_cache_value);
// Gets a string representation of an expiration time of the access token in
// |token_cache_value|.
const std::string GetExpirationTime(
const extensions::IdentityTokenCacheValue& token_cache_value);
// Converts a pair of |token_cache_key| and |token_cache_value| to a
// DictionaryValue object with corresponding information in a localized and
// readable form and returns a pointer to created object. Caller gets the
// ownership of the returned object.
DictionaryValue* GetInfoForToken(
const extensions::IdentityAPI::TokenCacheKey& token_cache_key,
const extensions::IdentityTokenCacheValue& token_cache_value);
// Gets all of the tokens stored in IdentityAPI token cache and returns them
// to the caller using Javascript callback function
// |identity_internals.returnTokens()|.
void GetInfoForAllTokens(const ListValue* args);
// Initiates revoking of the token, based on the extension ID and token
// passed as entries in the args list.
// passed as entries in the |args| list. Updates the caller of completion
// using Javascript callback function |identity_internals.tokenRevokeDone()|.
void RevokeToken(const ListValue* args);
// A vector of token revokers that are currently revoking tokens.
......@@ -192,7 +208,7 @@ DictionaryValue* IdentityInternalsUIMessageHandler::GetInfoForToken(
token_data->SetString(kExtensionName, GetExtensionName(token_cache_key));
token_data->Set(kScopes, GetScopes(token_cache_key));
token_data->SetString(kStatus, GetStatus(token_cache_value));
token_data->SetString(kTokenId, token_cache_value.token());
token_data->SetString(kAccessToken, token_cache_value.token());
token_data->SetString(kTokenExpirationTime,
GetExpirationTime(token_cache_value));
return token_data;
......@@ -262,8 +278,8 @@ IdentityInternalsUI::IdentityInternalsUI(content::WebUI* web_ui)
// Localized strings
html_source->AddLocalizedString("tokenCacheHeader",
IDS_IDENTITY_INTERNALS_TOKEN_CACHE_TEXT);
html_source->AddLocalizedString("tokenId",
IDS_IDENTITY_INTERNALS_TOKEN_ID);
html_source->AddLocalizedString("accessToken",
IDS_IDENTITY_INTERNALS_ACCESS_TOKEN);
html_source->AddLocalizedString("extensionName",
IDS_IDENTITY_INTERNALS_EXTENSION_NAME);
html_source->AddLocalizedString("extensionId",
......
......@@ -79,8 +79,8 @@ BaseIdentityInternalsWebUITest.prototype = {
* @param {Element} tokenEntry Display element holding token information.
* @return {string} Token ID of the token.
*/
getTokenId: function(tokenEntry) {
return tokenEntry.querySelector('.token-id').innerText;
getAccessToken: function(tokenEntry) {
return tokenEntry.querySelector('.access-token').innerText;
},
/**
......@@ -135,7 +135,7 @@ TEST_F('IdentityInternalsSingleTokenWebUITest', 'getAllTokens', function() {
expectEquals('Store', this.getExtensionName(tokenListEntries[0]));
expectEquals('ahfgeienlihckogmohjhadlkjgocpleb',
this.getExtensionId(tokenListEntries[0]));
expectEquals('store_token', this.getTokenId(tokenListEntries[0]));
expectEquals('store_token', this.getAccessToken(tokenListEntries[0]));
expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0]));
expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(),
3600 * 1000);
......@@ -158,8 +158,8 @@ TEST_F('IdentityInternalsSingleTokenWebUITest', 'verifyGetters', function() {
tokenListEntries[0].querySelector('.extension-name').innerText);
expectEquals(this.getExtensionId(tokenListEntries[0]),
tokenListEntries[0].querySelector('.extension-id').innerText);
expectEquals(this.getTokenId(tokenListEntries[0]),
tokenListEntries[0].querySelector('.token-id').innerText);
expectEquals(this.getAccessToken(tokenListEntries[0]),
tokenListEntries[0].querySelector('.access-token').innerText);
expectEquals(this.getTokenStatus(tokenListEntries[0]),
tokenListEntries[0].querySelector('.token-status').innerText);
expectEquals(this.getExpirationTime(tokenListEntries[0]),
......@@ -200,7 +200,7 @@ TEST_F('IdentityInternalsMultipleTokensWebUITest', 'getAllTokens', function() {
expectEquals('', this.getExtensionName(tokenListEntries[0]));
expectEquals('extension0',
this.getExtensionId(tokenListEntries[0]));
expectEquals('token0', this.getTokenId(tokenListEntries[0]));
expectEquals('token0', this.getAccessToken(tokenListEntries[0]));
expectEquals('Token Present', this.getTokenStatus(tokenListEntries[0]));
expectLT(this.getExpirationTime(tokenListEntries[0]) - new Date(),
3600 * 1000);
......@@ -212,7 +212,7 @@ TEST_F('IdentityInternalsMultipleTokensWebUITest', 'getAllTokens', function() {
expectEquals('', this.getExtensionName(tokenListEntries[1]));
expectEquals('extension1',
this.getExtensionId(tokenListEntries[1]));
expectEquals('token1', this.getTokenId(tokenListEntries[1]));
expectEquals('token1', this.getAccessToken(tokenListEntries[1]));
expectEquals('Token Present', this.getTokenStatus(tokenListEntries[1]));
expectLT(this.getExpirationTime(tokenListEntries[1]) - new Date(),
3600 * 1000);
......@@ -243,13 +243,13 @@ TEST_F('IdentityInternalsWebUITestAsync', 'revokeToken', function() {
expectEquals(2, tokenListBefore.length);
var tokenRevokeDone = identity_internals.tokenRevokeDone;
identity_internals.tokenRevokeDone = this.continueTest(
WhenTestDone.ALWAYS, function (tokenIds) {
tokenRevokeDone.call(identity_internals, tokenIds);
WhenTestDone.ALWAYS, function (accessTokens) {
tokenRevokeDone.call(identity_internals, accessTokens);
identity_internals.tokenRevokeDone = tokenRevokeDone;
var tokenListAfter = this.getTokens();
expectEquals(1, tokenListAfter.length);
expectEquals(this.getTokenId(tokenListBefore[0]),
this.getTokenId(tokenListAfter[0]));
expectEquals(this.getAccessToken(tokenListBefore[0]),
this.getAccessToken(tokenListAfter[0]));
}.bind(this));
this.getRevokeButton(tokenListBefore[1]).click();
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment