Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: chrome/browser/ui/webui/identity_internals/identity_internals_ui_handler.h

Issue 365513002: Port identity_internals to mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT for commit Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/identity_internals/identity_internals_ui_handler.h
diff --git a/chrome/browser/ui/webui/identity_internals/identity_internals_ui_handler.h b/chrome/browser/ui/webui/identity_internals/identity_internals_ui_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..400e52156ab861fb406066e3ba343ed479ecd0e2
--- /dev/null
+++ b/chrome/browser/ui/webui/identity_internals/identity_internals_ui_handler.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_IDENTITY_INTERNALS_IDENTITY_INTERNALS_UI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_IDENTITY_INTERNALS_IDENTITY_INTERNALS_UI_HANDLER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "chrome/browser/extensions/api/identity/identity_api.h"
+#include "chrome/browser/ui/webui/identity_internals/identity_internals.mojom.h"
+#include "chrome/browser/ui/webui/mojo_web_ui_handler.h"
+
+class Profile;
+class IdentityInternalsTokenRevoker;
+
+// Class acting as a controller of the chrome://identity-internals WebUI.
+class IdentityInternalsUIHandler
+ : public mojo::InterfaceImpl<IdentityInternalsHandlerMojo>,
+ public MojoWebUIHandler {
+ public:
+ explicit IdentityInternalsUIHandler(Profile* profile);
+ virtual ~IdentityInternalsUIHandler();
+
+ // Ensures that a proper clean up happens after a token is revoked. That
+ // includes deleting the |token_revoker|, removing the token from Identity API
+ // cache and updating the UI that the token is gone.
+ void OnTokenRevokerDone(IdentityInternalsTokenRevoker* token_revoker);
+
+ // Overridden from IdentityInternalsHandlerMojo:
+ virtual void GetTokens(
+ const mojo::Callback<void(mojo::Array<IdentityTokenMojoPtr>)>& callback)
+ OVERRIDE;
+ virtual void RevokeToken(const mojo::String& extension_id,
+ const mojo::String& access_token,
+ const mojo::Callback<void()>& callback) OVERRIDE;
+
+ private:
+ // We use an explicit conversion function instead of TypeConverter because
+ // creating an IdentityTokenMojo relies on having the Profile* as state.
+ mojo::Array<IdentityTokenMojoPtr> ConvertCachedTokens(
+ const extensions::IdentityAPI::CachedTokens& tokens);
+
+ // Gets the name of an extension referred to by |token_cache_key| as a string.
+ const std::string GetExtensionName(
+ const extensions::ExtensionTokenKey& 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.
+ mojo::Array<mojo::String> GetScopes(
+ const extensions::ExtensionTokenKey& token_cache_key);
+
+ // Gets a localized status of the access token in |token_cache_value|.
+ const std::string 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);
+
+ Profile* profile_;
+
+ // A vector of token revokers that are currently revoking tokens.
+ ScopedVector<IdentityInternalsTokenRevoker> token_revokers_;
+
+ DISALLOW_COPY_AND_ASSIGN(IdentityInternalsUIHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_IDENTITY_INTERNALS_IDENTITY_INTERNALS_UI_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698