| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 public mojom::AuthHost, | 53 public mojom::AuthHost, |
| 54 public ArcBridgeService::Observer, | 54 public ArcBridgeService::Observer, |
| 55 public InstanceHolder<mojom::AuthInstance>::Observer, | 55 public InstanceHolder<mojom::AuthInstance>::Observer, |
| 56 public ArcSupportHost::Observer, | 56 public ArcSupportHost::Observer, |
| 57 public ArcOptInPreferenceHandlerObserver, | 57 public ArcOptInPreferenceHandlerObserver, |
| 58 public ArcAuthContextDelegate, | 58 public ArcAuthContextDelegate, |
| 59 public ArcAuthCodeFetcherDelegate, | 59 public ArcAuthCodeFetcherDelegate, |
| 60 public sync_preferences::PrefServiceSyncableObserver, | 60 public sync_preferences::PrefServiceSyncableObserver, |
| 61 public sync_preferences::SyncedPrefObserver { | 61 public sync_preferences::SyncedPrefObserver { |
| 62 public: | 62 public: |
| 63 // Represents each State of ARC session. |
| 64 // NOT_INITIALIZED: represents the state that the Profile is not yet ready |
| 65 // so that this service is not yet initialized, or Chrome is being shut |
| 66 // down so that this is destroyed. |
| 67 // STOPPED: ARC session is not running, or being terminated. |
| 68 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support |
| 69 // Chrome app. |
| 70 // CHECKING_ANDROID_MANAGEMENT: Checking Android management status. Note that |
| 71 // the status is checked for each ARC session starting, but this is the |
| 72 // state only for the first boot case (= opt-in case). The second time and |
| 73 // later the management check is running in parallel with ARC session |
| 74 // starting, and in such a case, State is ACTIVE, instead. |
| 75 // FETCHING_CODE: Fetching an auth token. Similar to |
| 76 // CHECKING_ANDROID_MANAGEMENT case, this is only for the first boot case. |
| 77 // In re-auth flow (fetching an auth token while ARC is running), the |
| 78 // State should be ACTIVE. |
| 79 // TODO(hidehiko): Migrate into re-auth flow, then remove this state. |
| 80 // ACTIVE: ARC is running. |
| 81 // |
| 82 // State transition should be as follows: |
| 83 // |
| 84 // NOT_INITIALIZED -> STOPPED: when the primary Profile gets ready. |
| 85 // ...(any)... -> NOT_INITIALIZED: when the Chrome is being shutdown. |
| 86 // ...(any)... -> STOPPED: on error. |
| 87 // |
| 88 // In the first boot case (no OOBE case): |
| 89 // STOPPED -> SHOWING_TERMS_OF_SERVICE: when arc.enabled preference is set. |
| 90 // SHOWING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user |
| 91 // agree with "Terms Of Service" |
| 92 // CHECKING_ANDROID_MANAGEMENT -> FETCHING_CODE: when Android management |
| 93 // check passes. |
| 94 // FETCHING_CODE -> ACTIVE: when the auth token is successfully fetched. |
| 95 // |
| 96 // In the first boot case (OOBE case): |
| 97 // STOPPED -> FETCHING_CODE: When arc.enabled preference is set. |
| 98 // FETCHING_CODE -> ACTIVE: when the auth token is successfully fetched. |
| 99 // |
| 100 // In the second (or later) boot case: |
| 101 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is |
| 102 // true. Practically, this is when the primary Profile gets ready. |
| 63 enum class State { | 103 enum class State { |
| 64 NOT_INITIALIZED, // Service is not initialized. | 104 NOT_INITIALIZED, |
| 65 STOPPED, // ARC is not running. | 105 STOPPED, |
| 66 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. | 106 SHOWING_TERMS_OF_SERVICE, |
| 67 ACTIVE, // ARC is running. | 107 CHECKING_ANDROID_MANAGEMENT, |
| 108 FETCHING_CODE, |
| 109 ACTIVE, |
| 68 }; | 110 }; |
| 69 | 111 |
| 70 class Observer { | 112 class Observer { |
| 71 public: | 113 public: |
| 72 virtual ~Observer() = default; | 114 virtual ~Observer() = default; |
| 73 | 115 |
| 74 // Called to notify that ARC bridge is shut down. | 116 // Called to notify that ARC bridge is shut down. |
| 75 virtual void OnShutdownBridge() {} | 117 virtual void OnShutdownBridge() {} |
| 76 | 118 |
| 77 // Called to notify that ARC enabled state has been updated. | 119 // Called to notify that ARC enabled state has been updated. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const GetAuthCodeDeprecatedCallback& callback) override; | 179 const GetAuthCodeDeprecatedCallback& callback) override; |
| 138 void GetAuthCodeAndAccountTypeDeprecated( | 180 void GetAuthCodeAndAccountTypeDeprecated( |
| 139 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; | 181 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; |
| 140 // Callback is called with a bool that indicates the management status of the | 182 // Callback is called with a bool that indicates the management status of the |
| 141 // user. | 183 // user. |
| 142 void GetIsAccountManagedDeprecated( | 184 void GetIsAccountManagedDeprecated( |
| 143 const GetIsAccountManagedDeprecatedCallback& callback) override; | 185 const GetIsAccountManagedDeprecatedCallback& callback) override; |
| 144 | 186 |
| 145 void OnSignInFailedInternal(ProvisioningResult result); | 187 void OnSignInFailedInternal(ProvisioningResult result); |
| 146 | 188 |
| 147 // Called from Arc support platform app to start LSO. | |
| 148 void StartLso(); | |
| 149 | |
| 150 // Called from Arc support platform app to set auth code and start arc. | 189 // Called from Arc support platform app to set auth code and start arc. |
| 151 void SetAuthCodeAndStartArc(const std::string& auth_code); | 190 void SetAuthCodeAndStartArc(const std::string& auth_code); |
| 152 | 191 |
| 153 // Called from Arc support platform app when user cancels signing. | 192 // Called from Arc support platform app when user cancels signing. |
| 154 void CancelAuthCode(); | 193 void CancelAuthCode(); |
| 155 | 194 |
| 156 bool IsArcManaged() const; | 195 bool IsArcManaged() const; |
| 157 bool IsArcEnabled() const; | 196 bool IsArcEnabled() const; |
| 158 | 197 |
| 159 // This requires Arc to be allowed (|IsAllowed|)for current profile. | 198 // This requires Arc to be allowed (|IsAllowed|)for current profile. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 177 // ArcAuthCodeFetcherDelegate: | 216 // ArcAuthCodeFetcherDelegate: |
| 178 void OnAuthCodeSuccess(const std::string& auth_code) override; | 217 void OnAuthCodeSuccess(const std::string& auth_code) override; |
| 179 void OnAuthCodeFailed() override; | 218 void OnAuthCodeFailed() override; |
| 180 | 219 |
| 181 // ArcSupportHost::Observer: | 220 // ArcSupportHost::Observer: |
| 182 void OnWindowClosed() override; | 221 void OnWindowClosed() override; |
| 183 void OnTermsAgreed(bool is_metrics_enabled, | 222 void OnTermsAgreed(bool is_metrics_enabled, |
| 184 bool is_backup_and_restore_enabled, | 223 bool is_backup_and_restore_enabled, |
| 185 bool is_location_service_enabled) override; | 224 bool is_location_service_enabled) override; |
| 186 void OnAuthSucceeded(const std::string& auth_code) override; | 225 void OnAuthSucceeded(const std::string& auth_code) override; |
| 226 void OnRetryClicked() override; |
| 187 void OnSendFeedbackClicked() override; | 227 void OnSendFeedbackClicked() override; |
| 188 | 228 |
| 189 // arc::ArcOptInPreferenceHandlerObserver: | 229 // arc::ArcOptInPreferenceHandlerObserver: |
| 190 void OnMetricsModeChanged(bool enabled, bool managed) override; | 230 void OnMetricsModeChanged(bool enabled, bool managed) override; |
| 191 void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override; | 231 void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override; |
| 192 void OnLocationServicesModeChanged(bool enabled, bool managed) override; | 232 void OnLocationServicesModeChanged(bool enabled, bool managed) override; |
| 193 | 233 |
| 194 // Stops ARC without changing ArcEnabled preference. | 234 // Stops ARC without changing ArcEnabled preference. |
| 195 void StopArc(); | 235 void StopArc(); |
| 196 | 236 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 220 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status); | 260 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status); |
| 221 void CloseUI(); | 261 void CloseUI(); |
| 222 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status); | 262 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status); |
| 223 void SetState(State state); | 263 void SetState(State state); |
| 224 void ShutdownBridge(); | 264 void ShutdownBridge(); |
| 225 void ShutdownBridgeAndCloseUI(); | 265 void ShutdownBridgeAndCloseUI(); |
| 226 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, | 266 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, |
| 227 const base::string16& status); | 267 const base::string16& status); |
| 228 void OnOptInPreferenceChanged(); | 268 void OnOptInPreferenceChanged(); |
| 229 void StartUI(); | 269 void StartUI(); |
| 230 void StartAndroidManagementClient(); | |
| 231 void OnAndroidManagementPassed(); | 270 void OnAndroidManagementPassed(); |
| 232 void OnArcDataRemoved(bool success); | 271 void OnArcDataRemoved(bool success); |
| 233 void OnArcSignInTimeout(); | 272 void OnArcSignInTimeout(); |
| 234 bool IsAuthCodeRequest() const; | 273 bool IsAuthCodeRequest() const; |
| 235 void FetchAuthCode(); | 274 void FetchAuthCode(); |
| 236 void PrepareContextForAuthCodeRequest(); | 275 void PrepareContextForAuthCodeRequest(); |
| 237 void RequestAccountInfoInternal( | 276 void RequestAccountInfoInternal( |
| 238 std::unique_ptr<AccountInfoNotifier> account_info_notifier); | 277 std::unique_ptr<AccountInfoNotifier> account_info_notifier); |
| 239 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); | 278 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); |
| 240 void OnRobotAuthCodeFetched(const std::string& auth_code); | 279 void OnRobotAuthCodeFetched(const std::string& auth_code); |
| 241 | 280 |
| 281 void StartArcAndroidManagementCheck(); |
| 282 |
| 242 // Called when the Android management check is done in opt-in flow or | 283 // Called when the Android management check is done in opt-in flow or |
| 243 // re-auth flow. | 284 // re-auth flow. |
| 244 void OnAndroidManagementChecked( | 285 void OnAndroidManagementChecked( |
| 245 policy::AndroidManagementClient::Result result); | 286 policy::AndroidManagementClient::Result result); |
| 246 | 287 |
| 247 // Called when the background Android management check is done. It is | 288 // Called when the background Android management check is done. It is |
| 248 // triggered when the second or later ARC boot timing. | 289 // triggered when the second or later ARC boot timing. |
| 249 void OnBackgroundAndroidManagementChecked( | 290 void OnBackgroundAndroidManagementChecked( |
| 250 policy::AndroidManagementClient::Result result); | 291 policy::AndroidManagementClient::Result result); |
| 251 | 292 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 328 |
| 288 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 329 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 289 }; | 330 }; |
| 290 | 331 |
| 291 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 332 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 292 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 333 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 293 | 334 |
| 294 } // namespace arc | 335 } // namespace arc |
| 295 | 336 |
| 296 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 337 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |