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 "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h" | 15 #include "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher_delegate.h" |
16 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" | 17 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" |
17 #include "components/arc/arc_bridge_service.h" | 18 #include "components/arc/arc_bridge_service.h" |
18 #include "components/arc/arc_service.h" | 19 #include "components/arc/arc_service.h" |
19 #include "components/arc/common/auth.mojom.h" | 20 #include "components/arc/common/auth.mojom.h" |
20 #include "components/arc/instance_holder.h" | 21 #include "components/arc/instance_holder.h" |
21 #include "components/prefs/pref_change_registrar.h" | 22 #include "components/prefs/pref_change_registrar.h" |
22 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 23 #include "components/syncable_prefs/pref_service_syncable_observer.h" |
23 #include "components/syncable_prefs/synced_pref_observer.h" | 24 #include "components/syncable_prefs/synced_pref_observer.h" |
24 #include "mojo/public/cpp/bindings/binding.h" | 25 #include "mojo/public/cpp/bindings/binding.h" |
25 | 26 |
26 class ArcAppLauncher; | 27 class ArcAppLauncher; |
27 class Profile; | 28 class Profile; |
28 | 29 |
29 namespace ash { | 30 namespace ash { |
30 class ShelfDelegate; | 31 class ShelfDelegate; |
31 } | 32 } |
32 | 33 |
33 namespace user_prefs { | 34 namespace user_prefs { |
34 class PrefRegistrySyncable; | 35 class PrefRegistrySyncable; |
35 } | 36 } |
36 | 37 |
37 namespace arc { | 38 namespace arc { |
38 | 39 |
39 class ArcAndroidManagementChecker; | 40 class ArcAndroidManagementChecker; |
| 41 class ArcAuthCodeFetcher; |
40 class ArcAuthContext; | 42 class ArcAuthContext; |
41 enum class ProvisioningResult : int; | 43 enum class ProvisioningResult : int; |
42 | 44 |
43 // This class proxies the request from the client to fetch an auth code from | 45 // This class proxies the request from the client to fetch an auth code from |
44 // LSO. It lives on the UI thread. | 46 // LSO. It lives on the UI thread. |
45 class ArcAuthService : public ArcService, | 47 class ArcAuthService : public ArcService, |
46 public mojom::AuthHost, | 48 public mojom::AuthHost, |
47 public ArcBridgeService::Observer, | 49 public ArcBridgeService::Observer, |
48 public InstanceHolder<mojom::AuthInstance>::Observer, | 50 public InstanceHolder<mojom::AuthInstance>::Observer, |
49 public ArcAndroidManagementCheckerDelegate, | 51 public ArcAndroidManagementCheckerDelegate, |
50 public ArcAuthContextDelegate, | 52 public ArcAuthContextDelegate, |
| 53 public ArcAuthCodeFetcherDelegate, |
51 public syncable_prefs::PrefServiceSyncableObserver, | 54 public syncable_prefs::PrefServiceSyncableObserver, |
52 public syncable_prefs::SyncedPrefObserver { | 55 public syncable_prefs::SyncedPrefObserver { |
53 public: | 56 public: |
54 enum class State { | 57 enum class State { |
55 NOT_INITIALIZED, // Service is not initialized. | 58 NOT_INITIALIZED, // Service is not initialized. |
56 STOPPED, // ARC is not running. | 59 STOPPED, // ARC is not running. |
57 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. | 60 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. |
58 ACTIVE, // ARC is running. | 61 ACTIVE, // ARC is running. |
59 }; | 62 }; |
60 | 63 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // syncable_prefs::PrefServiceSyncableObserver | 171 // syncable_prefs::PrefServiceSyncableObserver |
169 void OnIsSyncingChanged() override; | 172 void OnIsSyncingChanged() override; |
170 | 173 |
171 // syncable_prefs::SyncedPrefObserver | 174 // syncable_prefs::SyncedPrefObserver |
172 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; | 175 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; |
173 | 176 |
174 // ArcAuthContextDelegate: | 177 // ArcAuthContextDelegate: |
175 void OnContextReady() override; | 178 void OnContextReady() override; |
176 void OnPrepareContextFailed() override; | 179 void OnPrepareContextFailed() override; |
177 | 180 |
| 181 // ArcAuthCodeFetcherDelegate: |
| 182 void OnAuthCodeSuccess(const std::string& auth_code) override; |
| 183 void OnAuthCodeFailed() override; |
| 184 |
178 // ArcAndroidManagementCheckerDelegate: | 185 // ArcAndroidManagementCheckerDelegate: |
179 void OnAndroidManagementChecked( | 186 void OnAndroidManagementChecked( |
180 policy::AndroidManagementClient::Result result) override; | 187 policy::AndroidManagementClient::Result result) override; |
181 | 188 |
182 // Stops ARC without changing ArcEnabled preference. | 189 // Stops ARC without changing ArcEnabled preference. |
183 void StopArc(); | 190 void StopArc(); |
184 | 191 |
185 // StopArc(), then EnableArc(). Between them data clear may happens. | 192 // StopArc(), then EnableArc(). Between them data clear may happens. |
186 // This is a special method to support enterprise device lost case. | 193 // This is a special method to support enterprise device lost case. |
187 // This can be called only when ARC is running. | 194 // This can be called only when ARC is running. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 GetAuthCodeCallback auth_callback_; | 234 GetAuthCodeCallback auth_callback_; |
228 bool initial_opt_in_ = false; | 235 bool initial_opt_in_ = false; |
229 bool disable_arc_from_ui_ = false; | 236 bool disable_arc_from_ui_ = false; |
230 UIPage ui_page_ = UIPage::NO_PAGE; | 237 UIPage ui_page_ = UIPage::NO_PAGE; |
231 base::string16 ui_page_status_; | 238 base::string16 ui_page_status_; |
232 bool clear_required_ = false; | 239 bool clear_required_ = false; |
233 bool reenable_arc_ = false; | 240 bool reenable_arc_ = false; |
234 bool waiting_for_reply_ = false; | 241 bool waiting_for_reply_ = false; |
235 | 242 |
236 std::unique_ptr<ArcAuthContext> context_; | 243 std::unique_ptr<ArcAuthContext> context_; |
| 244 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_; |
237 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; | 245 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; |
238 | 246 |
239 base::Time sign_in_time_; | 247 base::Time sign_in_time_; |
240 | 248 |
241 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | 249 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
242 | 250 |
243 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 251 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
244 }; | 252 }; |
245 | 253 |
246 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 254 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
247 | 255 |
248 } // namespace arc | 256 } // namespace arc |
249 | 257 |
250 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 258 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
OLD | NEW |