| 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" | 16 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher_delegate.h" |
| 17 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" | 17 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" |
| 18 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker_dele
gate.h" | 18 #include "chrome/browser/chromeos/policy/android_management_client.h" |
| 19 #include "components/arc/arc_bridge_service.h" | 19 #include "components/arc/arc_bridge_service.h" |
| 20 #include "components/arc/arc_service.h" | 20 #include "components/arc/arc_service.h" |
| 21 #include "components/arc/common/auth.mojom.h" | 21 #include "components/arc/common/auth.mojom.h" |
| 22 #include "components/arc/instance_holder.h" | 22 #include "components/arc/instance_holder.h" |
| 23 #include "components/prefs/pref_change_registrar.h" | 23 #include "components/prefs/pref_change_registrar.h" |
| 24 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 24 #include "components/syncable_prefs/pref_service_syncable_observer.h" |
| 25 #include "components/syncable_prefs/synced_pref_observer.h" | 25 #include "components/syncable_prefs/synced_pref_observer.h" |
| 26 #include "mojo/public/cpp/bindings/binding.h" | 26 #include "mojo/public/cpp/bindings/binding.h" |
| 27 | 27 |
| 28 class ArcAppLauncher; | 28 class ArcAppLauncher; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 44 class ArcAuthCodeFetcher; | 44 class ArcAuthCodeFetcher; |
| 45 class ArcAuthContext; | 45 class ArcAuthContext; |
| 46 enum class ProvisioningResult : int; | 46 enum class ProvisioningResult : int; |
| 47 | 47 |
| 48 // 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 |
| 49 // LSO. It lives on the UI thread. | 49 // LSO. It lives on the UI thread. |
| 50 class ArcAuthService : public ArcService, | 50 class ArcAuthService : public ArcService, |
| 51 public mojom::AuthHost, | 51 public mojom::AuthHost, |
| 52 public ArcBridgeService::Observer, | 52 public ArcBridgeService::Observer, |
| 53 public InstanceHolder<mojom::AuthInstance>::Observer, | 53 public InstanceHolder<mojom::AuthInstance>::Observer, |
| 54 public ArcAndroidManagementCheckerDelegate, | |
| 55 public ArcAuthContextDelegate, | 54 public ArcAuthContextDelegate, |
| 56 public ArcAuthCodeFetcherDelegate, | 55 public ArcAuthCodeFetcherDelegate, |
| 57 public syncable_prefs::PrefServiceSyncableObserver, | 56 public syncable_prefs::PrefServiceSyncableObserver, |
| 58 public syncable_prefs::SyncedPrefObserver { | 57 public syncable_prefs::SyncedPrefObserver { |
| 59 public: | 58 public: |
| 60 enum class State { | 59 enum class State { |
| 61 NOT_INITIALIZED, // Service is not initialized. | 60 NOT_INITIALIZED, // Service is not initialized. |
| 62 STOPPED, // ARC is not running. | 61 STOPPED, // ARC is not running. |
| 63 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. | 62 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. |
| 64 ACTIVE, // ARC is running. | 63 ACTIVE, // ARC is running. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; | 173 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; |
| 175 | 174 |
| 176 // ArcAuthContextDelegate: | 175 // ArcAuthContextDelegate: |
| 177 void OnContextReady() override; | 176 void OnContextReady() override; |
| 178 void OnPrepareContextFailed() override; | 177 void OnPrepareContextFailed() override; |
| 179 | 178 |
| 180 // ArcAuthCodeFetcherDelegate: | 179 // ArcAuthCodeFetcherDelegate: |
| 181 void OnAuthCodeSuccess(const std::string& auth_code) override; | 180 void OnAuthCodeSuccess(const std::string& auth_code) override; |
| 182 void OnAuthCodeFailed() override; | 181 void OnAuthCodeFailed() override; |
| 183 | 182 |
| 184 // ArcAndroidManagementCheckerDelegate: | |
| 185 void OnAndroidManagementChecked( | |
| 186 policy::AndroidManagementClient::Result result) override; | |
| 187 | |
| 188 // Stops ARC without changing ArcEnabled preference. | 183 // Stops ARC without changing ArcEnabled preference. |
| 189 void StopArc(); | 184 void StopArc(); |
| 190 | 185 |
| 191 // StopArc(), then EnableArc(). Between them data clear may happens. | 186 // StopArc(), then EnableArc(). Between them data clear may happens. |
| 192 // This is a special method to support enterprise device lost case. | 187 // This is a special method to support enterprise device lost case. |
| 193 // This can be called only when ARC is running. | 188 // This can be called only when ARC is running. |
| 194 void StopAndEnableArc(); | 189 void StopAndEnableArc(); |
| 195 | 190 |
| 196 // Removes the data if ARC is stopped. Otherwise, queue to remove the data | 191 // Removes the data if ARC is stopped. Otherwise, queue to remove the data |
| 197 // on ARC is stopped. | 192 // on ARC is stopped. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 211 void ShowUI(UIPage page, const base::string16& status); | 206 void ShowUI(UIPage page, const base::string16& status); |
| 212 void CloseUI(); | 207 void CloseUI(); |
| 213 void SetUIPage(UIPage page, const base::string16& status); | 208 void SetUIPage(UIPage page, const base::string16& status); |
| 214 void SetState(State state); | 209 void SetState(State state); |
| 215 void ShutdownBridge(); | 210 void ShutdownBridge(); |
| 216 void ShutdownBridgeAndCloseUI(); | 211 void ShutdownBridgeAndCloseUI(); |
| 217 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); | 212 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); |
| 218 void OnOptInPreferenceChanged(); | 213 void OnOptInPreferenceChanged(); |
| 219 void StartUI(); | 214 void StartUI(); |
| 220 void StartAndroidManagementClient(); | 215 void StartAndroidManagementClient(); |
| 221 void CheckAndroidManagement(bool background_mode); | |
| 222 void OnAndroidManagementPassed(); | 216 void OnAndroidManagementPassed(); |
| 223 void OnArcDataRemoved(bool success); | 217 void OnArcDataRemoved(bool success); |
| 224 void OnArcSignInTimeout(); | 218 void OnArcSignInTimeout(); |
| 225 bool IsAuthCodeRequest() const; | 219 bool IsAuthCodeRequest() const; |
| 226 void FetchAuthCode(); | 220 void FetchAuthCode(); |
| 227 void PrepareContextForAuthCodeRequest(); | 221 void PrepareContextForAuthCodeRequest(); |
| 228 | 222 |
| 223 // Called when the Android management check is done in opt-in flow or |
| 224 // re-auth flow. |
| 225 void OnAndroidManagementChecked( |
| 226 policy::AndroidManagementClient::Result result); |
| 227 |
| 228 // Called when the background Android management check is done. It is |
| 229 // triggered when the second or later ARC boot timing. |
| 230 void OnBackgroundAndroidManagementChecked( |
| 231 policy::AndroidManagementClient::Result result); |
| 232 |
| 229 // Unowned pointer. Keeps current profile. | 233 // Unowned pointer. Keeps current profile. |
| 230 Profile* profile_ = nullptr; | 234 Profile* profile_ = nullptr; |
| 231 | 235 |
| 232 // Registrar used to monitor ARC enabled state. | 236 // Registrar used to monitor ARC enabled state. |
| 233 PrefChangeRegistrar pref_change_registrar_; | 237 PrefChangeRegistrar pref_change_registrar_; |
| 234 | 238 |
| 235 mojo::Binding<AuthHost> binding_; | 239 mojo::Binding<AuthHost> binding_; |
| 236 State state_ = State::NOT_INITIALIZED; | 240 State state_ = State::NOT_INITIALIZED; |
| 237 base::ObserverList<Observer> observer_list_; | 241 base::ObserverList<Observer> observer_list_; |
| 238 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 242 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 262 | 266 |
| 263 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 267 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 264 }; | 268 }; |
| 265 | 269 |
| 266 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 270 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 267 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 271 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 268 | 272 |
| 269 } // namespace arc | 273 } // namespace arc |
| 270 | 274 |
| 271 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 275 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |