OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_ | |
6 #define SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_ | |
7 | |
8 #include "base/memory/weak_ptr.h" | |
9 #include "mojo/common/binding_set.h" | |
10 #include "mojo/public/cpp/bindings/strong_binding.h" | |
11 #include "mojo/public/cpp/system/macros.h" | |
12 #include "mojo/services/authentication/interfaces/authentication.mojom.h" | |
13 #include "mojo/services/network/interfaces/network_service.mojom.h" | |
14 #include "services/authentication/accounts_db_manager.h" | |
15 | |
16 namespace authentication { | |
17 | |
18 /** | |
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.
| |
19 * Implementation of AuthenticationService from | |
20 * services/authentication/authentication.mojom for Google IDP users. | |
21 */ | |
22 class GoogleAuthenticationServiceImpl | |
23 : public authentication::AuthenticationService { | |
24 public: | |
25 GoogleAuthenticationServiceImpl( | |
26 mojo::InterfaceRequest<AuthenticationService> request, | |
27 mojo::NetworkServicePtr& network_service, | |
28 mojo::files::FilesPtr& files); | |
29 | |
30 ~GoogleAuthenticationServiceImpl() override; | |
31 | |
32 void GetOAuth2Token(const mojo::String& username, | |
33 mojo::Array<mojo::String> scopes, | |
34 const GetOAuth2TokenCallback& callback) override; | |
35 | |
36 void SelectAccount(bool returnLastSelected, | |
37 const SelectAccountCallback& callback) override; | |
38 | |
39 void ClearOAuth2Token(const mojo::String& token) override; | |
40 | |
41 void GetOAuth2DeviceCode( | |
42 mojo::Array<mojo::String> scopes, | |
43 const GetOAuth2DeviceCodeCallback& callback) override; | |
44 | |
45 void AddAccount(const mojo::String& device_code, | |
46 const AddAccountCallback& callback) override; | |
47 | |
48 private: | |
49 void OnGetOAuth2Token(const GetOAuth2TokenCallback& callback, | |
50 const std::string& response, | |
51 const std::string& error); | |
52 | |
53 void OnGetOAuth2DeviceCode(const GetOAuth2DeviceCodeCallback& callback, | |
54 const std::string& response, | |
55 const std::string& error); | |
56 | |
57 // Fetches token info from access token. | |
58 void GetTokenInfo(const std::string& access_token); | |
59 | |
60 void OnGetTokenInfo(const std::string& response, const std::string& error); | |
61 | |
62 // Fetches user info from id token. | |
63 void GetUserInfo(const std::string& id_token); | |
64 | |
65 void OnGetUserInfo(const std::string& response, const std::string& error); | |
66 | |
67 void OnAddAccount(const AddAccountCallback& callback, | |
68 const std::string& response, | |
69 const std::string& error); | |
70 | |
71 void Request(const std::string& url, | |
72 const std::string& method, | |
73 const std::string& message, | |
74 const GetOAuth2TokenCallback& callback); | |
75 | |
76 void HandleServerResponse(const GetOAuth2TokenCallback& callback, | |
77 mojo::URLResponsePtr response); | |
78 | |
79 std::string user_id_; | |
80 std::string email_; | |
81 std::string scope_; | |
82 mojo::StrongBinding<AuthenticationService> binding_; | |
83 mojo::NetworkServicePtr& network_service_; | |
84 AccountsDbManager* accounts_db_manager_; | |
85 base::WeakPtrFactory<GoogleAuthenticationServiceImpl> weak_ptr_factory_; | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticationServiceImpl); | |
88 }; | |
89 | |
90 } // namespace authentication | |
91 | |
92 #endif // SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_ | |
OLD | NEW |