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

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

Issue 2490093002: Migrate opt-in auth flow to re-auth flow. (Closed)
Patch Set: Created 4 years, 1 month 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>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 public ArcAuthContextDelegate, 57 public ArcAuthContextDelegate,
58 public ArcAuthCodeFetcherDelegate, 58 public ArcAuthCodeFetcherDelegate,
59 public sync_preferences::PrefServiceSyncableObserver, 59 public sync_preferences::PrefServiceSyncableObserver,
60 public sync_preferences::SyncedPrefObserver { 60 public sync_preferences::SyncedPrefObserver {
61 public: 61 public:
62 enum class State { 62 enum class State {
63 NOT_INITIALIZED, // Service is not initialized. 63 NOT_INITIALIZED, // Service is not initialized.
64 STOPPED, // ARC is not running. 64 STOPPED, // ARC is not running.
65 TERMS, // Showing "Terms Of Service" to user. 65 TERMS, // Showing "Terms Of Service" to user.
66 ANDROID_MANAGEMENT_CHECK, // Checkng Android management status. 66 ANDROID_MANAGEMENT_CHECK, // Checkng Android management status.
67 FETCHING_CODE, // ARC is not yet running. Fetching auth token.
68 ACTIVE, // ARC is running. 67 ACTIVE, // ARC is running.
69 }; 68 };
70 69
71 class Observer { 70 class Observer {
72 public: 71 public:
73 virtual ~Observer() = default; 72 virtual ~Observer() = default;
74 73
75 // Called to notify that ARC bridge is shut down. 74 // Called to notify that ARC bridge is shut down.
76 virtual void OnShutdownBridge() {} 75 virtual void OnShutdownBridge() {}
77 76
(...skipping 27 matching lines...) Expand all
105 bool IsAllowed() const; 104 bool IsAllowed() const;
106 105
107 void OnPrimaryUserProfilePrepared(Profile* profile); 106 void OnPrimaryUserProfilePrepared(Profile* profile);
108 void Shutdown(); 107 void Shutdown();
109 108
110 Profile* profile() { return profile_; } 109 Profile* profile() { return profile_; }
111 const Profile* profile() const { return profile_; } 110 const Profile* profile() const { return profile_; }
112 111
113 State state() const { return state_; } 112 State state() const { return state_; }
114 113
115 std::string GetAndResetAuthCode();
116
117 // Adds or removes observers. 114 // Adds or removes observers.
118 void AddObserver(Observer* observer); 115 void AddObserver(Observer* observer);
119 void RemoveObserver(Observer* observer); 116 void RemoveObserver(Observer* observer);
120 117
121 // ArcBridgeService::Observer: 118 // ArcBridgeService::Observer:
122 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; 119 void OnBridgeStopped(ArcBridgeService::StopReason reason) override;
123 120
124 // InstanceHolder<mojom::AuthInstance>::Observer: 121 // InstanceHolder<mojom::AuthInstance>::Observer:
125 void OnInstanceReady() override; 122 void OnInstanceReady() override;
126 123
(...skipping 15 matching lines...) Expand all
142 // user. 139 // user.
143 void GetIsAccountManagedDeprecated( 140 void GetIsAccountManagedDeprecated(
144 const GetIsAccountManagedDeprecatedCallback& callback) override; 141 const GetIsAccountManagedDeprecatedCallback& callback) override;
145 142
146 void OnSignInFailedInternal(ProvisioningResult result); 143 void OnSignInFailedInternal(ProvisioningResult result);
147 144
148 // Called from Arc support platform app to start LSO. 145 // Called from Arc support platform app to start LSO.
149 void StartLso(); 146 void StartLso();
150 147
151 // Called from Arc support platform app to set auth code and start arc. 148 // Called from Arc support platform app to set auth code and start arc.
152 void SetAuthCodeAndStartArc(const std::string& auth_code); 149 void OnAuthCodeObtained(const std::string& auth_code);
153 150
154 // Called from Arc support platform app when user cancels signing. 151 // Called from Arc support platform app when user cancels signing.
155 void CancelAuthCode(); 152 void CancelAuthCode();
156 153
157 bool IsArcManaged() const; 154 bool IsArcManaged() const;
158 bool IsArcEnabled() const; 155 bool IsArcEnabled() const;
159 156
160 // This requires Arc to be allowed (|IsAllowed|)for current profile. 157 // This requires Arc to be allowed (|IsAllowed|)for current profile.
161 void EnableArc(); 158 void EnableArc();
162 void DisableArc(); 159 void DisableArc();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void RemoveArcData(); 203 void RemoveArcData();
207 204
208 // Returns current page that has to be shown in OptIn UI. 205 // Returns current page that has to be shown in OptIn UI.
209 ArcSupportHost::UIPage ui_page() const { return ui_page_; } 206 ArcSupportHost::UIPage ui_page() const { return ui_page_; }
210 207
211 // Returns current page status, relevant to the specific page. 208 // Returns current page status, relevant to the specific page.
212 const base::string16& ui_page_status() const { return ui_page_status_; } 209 const base::string16& ui_page_status() const { return ui_page_status_; }
213 210
214 ArcSupportHost* support_host() { return support_host_.get(); } 211 ArcSupportHost* support_host() { return support_host_.get(); }
215 212
213 void StartArc();
214
216 private: 215 private:
217 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; 216 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>;
218 class AccountInfoNotifier; 217 class AccountInfoNotifier;
219 218
220 void StartArc();
221 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. 219 // TODO(hidehiko): move UI methods/fields to ArcSupportHost.
222 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status); 220 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status);
223 void CloseUI(); 221 void CloseUI();
224 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status); 222 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status);
225 void SetState(State state); 223 void SetState(State state);
226 void ShutdownBridge(); 224 void ShutdownBridge();
227 void ShutdownBridgeAndCloseUI(); 225 void ShutdownBridgeAndCloseUI();
228 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, 226 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page,
229 const base::string16& status); 227 const base::string16& status);
230 void OnOptInPreferenceChanged(); 228 void OnOptInPreferenceChanged();
(...skipping 23 matching lines...) Expand all
254 // Unowned pointer. Keeps current profile. 252 // Unowned pointer. Keeps current profile.
255 Profile* profile_ = nullptr; 253 Profile* profile_ = nullptr;
256 254
257 // Registrar used to monitor ARC enabled state. 255 // Registrar used to monitor ARC enabled state.
258 PrefChangeRegistrar pref_change_registrar_; 256 PrefChangeRegistrar pref_change_registrar_;
259 257
260 mojo::Binding<AuthHost> binding_; 258 mojo::Binding<AuthHost> binding_;
261 State state_ = State::NOT_INITIALIZED; 259 State state_ = State::NOT_INITIALIZED;
262 base::ObserverList<Observer> observer_list_; 260 base::ObserverList<Observer> observer_list_;
263 std::unique_ptr<ArcAppLauncher> playstore_launcher_; 261 std::unique_ptr<ArcAppLauncher> playstore_launcher_;
264 std::string auth_code_;
265 ArcSupportHost::UIPage ui_page_ = ArcSupportHost::UIPage::NO_PAGE; 262 ArcSupportHost::UIPage ui_page_ = ArcSupportHost::UIPage::NO_PAGE;
266 base::string16 ui_page_status_; 263 base::string16 ui_page_status_;
267 bool clear_required_ = false; 264 bool clear_required_ = false;
268 bool reenable_arc_ = false; 265 bool reenable_arc_ = false;
266 bool arc_data_is_being_removed_ = false;
269 base::OneShotTimer arc_sign_in_timer_; 267 base::OneShotTimer arc_sign_in_timer_;
270 268
271 // Notifies the correct callback whenever the auth_code is ready. 269 // Notifies the correct callback whenever the auth_code is ready.
272 std::unique_ptr<AccountInfoNotifier> account_info_notifier_; 270 std::unique_ptr<AccountInfoNotifier> account_info_notifier_;
273 271
274 // Temporarily keeps the ArcSupportHost instance. 272 // Temporarily keeps the ArcSupportHost instance.
275 // This should be moved to ArcSessionManager when the refactoring is 273 // This should be moved to ArcSessionManager when the refactoring is
276 // done. 274 // done.
277 std::unique_ptr<ArcSupportHost> support_host_; 275 std::unique_ptr<ArcSupportHost> support_host_;
278 // Handles preferences and metrics mode. 276 // Handles preferences and metrics mode.
279 std::unique_ptr<arc::ArcOptInPreferenceHandler> preference_handler_; 277 std::unique_ptr<arc::ArcOptInPreferenceHandler> preference_handler_;
280 278
281 std::unique_ptr<ArcAuthContext> context_; 279 std::unique_ptr<ArcAuthContext> context_;
282 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_; 280 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_;
283 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; 281 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_;
284 282
285 base::Time sign_in_time_; 283 base::Time sign_in_time_;
286 284
287 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; 285 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_;
288 286
289 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 287 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
290 }; 288 };
291 289
292 // Outputs the stringified |state| to |os|. This is only for logging purposes. 290 // Outputs the stringified |state| to |os|. This is only for logging purposes.
293 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 291 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
294 292
295 } // namespace arc 293 } // namespace arc
296 294
297 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 295 #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