| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // FETCHING_CODE -> ACTIVE: when the auth token is successfully fetched. | 94 // FETCHING_CODE -> ACTIVE: when the auth token is successfully fetched. |
| 95 // | 95 // |
| 96 // In the second (or later) boot case: | 96 // In the second (or later) boot case: |
| 97 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is | 97 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is |
| 98 // true. Practically, this is when the primary Profile gets ready. | 98 // true. Practically, this is when the primary Profile gets ready. |
| 99 enum class State { | 99 enum class State { |
| 100 NOT_INITIALIZED, | 100 NOT_INITIALIZED, |
| 101 STOPPED, | 101 STOPPED, |
| 102 SHOWING_TERMS_OF_SERVICE, | 102 SHOWING_TERMS_OF_SERVICE, |
| 103 CHECKING_ANDROID_MANAGEMENT, | 103 CHECKING_ANDROID_MANAGEMENT, |
| 104 FETCHING_CODE, | |
| 105 ACTIVE, | 104 ACTIVE, |
| 106 }; | 105 }; |
| 107 | 106 |
| 108 class Observer { | 107 class Observer { |
| 109 public: | 108 public: |
| 110 virtual ~Observer() = default; | 109 virtual ~Observer() = default; |
| 111 | 110 |
| 112 // Called to notify that ARC bridge is shut down. | 111 // Called to notify that ARC bridge is shut down. |
| 113 virtual void OnShutdownBridge() {} | 112 virtual void OnShutdownBridge() {} |
| 114 | 113 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 142 bool IsAllowed() const; | 141 bool IsAllowed() const; |
| 143 | 142 |
| 144 void OnPrimaryUserProfilePrepared(Profile* profile); | 143 void OnPrimaryUserProfilePrepared(Profile* profile); |
| 145 void Shutdown(); | 144 void Shutdown(); |
| 146 | 145 |
| 147 Profile* profile() { return profile_; } | 146 Profile* profile() { return profile_; } |
| 148 const Profile* profile() const { return profile_; } | 147 const Profile* profile() const { return profile_; } |
| 149 | 148 |
| 150 State state() const { return state_; } | 149 State state() const { return state_; } |
| 151 | 150 |
| 152 std::string GetAndResetAuthCode(); | |
| 153 | |
| 154 // Adds or removes observers. | 151 // Adds or removes observers. |
| 155 void AddObserver(Observer* observer); | 152 void AddObserver(Observer* observer); |
| 156 void RemoveObserver(Observer* observer); | 153 void RemoveObserver(Observer* observer); |
| 157 | 154 |
| 158 // ArcBridgeService::Observer: | 155 // ArcBridgeService::Observer: |
| 159 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; | 156 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
| 160 | 157 |
| 161 // InstanceHolder<mojom::AuthInstance>::Observer: | 158 // InstanceHolder<mojom::AuthInstance>::Observer: |
| 162 void OnInstanceReady() override; | 159 void OnInstanceReady() override; |
| 163 | 160 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 176 void GetAuthCodeAndAccountTypeDeprecated( | 173 void GetAuthCodeAndAccountTypeDeprecated( |
| 177 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; | 174 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; |
| 178 // 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 |
| 179 // user. | 176 // user. |
| 180 void GetIsAccountManagedDeprecated( | 177 void GetIsAccountManagedDeprecated( |
| 181 const GetIsAccountManagedDeprecatedCallback& callback) override; | 178 const GetIsAccountManagedDeprecatedCallback& callback) override; |
| 182 | 179 |
| 183 void OnSignInFailedInternal(ProvisioningResult result); | 180 void OnSignInFailedInternal(ProvisioningResult result); |
| 184 | 181 |
| 185 // Called from Arc support platform app to set auth code and start arc. | 182 // Called from Arc support platform app to set auth code and start arc. |
| 186 void SetAuthCodeAndStartArc(const std::string& auth_code); | 183 void OnAuthCodeObtained(const std::string& auth_code); |
| 187 | 184 |
| 188 // Called from Arc support platform app when user cancels signing. | 185 // Called from Arc support platform app when user cancels signing. |
| 189 void CancelAuthCode(); | 186 void CancelAuthCode(); |
| 190 | 187 |
| 191 bool IsArcManaged() const; | 188 bool IsArcManaged() const; |
| 192 bool IsArcEnabled() const; | 189 bool IsArcEnabled() const; |
| 193 | 190 |
| 194 // This requires Arc to be allowed (|IsAllowed|)for current profile. | 191 // This requires Arc to be allowed (|IsAllowed|)for current profile. |
| 195 void EnableArc(); | 192 void EnableArc(); |
| 196 void DisableArc(); | 193 void DisableArc(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 void RemoveArcData(); | 237 void RemoveArcData(); |
| 241 | 238 |
| 242 // Returns current page that has to be shown in OptIn UI. | 239 // Returns current page that has to be shown in OptIn UI. |
| 243 ArcSupportHost::UIPage ui_page() const { return ui_page_; } | 240 ArcSupportHost::UIPage ui_page() const { return ui_page_; } |
| 244 | 241 |
| 245 // Returns current page status, relevant to the specific page. | 242 // Returns current page status, relevant to the specific page. |
| 246 const base::string16& ui_page_status() const { return ui_page_status_; } | 243 const base::string16& ui_page_status() const { return ui_page_status_; } |
| 247 | 244 |
| 248 ArcSupportHost* support_host() { return support_host_.get(); } | 245 ArcSupportHost* support_host() { return support_host_.get(); } |
| 249 | 246 |
| 247 void StartArc(); |
| 248 |
| 250 private: | 249 private: |
| 251 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; | 250 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; |
| 252 class AccountInfoNotifier; | 251 class AccountInfoNotifier; |
| 253 | 252 |
| 254 void StartArc(); | |
| 255 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. | 253 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. |
| 256 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status); | 254 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status); |
| 257 void CloseUI(); | 255 void CloseUI(); |
| 258 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status); | 256 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status); |
| 259 void SetState(State state); | 257 void SetState(State state); |
| 260 void ShutdownBridge(); | 258 void ShutdownBridge(); |
| 261 void ShutdownBridgeAndCloseUI(); | 259 void ShutdownBridgeAndCloseUI(); |
| 262 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, | 260 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, |
| 263 const base::string16& status); | 261 const base::string16& status); |
| 264 void OnOptInPreferenceChanged(); | 262 void OnOptInPreferenceChanged(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 289 // Unowned pointer. Keeps current profile. | 287 // Unowned pointer. Keeps current profile. |
| 290 Profile* profile_ = nullptr; | 288 Profile* profile_ = nullptr; |
| 291 | 289 |
| 292 // Registrar used to monitor ARC enabled state. | 290 // Registrar used to monitor ARC enabled state. |
| 293 PrefChangeRegistrar pref_change_registrar_; | 291 PrefChangeRegistrar pref_change_registrar_; |
| 294 | 292 |
| 295 mojo::Binding<AuthHost> binding_; | 293 mojo::Binding<AuthHost> binding_; |
| 296 State state_ = State::NOT_INITIALIZED; | 294 State state_ = State::NOT_INITIALIZED; |
| 297 base::ObserverList<Observer> observer_list_; | 295 base::ObserverList<Observer> observer_list_; |
| 298 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 296 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| 299 std::string auth_code_; | |
| 300 ArcSupportHost::UIPage ui_page_ = ArcSupportHost::UIPage::NO_PAGE; | 297 ArcSupportHost::UIPage ui_page_ = ArcSupportHost::UIPage::NO_PAGE; |
| 301 base::string16 ui_page_status_; | 298 base::string16 ui_page_status_; |
| 302 bool clear_required_ = false; | 299 bool clear_required_ = false; |
| 303 bool reenable_arc_ = false; | 300 bool reenable_arc_ = false; |
| 304 base::OneShotTimer arc_sign_in_timer_; | 301 base::OneShotTimer arc_sign_in_timer_; |
| 305 | 302 |
| 306 // Notifies the correct callback whenever the auth_code is ready. | 303 // Notifies the correct callback whenever the auth_code is ready. |
| 307 std::unique_ptr<AccountInfoNotifier> account_info_notifier_; | 304 std::unique_ptr<AccountInfoNotifier> account_info_notifier_; |
| 308 | 305 |
| 309 // Temporarily keeps the ArcSupportHost instance. | 306 // Temporarily keeps the ArcSupportHost instance. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 324 | 321 |
| 325 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 322 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 326 }; | 323 }; |
| 327 | 324 |
| 328 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 325 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 329 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 326 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 330 | 327 |
| 331 } // namespace arc | 328 } // namespace arc |
| 332 | 329 |
| 333 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 330 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |