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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_context.h

Issue 2320813002: arc: Enable silent PlayStore Sign-In. (Closed)
Patch Set: cleanup Created 4 years, 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "google_apis/gaia/oauth2_token_service.h"
13 #include "google_apis/gaia/ubertoken_fetcher.h" 14 #include "google_apis/gaia/ubertoken_fetcher.h"
15 #include "net/url_request/url_fetcher.h"
14 16
15 class Profile; 17 class Profile;
16 class ProfileOAuth2TokenService; 18 class ProfileOAuth2TokenService;
17 19
18 namespace content { 20 namespace content {
19 class StoragePartition; 21 class StoragePartition;
20 } 22 }
21 23
22 namespace arc { 24 namespace arc {
23 25
24 class ArcAuthContextDelegate; 26 class ArcAuthContextDelegate;
25 27
26 class ArcAuthContext : public UbertokenConsumer, 28 class ArcAuthContext : public UbertokenConsumer,
27 public GaiaAuthConsumer, 29 public GaiaAuthConsumer,
28 public OAuth2TokenService::Observer { 30 public OAuth2TokenService::Observer,
31 public OAuth2TokenService::Consumer,
32 public net::URLFetcherDelegate {
xiyuan 2016/09/07 21:07:55 Can we create a separate class and make it a membe
khmel 2016/09/07 23:08:53 +1
29 public: 33 public:
30 ArcAuthContext(ArcAuthContextDelegate* delegate, Profile* profile); 34 ArcAuthContext(ArcAuthContextDelegate* delegate, Profile* profile);
31 ~ArcAuthContext() override; 35 ~ArcAuthContext() override;
32 36
33 void PrepareContext(); 37 void PrepareContext();
38 void FetchAuthCode(const std::string& auth_endpoint);
34 39
35 // OAuth2TokenService::Observer: 40 // OAuth2TokenService::Observer:
36 void OnRefreshTokenAvailable(const std::string& account_id) override; 41 void OnRefreshTokenAvailable(const std::string& account_id) override;
37 void OnRefreshTokensLoaded() override; 42 void OnRefreshTokensLoaded() override;
38 43
39 // UbertokenConsumer: 44 // UbertokenConsumer:
40 void OnUbertokenSuccess(const std::string& token) override; 45 void OnUbertokenSuccess(const std::string& token) override;
41 void OnUbertokenFailure(const GoogleServiceAuthError& error) override; 46 void OnUbertokenFailure(const GoogleServiceAuthError& error) override;
42 47
43 // GaiaAuthConsumer: 48 // GaiaAuthConsumer:
44 void OnMergeSessionSuccess(const std::string& data) override; 49 void OnMergeSessionSuccess(const std::string& data) override;
45 void OnMergeSessionFailure(const GoogleServiceAuthError& error) override; 50 void OnMergeSessionFailure(const GoogleServiceAuthError& error) override;
46 51
52 // OAuth2TokenService::Consumer:
53 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
54 const std::string& access_token,
55 const base::Time& expiration_time) override;
56 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
57 const GoogleServiceAuthError& error) override;
58
59 // net::URLFetcherDelegate:
60 void OnURLFetchComplete(const net::URLFetcher* source) override;
61
47 const std::string& account_id() const { return account_id_; } 62 const std::string& account_id() const { return account_id_; }
48 63
49 ProfileOAuth2TokenService* token_service() { return token_service_; } 64 ProfileOAuth2TokenService* token_service() { return token_service_; }
50 65
51 private: 66 private:
52 void StartFetchers(); 67 void StartFetchers();
68 void ResetFetchers();
53 void OnRefreshTokenTimeout(); 69 void OnRefreshTokenTimeout();
54 70
55 // Unowned pointers. 71 // Unowned pointers.
56 ArcAuthContextDelegate* const delegate_; 72 ArcAuthContextDelegate* const delegate_;
73 Profile* const profile_;
57 ProfileOAuth2TokenService* token_service_; 74 ProfileOAuth2TokenService* token_service_;
75 // URL to request auth code.
76 std::string auth_endpoint_;
58 77
59 bool context_prepared_ = false; 78 bool context_prepared_ = false;
60 79
61 // Owned by content::BrowserContent. Used to isolate cookies for auth server 80 // Owned by content::BrowserContent. Used to isolate cookies for auth server
62 // communication and shared with Arc OptIn UI platform app. 81 // communication and shared with Arc OptIn UI platform app.
63 content::StoragePartition* storage_partition_ = nullptr; 82 content::StoragePartition* storage_partition_ = nullptr;
64 83
65 std::string account_id_; 84 std::string account_id_;
66 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_; 85 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_;
67 std::unique_ptr<UbertokenFetcher> ubertoken_fetcher_; 86 std::unique_ptr<UbertokenFetcher> ubertoken_fetcher_;
87 std::unique_ptr<OAuth2TokenService::Request> login_token_request_;
88 std::unique_ptr<net::URLFetcher> auth_code_fetcher_;
68 base::OneShotTimer refresh_token_timeout_; 89 base::OneShotTimer refresh_token_timeout_;
69 90
70 DISALLOW_COPY_AND_ASSIGN(ArcAuthContext); 91 DISALLOW_COPY_AND_ASSIGN(ArcAuthContext);
71 }; 92 };
72 93
73 } // namespace arc 94 } // namespace arc
74 95
75 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_ 96 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698