Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1499)

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager.h

Issue 2534883002: Extract ArcTermsOfServiceNegotiator implementation. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SESSION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_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_support_host.h" 16 #include "chrome/browser/chromeos/arc/arc_support_host.h"
17 #include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler_observe r.h"
18 #include "chrome/browser/chromeos/policy/android_management_client.h" 17 #include "chrome/browser/chromeos/policy/android_management_client.h"
19 #include "components/arc/arc_bridge_service.h" 18 #include "components/arc/arc_bridge_service.h"
20 #include "components/arc/arc_service.h" 19 #include "components/arc/arc_service.h"
21 #include "components/prefs/pref_change_registrar.h" 20 #include "components/prefs/pref_change_registrar.h"
22 #include "components/sync_preferences/pref_service_syncable_observer.h" 21 #include "components/sync_preferences/pref_service_syncable_observer.h"
23 #include "components/sync_preferences/synced_pref_observer.h" 22 #include "components/sync_preferences/synced_pref_observer.h"
24 #include "mojo/public/cpp/bindings/binding.h" 23 #include "mojo/public/cpp/bindings/binding.h"
25 24
26 class ArcAppLauncher; 25 class ArcAppLauncher;
27 class Profile; 26 class Profile;
28 27
29 namespace ash { 28 namespace ash {
30 class ShelfDelegate; 29 class ShelfDelegate;
31 } 30 }
32 31
33 namespace user_prefs { 32 namespace user_prefs {
34 class PrefRegistrySyncable; 33 class PrefRegistrySyncable;
35 } 34 }
36 35
37 namespace arc { 36 namespace arc {
38 37
39 class ArcAndroidManagementChecker; 38 class ArcAndroidManagementChecker;
40 class ArcAuthCodeFetcher; 39 class ArcAuthCodeFetcher;
41 class ArcAuthContext; 40 class ArcAuthContext;
42 class ArcOptInPreferenceHandler; 41 class ArcTermsOfServiceNegotiator;
43 enum class ProvisioningResult : int; 42 enum class ProvisioningResult : int;
44 43
45 // This class proxies the request from the client to fetch an auth code from 44 // This class proxies the request from the client to fetch an auth code from
46 // LSO. It lives on the UI thread. 45 // LSO. It lives on the UI thread.
47 class ArcSessionManager : public ArcService, 46 class ArcSessionManager : public ArcService,
48 public ArcBridgeService::Observer, 47 public ArcBridgeService::Observer,
49 public ArcSupportHost::Observer, 48 public ArcSupportHost::Observer,
50 public ArcOptInPreferenceHandlerObserver,
51 public sync_preferences::PrefServiceSyncableObserver, 49 public sync_preferences::PrefServiceSyncableObserver,
52 public sync_preferences::SyncedPrefObserver { 50 public sync_preferences::SyncedPrefObserver {
53 public: 51 public:
54 // Represents each State of ARC session. 52 // Represents each State of ARC session.
55 // NOT_INITIALIZED: represents the state that the Profile is not yet ready 53 // NOT_INITIALIZED: represents the state that the Profile is not yet ready
56 // so that this service is not yet initialized, or Chrome is being shut 54 // so that this service is not yet initialized, or Chrome is being shut
57 // down so that this is destroyed. 55 // down so that this is destroyed.
58 // STOPPED: ARC session is not running, or being terminated. 56 // STOPPED: ARC session is not running, or being terminated.
59 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support 57 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support
60 // Chrome app. 58 // Chrome app.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; 172 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override;
175 173
176 // ArcSupportHost::Observer: 174 // ArcSupportHost::Observer:
177 void OnWindowClosed() override; 175 void OnWindowClosed() override;
178 void OnTermsAgreed(bool is_metrics_enabled, 176 void OnTermsAgreed(bool is_metrics_enabled,
179 bool is_backup_and_restore_enabled, 177 bool is_backup_and_restore_enabled,
180 bool is_location_service_enabled) override; 178 bool is_location_service_enabled) override;
181 void OnRetryClicked() override; 179 void OnRetryClicked() override;
182 void OnSendFeedbackClicked() override; 180 void OnSendFeedbackClicked() override;
183 181
184 // ArcOptInPreferenceHandlerObserver:
185 void OnMetricsModeChanged(bool enabled, bool managed) override;
186 void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override;
187 void OnLocationServicesModeChanged(bool enabled, bool managed) override;
188
189 // Stops ARC without changing ArcEnabled preference. 182 // Stops ARC without changing ArcEnabled preference.
190 void StopArc(); 183 void StopArc();
191 184
192 // StopArc(), then EnableArc(). Between them data clear may happens. 185 // StopArc(), then EnableArc(). Between them data clear may happens.
193 // This is a special method to support enterprise device lost case. 186 // This is a special method to support enterprise device lost case.
194 // This can be called only when ARC is running. 187 // This can be called only when ARC is running.
195 void StopAndEnableArc(); 188 void StopAndEnableArc();
196 189
197 // Removes the data if ARC is stopped. Otherwise, queue to remove the data 190 // Removes the data if ARC is stopped. Otherwise, queue to remove the data
198 // on ARC is stopped. 191 // on ARC is stopped.
199 void RemoveArcData(); 192 void RemoveArcData();
200 193
201 ArcSupportHost* support_host() { return support_host_.get(); } 194 ArcSupportHost* support_host() { return support_host_.get(); }
202 195
203 // TODO(hidehiko): Get rid of the getter by migration between ArcAuthContext 196 // TODO(hidehiko): Get rid of the getter by migration between ArcAuthContext
204 // and ArcAuthCodeFetcher. 197 // and ArcAuthCodeFetcher.
205 ArcAuthContext* auth_context() { return context_.get(); } 198 ArcAuthContext* auth_context() { return context_.get(); }
206 199
207 void StartArc(); 200 void StartArc();
208 201
209 void OnProvisioningFinished(ProvisioningResult result); 202 void OnProvisioningFinished(ProvisioningResult result);
210 203
211 private: 204 private:
212 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. 205 // Negotiates the terms of service to user.
206 void StartTermsOfServiceNegotiate();
Luis Héctor Chávez 2016/11/29 00:15:28 nit: StartTermsOfServiceNegotiation
hidehiko 2016/11/29 17:43:28 Done.
207 void OnTermsOfServiceNegotiated(bool agreed);
208
213 void SetState(State state); 209 void SetState(State state);
214 void ShutdownBridge(); 210 void ShutdownBridge();
215 void OnOptInPreferenceChanged(); 211 void OnOptInPreferenceChanged();
216 void StartUI();
217 void OnAndroidManagementPassed(); 212 void OnAndroidManagementPassed();
218 void OnArcDataRemoved(bool success); 213 void OnArcDataRemoved(bool success);
219 void OnArcSignInTimeout(); 214 void OnArcSignInTimeout();
220 void FetchAuthCode(); 215 void FetchAuthCode();
221 void PrepareContextForAuthCodeRequest(); 216 void PrepareContextForAuthCodeRequest();
222 217
223 void StartArcAndroidManagementCheck(); 218 void StartArcAndroidManagementCheck();
224 219
225 // Called when the Android management check is done in opt-in flow or 220 // Called when the Android management check is done in opt-in flow or
226 // re-auth flow. 221 // re-auth flow.
(...skipping 11 matching lines...) Expand all
238 // Registrar used to monitor ARC enabled state. 233 // Registrar used to monitor ARC enabled state.
239 PrefChangeRegistrar pref_change_registrar_; 234 PrefChangeRegistrar pref_change_registrar_;
240 235
241 State state_ = State::NOT_INITIALIZED; 236 State state_ = State::NOT_INITIALIZED;
242 base::ObserverList<Observer> observer_list_; 237 base::ObserverList<Observer> observer_list_;
243 std::unique_ptr<ArcAppLauncher> playstore_launcher_; 238 std::unique_ptr<ArcAppLauncher> playstore_launcher_;
244 bool clear_required_ = false; 239 bool clear_required_ = false;
245 bool reenable_arc_ = false; 240 bool reenable_arc_ = false;
246 base::OneShotTimer arc_sign_in_timer_; 241 base::OneShotTimer arc_sign_in_timer_;
247 242
248 // Temporarily keeps the ArcSupportHost instance.
249 // This should be moved to ArcSessionManager when the refactoring is
250 // done.
251 std::unique_ptr<ArcSupportHost> support_host_; 243 std::unique_ptr<ArcSupportHost> support_host_;
252 // Handles preferences and metrics mode. 244
253 std::unique_ptr<ArcOptInPreferenceHandler> preference_handler_; 245 std::unique_ptr<ArcTermsOfServiceNegotiator> terms_of_service_negotiator_;
254 246
255 std::unique_ptr<ArcAuthContext> context_; 247 std::unique_ptr<ArcAuthContext> context_;
256 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; 248 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_;
257 249
258 base::Time sign_in_time_; 250 base::Time sign_in_time_;
259 251
260 base::WeakPtrFactory<ArcSessionManager> weak_ptr_factory_; 252 base::WeakPtrFactory<ArcSessionManager> weak_ptr_factory_;
261 253
262 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); 254 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager);
263 }; 255 };
264 256
265 // Outputs the stringified |state| to |os|. This is only for logging purposes. 257 // Outputs the stringified |state| to |os|. This is only for logging purposes.
266 std::ostream& operator<<(std::ostream& os, 258 std::ostream& operator<<(std::ostream& os,
267 const ArcSessionManager::State& state); 259 const ArcSessionManager::State& state);
268 260
269 } // namespace arc 261 } // namespace arc
270 262
271 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ 263 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698