| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 void AddObserver(Observer* observer); | 126 void AddObserver(Observer* observer); |
| 127 void RemoveObserver(Observer* observer); | 127 void RemoveObserver(Observer* observer); |
| 128 | 128 |
| 129 // ArcBridgeService::Observer: | 129 // ArcBridgeService::Observer: |
| 130 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; | 130 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
| 131 | 131 |
| 132 // InstanceHolder<mojom::AuthInstance>::Observer: | 132 // InstanceHolder<mojom::AuthInstance>::Observer: |
| 133 void OnInstanceReady() override; | 133 void OnInstanceReady() override; |
| 134 | 134 |
| 135 // AuthHost: | 135 // AuthHost: |
| 136 void OnSignInComplete() override; |
| 137 void OnSignInFailed(mojom::ArcSignInFailureReason reason) override; |
| 138 void RequestAccountInfo() override; |
| 139 |
| 140 // Deprecated methods: |
| 136 // For security reason this code can be used only once and exists for specific | 141 // For security reason this code can be used only once and exists for specific |
| 137 // period of time. | 142 // period of time. |
| 143 void GetAuthCodeDeprecated0( |
| 144 const GetAuthCodeDeprecated0Callback& callback) override; |
| 138 void GetAuthCodeDeprecated( | 145 void GetAuthCodeDeprecated( |
| 139 const GetAuthCodeDeprecatedCallback& callback) override; | 146 const GetAuthCodeDeprecatedCallback& callback) override; |
| 140 void GetAuthCode(const GetAuthCodeCallback& callback) override; | 147 void GetAuthCodeAndAccountTypeDeprecated( |
| 141 void GetAuthCodeAndAccountType( | 148 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; |
| 142 const GetAuthCodeAndAccountTypeCallback& callback) override; | |
| 143 void OnSignInComplete() override; | |
| 144 void OnSignInFailed(mojom::ArcSignInFailureReason reason) override; | |
| 145 // Callback is called with a bool that indicates the management status of the | 149 // Callback is called with a bool that indicates the management status of the |
| 146 // user. | 150 // user. |
| 147 void GetIsAccountManaged( | 151 void GetIsAccountManagedDeprecated( |
| 148 const GetIsAccountManagedCallback& callback) override; | 152 const GetIsAccountManagedDeprecatedCallback& callback) override; |
| 149 | 153 |
| 150 void OnSignInFailedInternal(ProvisioningResult result); | 154 void OnSignInFailedInternal(ProvisioningResult result); |
| 151 | 155 |
| 152 // Called from Arc support platform app to start LSO. | 156 // Called from Arc support platform app to start LSO. |
| 153 void StartLso(); | 157 void StartLso(); |
| 154 | 158 |
| 155 // Called from Arc support platform app to set auth code and start arc. | 159 // Called from Arc support platform app to set auth code and start arc. |
| 156 void SetAuthCodeAndStartArc(const std::string& auth_code); | 160 void SetAuthCodeAndStartArc(const std::string& auth_code); |
| 157 | 161 |
| 158 // Called from Arc support platform app when user cancels signing. | 162 // Called from Arc support platform app when user cancels signing. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 197 |
| 194 // Returns current page that has to be shown in OptIn UI. | 198 // Returns current page that has to be shown in OptIn UI. |
| 195 UIPage ui_page() const { return ui_page_; } | 199 UIPage ui_page() const { return ui_page_; } |
| 196 | 200 |
| 197 // Returns current page status, relevant to the specific page. | 201 // Returns current page status, relevant to the specific page. |
| 198 const base::string16& ui_page_status() const { return ui_page_status_; } | 202 const base::string16& ui_page_status() const { return ui_page_status_; } |
| 199 | 203 |
| 200 ArcSupportHost* support_host() { return support_host_.get(); } | 204 ArcSupportHost* support_host() { return support_host_.get(); } |
| 201 | 205 |
| 202 private: | 206 private: |
| 207 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; |
| 208 class AccountInfoNotifier; |
| 209 |
| 203 void StartArc(); | 210 void StartArc(); |
| 204 // TODO: move UI methods/fields to ArcSupportHost. | 211 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. |
| 205 void ShowUI(UIPage page, const base::string16& status); | 212 void ShowUI(UIPage page, const base::string16& status); |
| 206 void CloseUI(); | 213 void CloseUI(); |
| 207 void SetUIPage(UIPage page, const base::string16& status); | 214 void SetUIPage(UIPage page, const base::string16& status); |
| 208 void SetState(State state); | 215 void SetState(State state); |
| 209 void ShutdownBridge(); | 216 void ShutdownBridge(); |
| 210 void ShutdownBridgeAndCloseUI(); | 217 void ShutdownBridgeAndCloseUI(); |
| 211 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); | 218 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); |
| 212 void OnOptInPreferenceChanged(); | 219 void OnOptInPreferenceChanged(); |
| 213 void StartUI(); | 220 void StartUI(); |
| 214 void StartAndroidManagementClient(); | 221 void StartAndroidManagementClient(); |
| 215 void OnAndroidManagementPassed(); | 222 void OnAndroidManagementPassed(); |
| 216 void OnArcDataRemoved(bool success); | 223 void OnArcDataRemoved(bool success); |
| 217 void OnArcSignInTimeout(); | 224 void OnArcSignInTimeout(); |
| 218 bool IsAuthCodeRequest() const; | 225 bool IsAuthCodeRequest() const; |
| 219 void FetchAuthCode(); | 226 void FetchAuthCode(); |
| 220 void PrepareContextForAuthCodeRequest(); | 227 void PrepareContextForAuthCodeRequest(); |
| 228 void RequestAccountInfoInternal( |
| 229 std::unique_ptr<AccountInfoNotifier> account_info_notifier); |
| 230 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); |
| 221 | 231 |
| 222 // Called when the Android management check is done in opt-in flow or | 232 // Called when the Android management check is done in opt-in flow or |
| 223 // re-auth flow. | 233 // re-auth flow. |
| 224 void OnAndroidManagementChecked( | 234 void OnAndroidManagementChecked( |
| 225 policy::AndroidManagementClient::Result result); | 235 policy::AndroidManagementClient::Result result); |
| 226 | 236 |
| 227 // Called when the background Android management check is done. It is | 237 // Called when the background Android management check is done. It is |
| 228 // triggered when the second or later ARC boot timing. | 238 // triggered when the second or later ARC boot timing. |
| 229 void OnBackgroundAndroidManagementChecked( | 239 void OnBackgroundAndroidManagementChecked( |
| 230 policy::AndroidManagementClient::Result result); | 240 policy::AndroidManagementClient::Result result); |
| 231 | 241 |
| 232 // Unowned pointer. Keeps current profile. | 242 // Unowned pointer. Keeps current profile. |
| 233 Profile* profile_ = nullptr; | 243 Profile* profile_ = nullptr; |
| 234 | 244 |
| 235 // Registrar used to monitor ARC enabled state. | 245 // Registrar used to monitor ARC enabled state. |
| 236 PrefChangeRegistrar pref_change_registrar_; | 246 PrefChangeRegistrar pref_change_registrar_; |
| 237 | 247 |
| 238 mojo::Binding<AuthHost> binding_; | 248 mojo::Binding<AuthHost> binding_; |
| 239 State state_ = State::NOT_INITIALIZED; | 249 State state_ = State::NOT_INITIALIZED; |
| 240 base::ObserverList<Observer> observer_list_; | 250 base::ObserverList<Observer> observer_list_; |
| 241 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 251 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| 242 std::string auth_code_; | 252 std::string auth_code_; |
| 243 GetAuthCodeCallback auth_callback_; | |
| 244 GetAuthCodeAndAccountTypeCallback auth_account_callback_; | |
| 245 bool initial_opt_in_ = false; | 253 bool initial_opt_in_ = false; |
| 246 UIPage ui_page_ = UIPage::NO_PAGE; | 254 UIPage ui_page_ = UIPage::NO_PAGE; |
| 247 base::string16 ui_page_status_; | 255 base::string16 ui_page_status_; |
| 248 bool clear_required_ = false; | 256 bool clear_required_ = false; |
| 249 bool reenable_arc_ = false; | 257 bool reenable_arc_ = false; |
| 250 base::OneShotTimer arc_sign_in_timer_; | 258 base::OneShotTimer arc_sign_in_timer_; |
| 251 | 259 |
| 260 // Notifies the correct callback whenever the auth_code is ready. |
| 261 std::unique_ptr<AccountInfoNotifier> account_info_notifier_; |
| 262 |
| 252 // Temporarily keeps the ArcSupportHost instance. | 263 // Temporarily keeps the ArcSupportHost instance. |
| 253 // This should be moved to ArcSessionManager when the refactoring is | 264 // This should be moved to ArcSessionManager when the refactoring is |
| 254 // done. | 265 // done. |
| 255 std::unique_ptr<ArcSupportHost> support_host_; | 266 std::unique_ptr<ArcSupportHost> support_host_; |
| 256 | 267 |
| 257 std::unique_ptr<ArcAuthContext> context_; | 268 std::unique_ptr<ArcAuthContext> context_; |
| 258 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_; | 269 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_; |
| 259 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; | 270 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; |
| 260 | 271 |
| 261 base::Time sign_in_time_; | 272 base::Time sign_in_time_; |
| 262 | 273 |
| 263 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | 274 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
| 264 | 275 |
| 265 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 276 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 266 }; | 277 }; |
| 267 | 278 |
| 268 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 279 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 269 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 280 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 270 | 281 |
| 271 } // namespace arc | 282 } // namespace arc |
| 272 | 283 |
| 273 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 284 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |