| 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> |
| 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 "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher_delegate.h" | |
| 17 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" | |
| 18 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 16 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 19 #include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler_observe
r.h" | 17 #include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler_observe
r.h" |
| 20 #include "chrome/browser/chromeos/policy/android_management_client.h" | 18 #include "chrome/browser/chromeos/policy/android_management_client.h" |
| 21 #include "components/arc/arc_bridge_service.h" | 19 #include "components/arc/arc_bridge_service.h" |
| 22 #include "components/arc/arc_service.h" | 20 #include "components/arc/arc_service.h" |
| 23 #include "components/arc/common/auth.mojom.h" | 21 #include "components/arc/common/auth.mojom.h" |
| 24 #include "components/arc/instance_holder.h" | 22 #include "components/arc/instance_holder.h" |
| 25 #include "components/prefs/pref_change_registrar.h" | 23 #include "components/prefs/pref_change_registrar.h" |
| 26 #include "components/sync_preferences/pref_service_syncable_observer.h" | 24 #include "components/sync_preferences/pref_service_syncable_observer.h" |
| 27 #include "components/sync_preferences/synced_pref_observer.h" | 25 #include "components/sync_preferences/synced_pref_observer.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 enum class ProvisioningResult : int; | 46 enum class ProvisioningResult : int; |
| 49 | 47 |
| 50 // This class proxies the request from the client to fetch an auth code from | 48 // This class proxies the request from the client to fetch an auth code from |
| 51 // LSO. It lives on the UI thread. | 49 // LSO. It lives on the UI thread. |
| 52 class ArcAuthService : public ArcService, | 50 class ArcAuthService : public ArcService, |
| 53 public mojom::AuthHost, | 51 public mojom::AuthHost, |
| 54 public ArcBridgeService::Observer, | 52 public ArcBridgeService::Observer, |
| 55 public InstanceHolder<mojom::AuthInstance>::Observer, | 53 public InstanceHolder<mojom::AuthInstance>::Observer, |
| 56 public ArcSupportHost::Observer, | 54 public ArcSupportHost::Observer, |
| 57 public ArcOptInPreferenceHandlerObserver, | 55 public ArcOptInPreferenceHandlerObserver, |
| 58 public ArcAuthContextDelegate, | |
| 59 public ArcAuthCodeFetcherDelegate, | |
| 60 public sync_preferences::PrefServiceSyncableObserver, | 56 public sync_preferences::PrefServiceSyncableObserver, |
| 61 public sync_preferences::SyncedPrefObserver { | 57 public sync_preferences::SyncedPrefObserver { |
| 62 public: | 58 public: |
| 63 // Represents each State of ARC session. | 59 // Represents each State of ARC session. |
| 64 // NOT_INITIALIZED: represents the state that the Profile is not yet ready | 60 // 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 | 61 // so that this service is not yet initialized, or Chrome is being shut |
| 66 // down so that this is destroyed. | 62 // down so that this is destroyed. |
| 67 // STOPPED: ARC session is not running, or being terminated. | 63 // STOPPED: ARC session is not running, or being terminated. |
| 68 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support | 64 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support |
| 69 // Chrome app. | 65 // Chrome app. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const GetAuthCodeDeprecated0Callback& callback) override; | 170 const GetAuthCodeDeprecated0Callback& callback) override; |
| 175 void GetAuthCodeDeprecated( | 171 void GetAuthCodeDeprecated( |
| 176 const GetAuthCodeDeprecatedCallback& callback) override; | 172 const GetAuthCodeDeprecatedCallback& callback) override; |
| 177 void GetAuthCodeAndAccountTypeDeprecated( | 173 void GetAuthCodeAndAccountTypeDeprecated( |
| 178 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; | 174 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; |
| 179 // Callback is called with a bool that indicates the management status of the | 175 // Callback is called with a bool that indicates the management status of the |
| 180 // user. | 176 // user. |
| 181 void GetIsAccountManagedDeprecated( | 177 void GetIsAccountManagedDeprecated( |
| 182 const GetIsAccountManagedDeprecatedCallback& callback) override; | 178 const GetIsAccountManagedDeprecatedCallback& callback) override; |
| 183 | 179 |
| 184 // Called from Arc support platform app to set auth code and start arc. | |
| 185 void OnAuthCodeObtained(const std::string& auth_code); | |
| 186 | |
| 187 // Called from Arc support platform app when user cancels signing. | 180 // Called from Arc support platform app when user cancels signing. |
| 188 void CancelAuthCode(); | 181 void CancelAuthCode(); |
| 189 | 182 |
| 190 bool IsArcManaged() const; | 183 bool IsArcManaged() const; |
| 191 bool IsArcEnabled() const; | 184 bool IsArcEnabled() const; |
| 192 | 185 |
| 193 // This requires Arc to be allowed (|IsAllowed|)for current profile. | 186 // This requires Arc to be allowed (|IsAllowed|)for current profile. |
| 194 void EnableArc(); | 187 void EnableArc(); |
| 195 void DisableArc(); | 188 void DisableArc(); |
| 196 | 189 |
| 197 // Called from the Chrome OS metrics provider to record Arc.State | 190 // Called from the Chrome OS metrics provider to record Arc.State |
| 198 // periodically. | 191 // periodically. |
| 199 void RecordArcState(); | 192 void RecordArcState(); |
| 200 | 193 |
| 201 // sync_preferences::PrefServiceSyncableObserver | 194 // sync_preferences::PrefServiceSyncableObserver |
| 202 void OnIsSyncingChanged() override; | 195 void OnIsSyncingChanged() override; |
| 203 | 196 |
| 204 // sync_preferences::SyncedPrefObserver | 197 // sync_preferences::SyncedPrefObserver |
| 205 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; | 198 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; |
| 206 | 199 |
| 207 // ArcAuthContextDelegate: | |
| 208 void OnContextReady() override; | |
| 209 void OnPrepareContextFailed() override; | |
| 210 | |
| 211 // ArcAuthCodeFetcherDelegate: | |
| 212 void OnAuthCodeSuccess(const std::string& auth_code) override; | |
| 213 void OnAuthCodeFailed() override; | |
| 214 | |
| 215 // ArcSupportHost::Observer: | 200 // ArcSupportHost::Observer: |
| 216 void OnWindowClosed() override; | 201 void OnWindowClosed() override; |
| 217 void OnTermsAgreed(bool is_metrics_enabled, | 202 void OnTermsAgreed(bool is_metrics_enabled, |
| 218 bool is_backup_and_restore_enabled, | 203 bool is_backup_and_restore_enabled, |
| 219 bool is_location_service_enabled) override; | 204 bool is_location_service_enabled) override; |
| 220 void OnAuthSucceeded(const std::string& auth_code) override; | 205 void OnAuthSucceeded(const std::string& auth_code) override; |
| 221 void OnRetryClicked() override; | 206 void OnRetryClicked() override; |
| 222 void OnSendFeedbackClicked() override; | 207 void OnSendFeedbackClicked() override; |
| 223 | 208 |
| 224 // arc::ArcOptInPreferenceHandlerObserver: | 209 // arc::ArcOptInPreferenceHandlerObserver: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 249 class AccountInfoNotifier; | 234 class AccountInfoNotifier; |
| 250 | 235 |
| 251 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. | 236 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. |
| 252 void SetState(State state); | 237 void SetState(State state); |
| 253 void ShutdownBridge(); | 238 void ShutdownBridge(); |
| 254 void OnOptInPreferenceChanged(); | 239 void OnOptInPreferenceChanged(); |
| 255 void StartUI(); | 240 void StartUI(); |
| 256 void OnAndroidManagementPassed(); | 241 void OnAndroidManagementPassed(); |
| 257 void OnArcDataRemoved(bool success); | 242 void OnArcDataRemoved(bool success); |
| 258 void OnArcSignInTimeout(); | 243 void OnArcSignInTimeout(); |
| 259 bool IsAuthCodeRequest() const; | |
| 260 void FetchAuthCode(); | 244 void FetchAuthCode(); |
| 261 void PrepareContextForAuthCodeRequest(); | 245 void PrepareContextForAuthCodeRequest(); |
| 262 void RequestAccountInfoInternal( | 246 void RequestAccountInfoInternal( |
| 263 std::unique_ptr<AccountInfoNotifier> account_info_notifier); | 247 std::unique_ptr<AccountInfoNotifier> account_info_notifier); |
| 264 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); | 248 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); |
| 249 |
| 250 // Callback for Robot auth in Kiosk mode. |
| 265 void OnRobotAuthCodeFetched(const std::string& auth_code); | 251 void OnRobotAuthCodeFetched(const std::string& auth_code); |
| 266 | 252 |
| 253 // Callback for automatic auth code fetching when --arc-user-auth-endpoint |
| 254 // flag is set. |
| 255 void OnAuthCodeFetched(const std::string& auth_code); |
| 256 |
| 257 // Common procedure across LSO auth code fetching, automatic auth code |
| 258 // fetching, and Robot auth. |
| 259 void OnAuthCodeObtained(const std::string& auth_code); |
| 260 |
| 267 void StartArcAndroidManagementCheck(); | 261 void StartArcAndroidManagementCheck(); |
| 268 | 262 |
| 269 // Called when the Android management check is done in opt-in flow or | 263 // Called when the Android management check is done in opt-in flow or |
| 270 // re-auth flow. | 264 // re-auth flow. |
| 271 void OnAndroidManagementChecked( | 265 void OnAndroidManagementChecked( |
| 272 policy::AndroidManagementClient::Result result); | 266 policy::AndroidManagementClient::Result result); |
| 273 | 267 |
| 274 // Called when the background Android management check is done. It is | 268 // Called when the background Android management check is done. It is |
| 275 // triggered when the second or later ARC boot timing. | 269 // triggered when the second or later ARC boot timing. |
| 276 void OnBackgroundAndroidManagementChecked( | 270 void OnBackgroundAndroidManagementChecked( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 305 |
| 312 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 306 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 313 }; | 307 }; |
| 314 | 308 |
| 315 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 309 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 316 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 310 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 317 | 311 |
| 318 } // namespace arc | 312 } // namespace arc |
| 319 | 313 |
| 320 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 314 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |