Index: services/authentication/google_authentication_impl.h |
diff --git a/services/authentication/google_authentication_impl.h b/services/authentication/google_authentication_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e96a192ad58a1c42f264a56114bc803c99096fb5 |
--- /dev/null |
+++ b/services/authentication/google_authentication_impl.h |
@@ -0,0 +1,92 @@ |
+// Copyright 2015 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 SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_ |
+#define SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "mojo/common/binding_set.h" |
+#include "mojo/public/cpp/bindings/strong_binding.h" |
+#include "mojo/public/cpp/system/macros.h" |
+#include "mojo/services/authentication/interfaces/authentication.mojom.h" |
+#include "mojo/services/network/interfaces/network_service.mojom.h" |
+#include "services/authentication/accounts_db_manager.h" |
+ |
+namespace authentication { |
+ |
+/** |
viettrungluu
2015/12/18 20:59:49
nit: We generally don't use this comment style in
ukode
2016/01/06 23:52:59
Acknowledged.
|
+ * Implementation of AuthenticationService from |
+ * services/authentication/authentication.mojom for Google IDP users. |
+ */ |
+class GoogleAuthenticationServiceImpl |
+ : public authentication::AuthenticationService { |
+ public: |
+ GoogleAuthenticationServiceImpl( |
+ mojo::InterfaceRequest<AuthenticationService> request, |
+ mojo::NetworkServicePtr& network_service, |
+ mojo::files::FilesPtr& files); |
+ |
+ ~GoogleAuthenticationServiceImpl() override; |
+ |
+ void GetOAuth2Token(const mojo::String& username, |
+ mojo::Array<mojo::String> scopes, |
+ const GetOAuth2TokenCallback& callback) override; |
+ |
+ void SelectAccount(bool returnLastSelected, |
+ const SelectAccountCallback& callback) override; |
+ |
+ void ClearOAuth2Token(const mojo::String& token) override; |
+ |
+ void GetOAuth2DeviceCode( |
+ mojo::Array<mojo::String> scopes, |
+ const GetOAuth2DeviceCodeCallback& callback) override; |
+ |
+ void AddAccount(const mojo::String& device_code, |
+ const AddAccountCallback& callback) override; |
+ |
+ private: |
+ void OnGetOAuth2Token(const GetOAuth2TokenCallback& callback, |
+ const std::string& response, |
+ const std::string& error); |
+ |
+ void OnGetOAuth2DeviceCode(const GetOAuth2DeviceCodeCallback& callback, |
+ const std::string& response, |
+ const std::string& error); |
+ |
+ // Fetches token info from access token. |
+ void GetTokenInfo(const std::string& access_token); |
+ |
+ void OnGetTokenInfo(const std::string& response, const std::string& error); |
+ |
+ // Fetches user info from id token. |
+ void GetUserInfo(const std::string& id_token); |
+ |
+ void OnGetUserInfo(const std::string& response, const std::string& error); |
+ |
+ void OnAddAccount(const AddAccountCallback& callback, |
+ const std::string& response, |
+ const std::string& error); |
+ |
+ void Request(const std::string& url, |
+ const std::string& method, |
+ const std::string& message, |
+ const GetOAuth2TokenCallback& callback); |
+ |
+ void HandleServerResponse(const GetOAuth2TokenCallback& callback, |
+ mojo::URLResponsePtr response); |
+ |
+ std::string user_id_; |
+ std::string email_; |
+ std::string scope_; |
+ mojo::StrongBinding<AuthenticationService> binding_; |
+ mojo::NetworkServicePtr& network_service_; |
+ AccountsDbManager* accounts_db_manager_; |
+ base::WeakPtrFactory<GoogleAuthenticationServiceImpl> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticationServiceImpl); |
+}; |
+ |
+} // namespace authentication |
+ |
+#endif // SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_ |