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

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

Issue 1681813003: arc: Use incognito profile for OptIn and cookie fetcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
7 7
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "chrome/browser/chromeos/arc/arc_auth_ui.h" 13 #include "chrome/browser/chromeos/arc/arc_auth_ui.h"
14 #include "components/arc/arc_bridge_service.h" 14 #include "components/arc/arc_bridge_service.h"
15 #include "components/arc/arc_service.h" 15 #include "components/arc/arc_service.h"
16 #include "components/arc/auth/arc_auth_fetcher.h" 16 #include "components/arc/auth/arc_auth_fetcher.h"
17 #include "components/arc/common/auth.mojom.h" 17 #include "components/arc/common/auth.mojom.h"
18 #include "components/prefs/pref_change_registrar.h" 18 #include "components/prefs/pref_change_registrar.h"
19 #include "google_apis/gaia/gaia_auth_consumer.h"
20 #include "google_apis/gaia/ubertoken_fetcher.h"
19 #include "mojo/public/cpp/bindings/binding.h" 21 #include "mojo/public/cpp/bindings/binding.h"
22 #include "net/cookies/canonical_cookie.h"
20 23
24 class GaiaAuthFetcher;
21 class PrefService; 25 class PrefService;
22 class Profile; 26 class Profile;
23 27
28 namespace net {
29 class URLRequestContextGetter;
30 }
31
24 namespace user_prefs { 32 namespace user_prefs {
25 class PrefRegistrySyncable; 33 class PrefRegistrySyncable;
26 } 34 }
27 35
28 namespace arc { 36 namespace arc {
29 37
30 // This class proxies the request from the client to fetch an auth code from 38 // This class proxies the request from the client to fetch an auth code from
31 // LSO. 39 // LSO.
32 class ArcAuthService : public ArcService, 40 class ArcAuthService : public ArcService,
33 public AuthHost, 41 public AuthHost,
34 public ArcBridgeService::Observer, 42 public ArcBridgeService::Observer,
35 public ArcAuthFetcher::Delegate, 43 public ArcAuthFetcher::Delegate,
36 public ArcAuthUI::Delegate { 44 public ArcAuthUI::Delegate,
45 public UbertokenConsumer,
46 public GaiaAuthConsumer {
37 public: 47 public:
38 enum class State { 48 enum class State {
39 DISABLE, // ARC is not allowed to run (default). 49 DISABLE, // ARC is not allowed to run (default).
40 FETCHING_CODE, // ARC is allowed, receiving auth_2 code. 50 FETCHING_CODE, // ARC is allowed, receiving auth_2 code.
41 NO_CODE, // ARC is allowed, auth_2 code was not received. 51 NO_CODE, // ARC is allowed, auth_2 code was not received.
42 ENABLE, // ARC is allowed, auth_2 code was received. 52 ENABLE, // ARC is allowed, auth_2 code was received.
43 }; 53 };
44 54
45 class Observer { 55 class Observer {
46 public: 56 public:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Overrides AuthHost. For security reason this code can be used only 91 // Overrides AuthHost. For security reason this code can be used only
82 // once and exists for specific period of time. 92 // once and exists for specific period of time.
83 void GetAuthCode(const GetAuthCodeCallback& callback) override; 93 void GetAuthCode(const GetAuthCodeCallback& callback) override;
84 94
85 // ArcAuthFetcher::Delegate: 95 // ArcAuthFetcher::Delegate:
86 void OnAuthCodeFetched(const std::string& auth_code) override; 96 void OnAuthCodeFetched(const std::string& auth_code) override;
87 void OnAuthCodeNeedUI() override; 97 void OnAuthCodeNeedUI() override;
88 void OnAuthCodeFailed() override; 98 void OnAuthCodeFailed() override;
89 99
90 // ArcAuthUI::Delegate: 100 // ArcAuthUI::Delegate:
101 void OnAuthCodeFetchedFromUI(const std::string& auth_code) override;
91 void OnAuthUIClosed() override; 102 void OnAuthUIClosed() override;
92 103
104 // UbertokenConsumer:
105 void OnUbertokenSuccess(const std::string& token) override;
106 void OnUbertokenFailure(const GoogleServiceAuthError& error) override;
107
108 // GaiaAuthConsumer:
109 void OnMergeSessionSuccess(const std::string& data) override;
110 void OnMergeSessionFailure(const GoogleServiceAuthError& error) override;
111
93 private: 112 private:
94 void FetchAuthCode(); 113 void FetchAuthCode();
114 void ShowUI();
95 void CloseUI(); 115 void CloseUI();
96 void SetState(State state); 116 void SetState(State state);
97 void ShutdownBridgeAndCloseUI(); 117 void ShutdownBridgeAndCloseUI();
98 void OnOptInPreferenceChanged(); 118 void OnOptInPreferenceChanged();
119 void CopyCookiesAndStartFetching();
120 void StartFetcherOnUIThread();
121 void CleanupSigninProfile();
122
123 void StartCopyFromArcCookiesOnIOThread(
124 net::URLRequestContextGetter* context_getter_from,
125 net::URLRequestContextGetter* context_getter_to);
126 void CopyFromArcCookiesOnIOThread(
127 net::URLRequestContextGetter* context_getter,
128 const net::CookieList& cookie_list);
129 void StartCopyToArcCookiesOnIOThread(
130 const std::string& auth_code,
131 net::URLRequestContextGetter* context_getter_from,
132 net::URLRequestContextGetter* context_getter_to);
133 void CopyToArcCookiesOnIOThread(const std::string& auth_code,
134 net::URLRequestContextGetter* context_getter,
135 const net::CookieList& cookie_list);
99 136
100 // Unowned pointer. Keeps current profile. 137 // Unowned pointer. Keeps current profile.
101 Profile* profile_ = nullptr; 138 Profile* profile_ = nullptr;
139 // Unowned pointer. Keeps sign-in profile.
140 Profile* signin_profile_ = nullptr;
102 141
103 // Owned by view hierarchy. 142 // Owned by view hierarchy.
104 ArcAuthUI* auth_ui_ = nullptr; 143 ArcAuthUI* auth_ui_ = nullptr;
105 144
106 // Registrar used to monitor ARC opt-in state. 145 // Registrar used to monitor ARC opt-in state.
107 PrefChangeRegistrar pref_change_registrar_; 146 PrefChangeRegistrar pref_change_registrar_;
108 147
109 mojo::Binding<AuthHost> binding_; 148 mojo::Binding<AuthHost> binding_;
110 base::ThreadChecker thread_checker_; 149 base::ThreadChecker thread_checker_;
111 State state_ = State::DISABLE; 150 State state_ = State::DISABLE;
112 base::ObserverList<Observer> observer_list_; 151 base::ObserverList<Observer> observer_list_;
113 scoped_ptr<ArcAuthFetcher> auth_fetcher_; 152 scoped_ptr<ArcAuthFetcher> auth_fetcher_;
153 scoped_ptr<GaiaAuthFetcher> merger_fetcher_;
154 scoped_ptr<UbertokenFetcher> ubertoken_fethcher_;
114 std::string auth_code_; 155 std::string auth_code_;
156 bool signin_profile_dirty_ = false;
157 int retry_cnt_ = 0;
115 158
116 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 159 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
117 }; 160 };
118 161
119 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 162 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
120 163
121 } // namespace arc 164 } // namespace arc
122 165
123 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 166 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_auth_service.cc » ('j') | chrome/browser/chromeos/arc/arc_auth_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698