| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_IDENTITY_INTERNALS_IDENTITY_INTERNALS_UI_HANDLER
_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_IDENTITY_INTERNALS_IDENTITY_INTERNALS_UI_HANDLER
_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/extensions/api/identity/identity_api.h" |
| 11 #include "chrome/browser/ui/webui/identity_internals/identity_internals.mojom.h" |
| 12 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h" |
| 13 |
| 14 class Profile; |
| 15 class IdentityInternalsTokenRevoker; |
| 16 |
| 17 // Class acting as a controller of the chrome://identity-internals WebUI. |
| 18 class IdentityInternalsUIHandler |
| 19 : public mojo::InterfaceImpl<IdentityInternalsHandlerMojo>, |
| 20 public MojoWebUIHandler { |
| 21 public: |
| 22 explicit IdentityInternalsUIHandler(Profile* profile); |
| 23 virtual ~IdentityInternalsUIHandler(); |
| 24 |
| 25 // Ensures that a proper clean up happens after a token is revoked. That |
| 26 // includes deleting the |token_revoker|, removing the token from Identity API |
| 27 // cache and updating the UI that the token is gone. |
| 28 void OnTokenRevokerDone(IdentityInternalsTokenRevoker* token_revoker); |
| 29 |
| 30 // Overridden from IdentityInternalsHandlerMojo: |
| 31 virtual void GetTokens( |
| 32 const mojo::Callback<void(mojo::Array<IdentityTokenMojoPtr>)>& callback) |
| 33 OVERRIDE; |
| 34 virtual void RevokeToken(const mojo::String& extension_id, |
| 35 const mojo::String& access_token, |
| 36 const mojo::Callback<void()>& callback) OVERRIDE; |
| 37 |
| 38 private: |
| 39 // We use an explicit conversion function instead of TypeConverter because |
| 40 // creating an IdentityTokenMojo relies on having the Profile* as state. |
| 41 mojo::Array<IdentityTokenMojoPtr> ConvertCachedTokens( |
| 42 const extensions::IdentityAPI::CachedTokens& tokens); |
| 43 |
| 44 // Gets the name of an extension referred to by |token_cache_key| as a string. |
| 45 const std::string GetExtensionName( |
| 46 const extensions::ExtensionTokenKey& token_cache_key); |
| 47 |
| 48 // Gets a list of scopes specified in |token_cache_key| and returns a pointer |
| 49 // to a ListValue containing the scopes. The caller gets ownership of the |
| 50 // returned object. |
| 51 mojo::Array<mojo::String> GetScopes( |
| 52 const extensions::ExtensionTokenKey& token_cache_key); |
| 53 |
| 54 // Gets a localized status of the access token in |token_cache_value|. |
| 55 const std::string GetStatus( |
| 56 const extensions::IdentityTokenCacheValue& token_cache_value); |
| 57 |
| 58 // Gets a string representation of an expiration time of the access token in |
| 59 // |token_cache_value|. |
| 60 const std::string GetExpirationTime( |
| 61 const extensions::IdentityTokenCacheValue& token_cache_value); |
| 62 |
| 63 Profile* profile_; |
| 64 |
| 65 // A vector of token revokers that are currently revoking tokens. |
| 66 ScopedVector<IdentityInternalsTokenRevoker> token_revokers_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(IdentityInternalsUIHandler); |
| 69 }; |
| 70 |
| 71 #endif // CHROME_BROWSER_UI_WEBUI_IDENTITY_INTERNALS_IDENTITY_INTERNALS_UI_HAND
LER_H_ |
| OLD | NEW |