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

Side by Side Diff: services/authentication/google_authentication_impl.h

Issue 1466733002: Google OAuth Device Flow support for FNL (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Addressed review comments Created 4 years, 11 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 unified diff | Download patch
OLDNEW
(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 // Implementation of AuthenticationService from
19 // services/authentication/authentication.mojom for Google users.
20 class GoogleAuthenticationServiceImpl
21 : public authentication::AuthenticationService {
22 public:
23 GoogleAuthenticationServiceImpl(
24 mojo::InterfaceRequest<AuthenticationService> request,
25 mojo::NetworkServicePtr& network_service,
26 mojo::files::DirectoryPtr& directory);
27
28 ~GoogleAuthenticationServiceImpl() override;
29
30 void GetOAuth2Token(const mojo::String& username,
31 mojo::Array<mojo::String> scopes,
32 const GetOAuth2TokenCallback& callback) override;
33
34 void SelectAccount(bool returnLastSelected,
35 const SelectAccountCallback& callback) override;
36
37 void ClearOAuth2Token(const mojo::String& token) override;
38
39 void GetOAuth2DeviceCode(
40 mojo::Array<mojo::String> scopes,
41 const GetOAuth2DeviceCodeCallback& callback) override;
42
43 void AddAccount(const mojo::String& device_code,
44 const AddAccountCallback& callback) override;
45
46 private:
47 void OnGetOAuth2Token(const GetOAuth2TokenCallback& callback,
48 const std::string& response,
49 const std::string& error);
50
51 void OnGetOAuth2DeviceCode(const GetOAuth2DeviceCodeCallback& callback,
52 const std::string& response,
53 const std::string& error);
54
55 // Fetches token info from access token.
56 void GetTokenInfo(const std::string& access_token);
57
58 void OnGetTokenInfo(const std::string& response, const std::string& error);
59
60 // Fetches user info from id token.
61 void GetUserInfo(const std::string& id_token);
62
63 void OnGetUserInfo(const std::string& response, const std::string& error);
64
65 void OnAddAccount(const AddAccountCallback& callback,
66 const std::string& response,
67 const std::string& error);
68
69 void Request(const std::string& url,
70 const std::string& method,
71 const std::string& message,
72 const GetOAuth2TokenCallback& callback);
73
74 void HandleServerResponse(const GetOAuth2TokenCallback& callback,
75 mojo::URLResponsePtr response);
76
77 std::string user_id_;
78 std::string email_;
79 std::string scope_;
80 mojo::StrongBinding<AuthenticationService> binding_;
81 mojo::NetworkServicePtr& network_service_;
82 AccountsDbManager* accounts_db_manager_;
83 base::WeakPtrFactory<GoogleAuthenticationServiceImpl> weak_ptr_factory_;
84
85 DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticationServiceImpl);
86 };
87
88 } // namespace authentication
89
90 #endif // SERVICES_AUTHENTICATION_GOOGLE_AUTHENTICATION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698