Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_session_manager.h |
| diff --git a/chrome/browser/chromeos/arc/arc_auth_service.h b/chrome/browser/chromeos/arc/arc_session_manager.h |
| similarity index 73% |
| copy from chrome/browser/chromeos/arc/arc_auth_service.h |
| copy to chrome/browser/chromeos/arc/arc_session_manager.h |
| index b330a4c364016039c707baebf776672ba2163904..d4a8a9d749bc7524407dd1a1ae29100728dea55d 100644 |
| --- a/chrome/browser/chromeos/arc/arc_auth_service.h |
| +++ b/chrome/browser/chromeos/arc/arc_session_manager.h |
| @@ -2,8 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| -#define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| +#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ |
| #include <memory> |
| #include <ostream> |
| @@ -18,8 +18,6 @@ |
| #include "chrome/browser/chromeos/policy/android_management_client.h" |
| #include "components/arc/arc_bridge_service.h" |
| #include "components/arc/arc_service.h" |
| -#include "components/arc/common/auth.mojom.h" |
| -#include "components/arc/instance_holder.h" |
| #include "components/prefs/pref_change_registrar.h" |
| #include "components/sync_preferences/pref_service_syncable_observer.h" |
| #include "components/sync_preferences/synced_pref_observer.h" |
| @@ -47,14 +45,12 @@ enum class ProvisioningResult : int; |
| // This class proxies the request from the client to fetch an auth code from |
| // LSO. It lives on the UI thread. |
| -class ArcAuthService : public ArcService, |
| - public mojom::AuthHost, |
| - public ArcBridgeService::Observer, |
| - public InstanceHolder<mojom::AuthInstance>::Observer, |
| - public ArcSupportHost::Observer, |
| - public ArcOptInPreferenceHandlerObserver, |
| - public sync_preferences::PrefServiceSyncableObserver, |
| - public sync_preferences::SyncedPrefObserver { |
| +class ArcSessionManager : public ArcService, |
| + public ArcBridgeService::Observer, |
| + public ArcSupportHost::Observer, |
| + public ArcOptInPreferenceHandlerObserver, |
| + public sync_preferences::PrefServiceSyncableObserver, |
| + public sync_preferences::SyncedPrefObserver { |
| public: |
| // Represents each State of ARC session. |
| // NOT_INITIALIZED: represents the state that the Profile is not yet ready |
| @@ -118,10 +114,10 @@ class ArcAuthService : public ArcService, |
| virtual void OnInitialStart() {} |
| }; |
| - explicit ArcAuthService(ArcBridgeService* bridge_service); |
| - ~ArcAuthService() override; |
| + explicit ArcSessionManager(ArcBridgeService* bridge_service); |
| + ~ArcSessionManager() override; |
| - static ArcAuthService* Get(); |
| + static ArcSessionManager* Get(); |
| // It is called from chrome/browser/prefs/browser_prefs.cc. |
| static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| @@ -137,6 +133,9 @@ class ArcAuthService : public ArcService, |
| // Returns true if Arc is allowed to run for the given profile. |
| static bool IsAllowedForProfile(const Profile* profile); |
| + // Returns true if ARC should run under Kiosk mode. |
| + static bool IsArcKioskMode(); |
| + |
| // Returns true if Arc is allowed to run for the current session. |
| bool IsAllowed() const; |
| @@ -155,28 +154,6 @@ class ArcAuthService : public ArcService, |
| // ArcBridgeService::Observer: |
| void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
| - // InstanceHolder<mojom::AuthInstance>::Observer: |
| - void OnInstanceReady() override; |
| - |
| - // AuthHost: |
| - void OnSignInComplete() override; |
| - void OnSignInFailed(mojom::ArcSignInFailureReason reason) override; |
| - void RequestAccountInfo() override; |
| - |
| - // Deprecated methods: |
| - // For security reason this code can be used only once and exists for specific |
| - // period of time. |
| - void GetAuthCodeDeprecated0( |
| - const GetAuthCodeDeprecated0Callback& callback) override; |
| - void GetAuthCodeDeprecated( |
| - const GetAuthCodeDeprecatedCallback& callback) override; |
| - void GetAuthCodeAndAccountTypeDeprecated( |
| - const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; |
| - // Callback is called with a bool that indicates the management status of the |
| - // user. |
| - void GetIsAccountManagedDeprecated( |
| - const GetIsAccountManagedDeprecatedCallback& callback) override; |
| - |
| // Called from Arc support platform app when user cancels signing. |
| void CancelAuthCode(); |
| @@ -202,11 +179,10 @@ class ArcAuthService : public ArcService, |
| void OnTermsAgreed(bool is_metrics_enabled, |
| bool is_backup_and_restore_enabled, |
| bool is_location_service_enabled) override; |
| - void OnAuthSucceeded(const std::string& auth_code) override; |
| void OnRetryClicked() override; |
| void OnSendFeedbackClicked() override; |
| - // arc::ArcOptInPreferenceHandlerObserver: |
| + // ArcOptInPreferenceHandlerObserver: |
| void OnMetricsModeChanged(bool enabled, bool managed) override; |
| void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override; |
| void OnLocationServicesModeChanged(bool enabled, bool managed) override; |
| @@ -225,14 +201,15 @@ class ArcAuthService : public ArcService, |
| ArcSupportHost* support_host() { return support_host_.get(); } |
|
Luis Héctor Chávez
2016/11/16 17:13:34
nit: I missed this earlier, but you can make this
hidehiko
2016/11/16 19:52:05
As ArcSupportHost, which is owned by ArcSessionMan
Luis Héctor Chávez
2016/11/16 23:03:31
I guess it's ok to keep it non-const.
|
| + // TODO(hidehiko): Get rid of the getter by migration between ArcAuthContext |
| + // and ArcAuthCodeFetcher. |
| + ArcAuthContext* auth_context() { return context_.get(); } |
| + |
| void StartArc(); |
| void OnProvisioningFinished(ProvisioningResult result); |
| private: |
| - using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; |
| - class AccountInfoNotifier; |
| - |
| // TODO(hidehiko): move UI methods/fields to ArcSupportHost. |
| void SetState(State state); |
| void ShutdownBridge(); |
| @@ -243,20 +220,6 @@ class ArcAuthService : public ArcService, |
| void OnArcSignInTimeout(); |
| void FetchAuthCode(); |
| void PrepareContextForAuthCodeRequest(); |
| - void RequestAccountInfoInternal( |
| - std::unique_ptr<AccountInfoNotifier> account_info_notifier); |
| - void OnAccountInfoReady(mojom::AccountInfoPtr account_info); |
| - |
| - // Callback for Robot auth in Kiosk mode. |
| - void OnRobotAuthCodeFetched(const std::string& auth_code); |
| - |
| - // Callback for automatic auth code fetching when --arc-user-auth-endpoint |
| - // flag is set. |
| - void OnAuthCodeFetched(const std::string& auth_code); |
| - |
| - // Common procedure across LSO auth code fetching, automatic auth code |
| - // fetching, and Robot auth. |
| - void OnAuthCodeObtained(const std::string& auth_code); |
| void StartArcAndroidManagementCheck(); |
| @@ -276,7 +239,6 @@ class ArcAuthService : public ArcService, |
| // Registrar used to monitor ARC enabled state. |
| PrefChangeRegistrar pref_change_registrar_; |
| - mojo::Binding<AuthHost> binding_; |
| State state_ = State::NOT_INITIALIZED; |
| base::ObserverList<Observer> observer_list_; |
| std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| @@ -284,31 +246,27 @@ class ArcAuthService : public ArcService, |
| bool reenable_arc_ = false; |
| base::OneShotTimer arc_sign_in_timer_; |
| - // Notifies the correct callback whenever the auth_code is ready. |
| - std::unique_ptr<AccountInfoNotifier> account_info_notifier_; |
| - |
| // Temporarily keeps the ArcSupportHost instance. |
| // This should be moved to ArcSessionManager when the refactoring is |
| // done. |
| std::unique_ptr<ArcSupportHost> support_host_; |
| // Handles preferences and metrics mode. |
| - std::unique_ptr<arc::ArcOptInPreferenceHandler> preference_handler_; |
| + std::unique_ptr<ArcOptInPreferenceHandler> preference_handler_; |
| std::unique_ptr<ArcAuthContext> context_; |
| - std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_; |
| std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; |
| - std::unique_ptr<ArcRobotAuth> arc_robot_auth_; |
| base::Time sign_in_time_; |
| - base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
| + base::WeakPtrFactory<ArcSessionManager> weak_ptr_factory_; |
| - DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| + DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); |
| }; |
| // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| -std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| +std::ostream& operator<<(std::ostream& os, |
| + const ArcSessionManager::State& state); |
| } // namespace arc |
| -#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ |