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_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> |
(...skipping 24 matching lines...) Expand all Loading... | |
35 // This class proxies the request from the client to fetch an auth code from | 35 // This class proxies the request from the client to fetch an auth code from |
36 // LSO. It lives on the UI thread. | 36 // LSO. It lives on the UI thread. |
37 class ArcSessionManager : public ArcSessionRunner::Observer, | 37 class ArcSessionManager : public ArcSessionRunner::Observer, |
38 public ArcSupportHost::Observer { | 38 public ArcSupportHost::Observer { |
39 public: | 39 public: |
40 // Represents each State of ARC session. | 40 // Represents each State of ARC session. |
41 // NOT_INITIALIZED: represents the state that the Profile is not yet ready | 41 // NOT_INITIALIZED: represents the state that the Profile is not yet ready |
42 // so that this service is not yet initialized, or Chrome is being shut | 42 // so that this service is not yet initialized, or Chrome is being shut |
43 // down so that this is destroyed. | 43 // down so that this is destroyed. |
44 // STOPPED: ARC session is not running, or being terminated. | 44 // STOPPED: ARC session is not running, or being terminated. |
45 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support | 45 // NEGOTIATING_TERMS_OF_SERVICE: Negotiating Google Play Store "Terms of |
46 // Chrome app. | 46 // Service" with a user. There are several ways for the negotiation, |
47 // including opt-in flow, which shows "Terms of Service" page on ARC | |
48 // support app, and OOBE flow, which shows "Terms of Service" page as a | |
49 // part of Chrome OOBE flow. | |
50 // If user does not accept the Terms of Service, disables Google Play | |
51 // Store, which triggers RequestDisable() and the state will be set to | |
52 // STOPPED, then. | |
47 // CHECKING_ANDROID_MANAGEMENT: Checking Android management status. Note that | 53 // CHECKING_ANDROID_MANAGEMENT: Checking Android management status. Note that |
48 // the status is checked for each ARC session starting, but this is the | 54 // the status is checked for each ARC session starting, but this is the |
49 // state only for the first boot case (= opt-in case). The second time and | 55 // state only for the first boot case (= opt-in case). The second time and |
50 // later the management check is running in parallel with ARC session | 56 // later the management check is running in parallel with ARC session |
51 // starting, and in such a case, State is ACTIVE, instead. | 57 // starting, and in such a case, State is ACTIVE, instead. |
52 // REMOVING_DATA_DIR: When ARC is disabled, the data directory is removed. | 58 // REMOVING_DATA_DIR: When ARC is disabled, the data directory is removed. |
53 // While removing is processed, ARC cannot be started. This is the state. | 59 // While removing is processed, ARC cannot be started. This is the state. |
54 // ACTIVE: ARC is running. | 60 // ACTIVE: ARC is running. |
55 // | 61 // |
56 // State transition should be as follows: | 62 // State transition should be as follows: |
57 // | 63 // |
58 // NOT_INITIALIZED -> STOPPED: when the primary Profile gets ready. | 64 // NOT_INITIALIZED -> STOPPED: when the primary Profile gets ready. |
59 // ...(any)... -> NOT_INITIALIZED: when the Chrome is being shutdown. | 65 // ...(any)... -> NOT_INITIALIZED: when the Chrome is being shutdown. |
60 // ...(any)... -> STOPPED: on error. | 66 // ...(any)... -> STOPPED: on error. |
61 // | 67 // |
62 // In the first boot case: | 68 // In the first boot case: |
63 // STOPPED -> SHOWING_TERMS_OF_SERVICE: when arc.enabled preference is set. | 69 // STOPPED -> NEGOTIATING_TERMS_OF_SERVICE: On request to enable. |
hidehiko
2017/03/06 13:38:39
Note: More detailed comment will come as a part of
| |
64 // SHOWING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user | 70 // NEGOTIATING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user |
65 // agree with "Terms Of Service" | 71 // accepts with "Terms Of Service" |
Yusuke Sato
2017/03/06 20:52:16
s/with//
hidehiko
2017/03/07 14:52:20
Done.
| |
66 // CHECKING_ANDROID_MANAGEMENT -> ACTIVE: when the auth token is | 72 // CHECKING_ANDROID_MANAGEMENT -> ACTIVE: when the auth token is |
67 // successfully fetched. | 73 // successfully fetched. |
68 // | 74 // |
69 // In the second (or later) boot case: | 75 // In the second (or later) boot case: |
70 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is | 76 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is |
71 // true. Practically, this is when the primary Profile gets ready. | 77 // true. Practically, this is when the primary Profile gets ready. |
72 // | 78 // |
73 // TODO(hidehiko): Fix the state machine, and update the comment including | 79 // TODO(hidehiko): Fix the state machine, and update the comment including |
74 // relationship with |enable_requested_|. | 80 // relationship with |enable_requested_|. |
75 enum class State { | 81 enum class State { |
76 NOT_INITIALIZED, | 82 NOT_INITIALIZED, |
77 STOPPED, | 83 STOPPED, |
78 SHOWING_TERMS_OF_SERVICE, | 84 NEGOTIATING_TERMS_OF_SERVICE, |
79 CHECKING_ANDROID_MANAGEMENT, | 85 CHECKING_ANDROID_MANAGEMENT, |
80 REMOVING_DATA_DIR, | 86 REMOVING_DATA_DIR, |
81 ACTIVE, | 87 ACTIVE, |
82 }; | 88 }; |
83 | 89 |
84 // Observer for those services outside of ARC which want to know ARC events. | 90 // Observer for those services outside of ARC which want to know ARC events. |
85 class Observer { | 91 class Observer { |
86 public: | 92 public: |
87 // Called to notify that whether Google Play Store is enabled or not, which | 93 // Called to notify that whether Google Play Store is enabled or not, which |
88 // is represented by "arc.enabled" preference, is updated. | 94 // is represented by "arc.enabled" preference, is updated. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 | 229 |
224 private: | 230 private: |
225 // RequestEnable() has a check in order not to trigger starting procedure | 231 // RequestEnable() has a check in order not to trigger starting procedure |
226 // twice. This method can be called to bypass that check when restarting. | 232 // twice. This method can be called to bypass that check when restarting. |
227 void RequestEnableImpl(); | 233 void RequestEnableImpl(); |
228 | 234 |
229 // Negotiates the terms of service to user. | 235 // Negotiates the terms of service to user. |
230 void StartTermsOfServiceNegotiation(); | 236 void StartTermsOfServiceNegotiation(); |
231 void OnTermsOfServiceNegotiated(bool accepted); | 237 void OnTermsOfServiceNegotiated(bool accepted); |
232 | 238 |
239 // Returns true if Terms of Service negotiation is needed. Otherwise false. | |
240 // TODO(crbug.com/698418): Write unittest for this utility after extracting | |
241 // ToS related code from ArcSessionManager into a dedicated class. | |
242 bool IsArcTermsOfServiceNegotiationNeeded() const; | |
243 | |
233 // Returns whether ARC is managed and all ARC related OptIn preferences are | 244 // Returns whether ARC is managed and all ARC related OptIn preferences are |
234 // managed too. | 245 // managed too. |
235 bool AreArcAllOptInPreferencesManaged() const; | 246 bool AreArcAllOptInPreferencesManaged() const; |
236 | 247 |
237 void SetState(State state); | 248 void SetState(State state); |
238 void ShutdownSession(); | 249 void ShutdownSession(); |
239 void OnAndroidManagementPassed(); | 250 void OnAndroidManagementPassed(); |
240 void OnArcDataRemoved(bool success); | 251 void OnArcDataRemoved(bool success); |
241 void OnArcSignInTimeout(); | 252 void OnArcSignInTimeout(); |
242 | 253 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); | 314 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); |
304 }; | 315 }; |
305 | 316 |
306 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 317 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
307 std::ostream& operator<<(std::ostream& os, | 318 std::ostream& operator<<(std::ostream& os, |
308 const ArcSessionManager::State& state); | 319 const ArcSessionManager::State& state); |
309 | 320 |
310 } // namespace arc | 321 } // namespace arc |
311 | 322 |
312 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ | 323 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ |
OLD | NEW |