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

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

Issue 2108643007: Revert of arc: Implement silent OptIn mode for managed Arc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h" 15 #include "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h"
16 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h"
17 #include "components/arc/arc_bridge_service.h" 16 #include "components/arc/arc_bridge_service.h"
18 #include "components/arc/arc_service.h" 17 #include "components/arc/arc_service.h"
19 #include "components/arc/common/auth.mojom.h" 18 #include "components/arc/common/auth.mojom.h"
20 #include "components/prefs/pref_change_registrar.h" 19 #include "components/prefs/pref_change_registrar.h"
21 #include "components/syncable_prefs/pref_service_syncable_observer.h" 20 #include "components/syncable_prefs/pref_service_syncable_observer.h"
22 #include "components/syncable_prefs/synced_pref_observer.h" 21 #include "components/syncable_prefs/synced_pref_observer.h"
22 #include "google_apis/gaia/ubertoken_fetcher.h"
23 #include "mojo/public/cpp/bindings/binding.h" 23 #include "mojo/public/cpp/bindings/binding.h"
24 24
25 class ArcAndroidManagementChecker;
25 class ArcAppLauncher; 26 class ArcAppLauncher;
27 class GaiaAuthFetcher;
26 class Profile; 28 class Profile;
29 class ProfileOAuth2TokenService;
27 30
28 namespace ash { 31 namespace ash {
29 class ShelfDelegate; 32 class ShelfDelegate;
30 } 33 }
31 34
35 namespace content {
36 class StoragePartition;
37 }
38
39 namespace net {
40 class URLRequestContextGetter;
41 }
42
32 namespace user_prefs { 43 namespace user_prefs {
33 class PrefRegistrySyncable; 44 class PrefRegistrySyncable;
34 } 45 }
35 46
36 namespace arc { 47 namespace arc {
37 48
38 class ArcAndroidManagementChecker;
39 class ArcAuthContext;
40
41 // This class proxies the request from the client to fetch an auth code from 49 // This class proxies the request from the client to fetch an auth code from
42 // LSO. 50 // LSO.
43 class ArcAuthService : public ArcService, 51 class ArcAuthService : public ArcService,
44 public mojom::AuthHost, 52 public mojom::AuthHost,
45 public ArcBridgeService::Observer, 53 public ArcBridgeService::Observer,
46 public ArcAndroidManagementCheckerDelegate, 54 public ArcAndroidManagementCheckerDelegate,
47 public ArcAuthContextDelegate, 55 public UbertokenConsumer,
56 public GaiaAuthConsumer,
48 public syncable_prefs::PrefServiceSyncableObserver, 57 public syncable_prefs::PrefServiceSyncableObserver,
49 public syncable_prefs::SyncedPrefObserver { 58 public syncable_prefs::SyncedPrefObserver {
50 public: 59 public:
51 enum class State { 60 enum class State {
52 NOT_INITIALIZED, // Service is not initialized. 61 NOT_INITIALIZED, // Service is not initialized.
53 STOPPED, // ARC is not running. 62 STOPPED, // ARC is not running.
54 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. 63 FETCHING_CODE, // ARC may be running or not. Auth code is fetching.
55 ACTIVE, // ARC is running. 64 ACTIVE, // ARC is running.
56 }; 65 };
57 66
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void SetAuthCodeAndStartArc(const std::string& auth_code); 153 void SetAuthCodeAndStartArc(const std::string& auth_code);
145 154
146 // Called from Arc support platform app when user cancels signing. 155 // Called from Arc support platform app when user cancels signing.
147 void CancelAuthCode(); 156 void CancelAuthCode();
148 157
149 bool IsArcManaged() const; 158 bool IsArcManaged() const;
150 bool IsArcEnabled() const; 159 bool IsArcEnabled() const;
151 void EnableArc(); 160 void EnableArc();
152 void DisableArc(); 161 void DisableArc();
153 162
163 // UbertokenConsumer:
164 void OnUbertokenSuccess(const std::string& token) override;
165 void OnUbertokenFailure(const GoogleServiceAuthError& error) override;
166
167 // GaiaAuthConsumer:
168 void OnMergeSessionSuccess(const std::string& data) override;
169 void OnMergeSessionFailure(const GoogleServiceAuthError& error) override;
170
154 // syncable_prefs::PrefServiceSyncableObserver 171 // syncable_prefs::PrefServiceSyncableObserver
155 void OnIsSyncingChanged() override; 172 void OnIsSyncingChanged() override;
156 173
157 // syncable_prefs::SyncedPrefObserver 174 // syncable_prefs::SyncedPrefObserver
158 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; 175 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override;
159 176
160 // ArcAuthContextDelegate:
161 void OnContextReady() override;
162 void OnPrepareContextFailed() override;
163
164 // ArcAndroidManagementCheckerDelegate: 177 // ArcAndroidManagementCheckerDelegate:
165 void OnAndroidManagementChecked( 178 void OnAndroidManagementChecked(
166 policy::AndroidManagementClient::Result result) override; 179 policy::AndroidManagementClient::Result result) override;
167 180
168 // Returns current page that has to be shown in OptIn UI. 181 // Returns current page that has to be shown in OptIn UI.
169 UIPage ui_page() const { return ui_page_; } 182 UIPage ui_page() const { return ui_page_; }
170 183
171 // Returns current page status, relevant to the specific page. 184 // Returns current page status, relevant to the specific page.
172 const base::string16& ui_page_status() { return ui_page_status_; } 185 const base::string16& ui_page_status() { return ui_page_status_; }
173 186
174 private: 187 private:
175 void StartArc(); 188 void StartArc();
189 void PrepareContext();
176 void ShowUI(UIPage page, const base::string16& status); 190 void ShowUI(UIPage page, const base::string16& status);
177 void CloseUI(); 191 void CloseUI();
178 void SetUIPage(UIPage page, const base::string16& status); 192 void SetUIPage(UIPage page, const base::string16& status);
179 void SetState(State state); 193 void SetState(State state);
180 void ShutdownBridge(); 194 void ShutdownBridge();
181 void ShutdownBridgeAndCloseUI(); 195 void ShutdownBridgeAndCloseUI();
182 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); 196 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status);
183 void OnOptInPreferenceChanged(); 197 void OnOptInPreferenceChanged();
184 void StartUI(); 198 void StartUI();
199 void OnPrepareContextFailed();
185 void StartAndroidManagementClient(); 200 void StartAndroidManagementClient();
186 void CheckAndroidManagement(bool background_mode); 201 void CheckAndroidManagement(bool background_mode);
187 void StartArcIfSignedIn(); 202 void StartArcIfSignedIn();
188 203
189 // Unowned pointer. Keeps current profile. 204 // Unowned pointer. Keeps current profile.
190 Profile* profile_ = nullptr; 205 Profile* profile_ = nullptr;
206 // Owned by content::BrowserContent. Used to isolate cookies for auth server
207 // communication and shared with Arc OptIn UI platform app.
208 content::StoragePartition* storage_partition_ = nullptr;
191 209
192 // Registrar used to monitor ARC enabled state. 210 // Registrar used to monitor ARC enabled state.
193 PrefChangeRegistrar pref_change_registrar_; 211 PrefChangeRegistrar pref_change_registrar_;
194 212
195 mojo::Binding<AuthHost> binding_; 213 mojo::Binding<AuthHost> binding_;
196 State state_ = State::NOT_INITIALIZED; 214 State state_ = State::NOT_INITIALIZED;
197 base::ObserverList<Observer> observer_list_; 215 base::ObserverList<Observer> observer_list_;
216 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_;
217 std::unique_ptr<UbertokenFetcher> ubertoken_fetcher_;
198 std::unique_ptr<ArcAppLauncher> playstore_launcher_; 218 std::unique_ptr<ArcAppLauncher> playstore_launcher_;
199 std::string auth_code_; 219 std::string auth_code_;
200 GetAuthCodeCallback auth_callback_; 220 GetAuthCodeCallback auth_callback_;
201 bool initial_opt_in_ = false; 221 bool initial_opt_in_ = false;
222 bool context_prepared_ = false;
202 bool disable_arc_from_ui_ = false; 223 bool disable_arc_from_ui_ = false;
203 UIPage ui_page_ = UIPage::NO_PAGE; 224 UIPage ui_page_ = UIPage::NO_PAGE;
204 base::string16 ui_page_status_; 225 base::string16 ui_page_status_;
205 bool clear_required_ = false; 226 bool clear_required_ = false;
206 227
207 std::unique_ptr<ArcAuthContext> context_; 228 ProfileOAuth2TokenService* token_service_;
229 std::string account_id_;
208 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; 230 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_;
209 231
210 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; 232 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_;
211 233
212 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 234 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
213 }; 235 };
214 236
215 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 237 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
216 238
217 } // namespace arc 239 } // namespace arc
218 240
219 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 241 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_context_delegate.h ('k') | chrome/browser/chromeos/arc/arc_auth_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698