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

Unified Diff: blimp/client/core/authenticator.h

Issue 2204223005: Blimp OAuth2 token retreival on application start up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build config. Created 4 years, 4 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: blimp/client/core/authenticator.h
diff --git a/blimp/client/core/authenticator.h b/blimp/client/core/authenticator.h
new file mode 100644
index 0000000000000000000000000000000000000000..4301e7a7d2502420203d432d99e7cbd51386b85d
--- /dev/null
+++ b/blimp/client/core/authenticator.h
@@ -0,0 +1,63 @@
+// Copyright 2016 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 BLIMP_CLIENT_CORE_AUTHENTICATOR_H_
+#define BLIMP_CLIENT_CORE_AUTHENTICATOR_H_
+
+#include "base/macros.h"
+
+#include "google_apis/gaia/identity_provider.h"
+#include "google_apis/gaia/oauth2_token_service.h"
+
+namespace blimp {
+namespace client {
+
+// Authenticator handles OAuth2 token request and forward user sign in state
nyquist 2016/08/10 16:48:56 Could we come up with a different name than 'Authe
xingliu 2016/08/10 21:03:14 Renamed to IdentitySource, also Authenticator is p
+// change to Blimp with ProfileIdentityProvider.
+class Authenticator : public OAuth2TokenService::Consumer,
nyquist 2016/08/10 01:20:33 I think we want this to live in //blimp/client/cor
xingliu 2016/08/10 21:03:14 Done.
+ public OAuth2TokenService::Observer,
+ public IdentityProvider::Observer {
+ public:
+ explicit Authenticator(
+ std::unique_ptr<IdentityProvider> identity_provider);
+
+ ~Authenticator() override;
+
+ // Start Blimp authentication by requesting OAuth2 token from google.
nyquist 2016/08/10 01:20:33 Capitalize Google here and below.
xingliu 2016/08/10 21:03:14 Done.
+ void Connect();
+
+ // OAuth2TokenService::Consumer implementation.
+ void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
+ const std::string& access_token,
+ const base::Time& expiration_time) override;
+ void OnGetTokenFailure(const OAuth2TokenService::Request* request,
+ const GoogleServiceAuthError& error) override;
+
+ // OAuth2TokenService::Observer implementation.
+ void OnRefreshTokenAvailable(const std::string& account_id) override;
+
+ // IdentityProvider::Observer implementation.
+ void OnActiveAccountLogin() override;
+ void OnActiveAccountLogout() override;
+
+ private:
+ // Fetch OAuth token.
+ void FetchAuthToken();
+
+ // Provide OAuth2 token service and listen to google account sign in state.
+ std::unique_ptr<IdentityProvider> identity_provider_;
nyquist 2016/08/10 01:20:33 #include <memory>
xingliu 2016/08/10 21:03:14 Done.
+
+ // OAuth2 token request. This class should take ownership of the request.
nyquist 2016/08/10 01:20:33 std::unique_ptr implies ownership. Maybe instead f
xingliu 2016/08/10 21:03:14 I'll change the comment. Yes, it's the actual req
+ std::unique_ptr<OAuth2TokenService::Request> token_request_;
+
+ // Account id of current active user, used during token request.
+ std::string account_id_;
nyquist 2016/08/10 01:20:33 #include <string>
xingliu 2016/08/10 21:03:14 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(Authenticator);
+};
+
+} // namespace client
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_CORE_AUTHENTICATOR_H_

Powered by Google App Engine
This is Rietveld 408576698