| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // In the first boot case: | 70 // In the first boot case: |
| 71 // STOPPED -> SHOWING_TERMS_OF_SERVICE: when arc.enabled preference is set. | 71 // STOPPED -> SHOWING_TERMS_OF_SERVICE: when arc.enabled preference is set. |
| 72 // SHOWING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user | 72 // SHOWING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user |
| 73 // agree with "Terms Of Service" | 73 // agree with "Terms Of Service" |
| 74 // CHECKING_ANDROID_MANAGEMENT -> ACTIVE: when the auth token is | 74 // CHECKING_ANDROID_MANAGEMENT -> ACTIVE: when the auth token is |
| 75 // successfully fetched. | 75 // successfully fetched. |
| 76 // | 76 // |
| 77 // In the second (or later) boot case: | 77 // In the second (or later) boot case: |
| 78 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is | 78 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is |
| 79 // true. Practically, this is when the primary Profile gets ready. | 79 // true. Practically, this is when the primary Profile gets ready. |
| 80 // |
| 81 // TODO(hidehiko): Fix the state machine, and update the comment including |
| 82 // relationship with |enable_requested_|. |
| 80 enum class State { | 83 enum class State { |
| 81 NOT_INITIALIZED, | 84 NOT_INITIALIZED, |
| 82 STOPPED, | 85 STOPPED, |
| 83 SHOWING_TERMS_OF_SERVICE, | 86 SHOWING_TERMS_OF_SERVICE, |
| 84 CHECKING_ANDROID_MANAGEMENT, | 87 CHECKING_ANDROID_MANAGEMENT, |
| 85 REMOVING_DATA_DIR, | 88 REMOVING_DATA_DIR, |
| 86 ACTIVE, | 89 ACTIVE, |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 class Observer { | 92 class Observer { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 bool IsArcPlayStoreEnabled() const; | 166 bool IsArcPlayStoreEnabled() const; |
| 164 | 167 |
| 165 // Enables/disables Google Play Store on ARC. Currently, it is tied to | 168 // Enables/disables Google Play Store on ARC. Currently, it is tied to |
| 166 // ARC enabled state, too, so this also should trigger to enable/disable | 169 // ARC enabled state, too, so this also should trigger to enable/disable |
| 167 // whole ARC system. | 170 // whole ARC system. |
| 168 // TODO(hidehiko): De-couple the concept to enable ARC system and opt-in | 171 // TODO(hidehiko): De-couple the concept to enable ARC system and opt-in |
| 169 // to use Google Play Store. Note that there is a plan to use ARC without | 172 // to use Google Play Store. Note that there is a plan to use ARC without |
| 170 // Google Play Store, then ARC can run without opt-in. | 173 // Google Play Store, then ARC can run without opt-in. |
| 171 void SetArcPlayStoreEnabled(bool enable); | 174 void SetArcPlayStoreEnabled(bool enable); |
| 172 | 175 |
| 176 // Requests to enable ARC session. This starts ARC instance, or maybe starts |
| 177 // Terms Of Service negotiation if they haven't been accepted yet. |
| 178 // If it is already requested to enable, no-op. |
| 179 // Currently, enabled/disabled is tied to whether Google Play Store is |
| 180 // enabled or disabled. Please see also TODO of SetArcPlayStoreEnabled(). |
| 181 void RequestEnable(); |
| 182 |
| 183 // Requests to disable ARC session. This stops ARC instance, or quits Terms |
| 184 // Of Service negotiation if it is the middle of the process (e.g. closing |
| 185 // UI for manual negotiation if it is shown). |
| 186 // If it is already requested to disable, no-op. |
| 187 void RequestDisable(); |
| 188 |
| 173 // Called from the Chrome OS metrics provider to record Arc.State | 189 // Called from the Chrome OS metrics provider to record Arc.State |
| 174 // periodically. | 190 // periodically. |
| 175 void RecordArcState(); | 191 void RecordArcState(); |
| 176 | 192 |
| 177 // sync_preferences::PrefServiceSyncableObserver | 193 // sync_preferences::PrefServiceSyncableObserver |
| 178 void OnIsSyncingChanged() override; | 194 void OnIsSyncingChanged() override; |
| 179 | 195 |
| 180 // ArcSupportHost::Observer: | 196 // ArcSupportHost::Observer: |
| 181 void OnWindowClosed() override; | 197 void OnWindowClosed() override; |
| 182 void OnTermsAgreed(bool is_metrics_enabled, | 198 void OnTermsAgreed(bool is_metrics_enabled, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // Returns the time when ARC was about to start, or a null time if ARC has not | 231 // Returns the time when ARC was about to start, or a null time if ARC has not |
| 216 // been started yet. | 232 // been started yet. |
| 217 base::Time arc_start_time() const { return arc_start_time_; } | 233 base::Time arc_start_time() const { return arc_start_time_; } |
| 218 | 234 |
| 219 // Injectors for testing. | 235 // Injectors for testing. |
| 220 void SetArcSessionRunnerForTesting( | 236 void SetArcSessionRunnerForTesting( |
| 221 std::unique_ptr<ArcSessionRunner> arc_session_runner); | 237 std::unique_ptr<ArcSessionRunner> arc_session_runner); |
| 222 void SetAttemptUserExitCallbackForTesting(const base::Closure& callback); | 238 void SetAttemptUserExitCallbackForTesting(const base::Closure& callback); |
| 223 | 239 |
| 224 private: | 240 private: |
| 241 // RequestEnable() has a check in order not to trigger starting procedure |
| 242 // twice. This method can be called to bypass that check when restarting. |
| 243 void RequestEnableImpl(); |
| 244 |
| 225 // Negotiates the terms of service to user. | 245 // Negotiates the terms of service to user. |
| 226 void StartTermsOfServiceNegotiation(); | 246 void StartTermsOfServiceNegotiation(); |
| 227 void OnTermsOfServiceNegotiated(bool accepted); | 247 void OnTermsOfServiceNegotiated(bool accepted); |
| 228 | 248 |
| 229 void SetState(State state); | 249 void SetState(State state); |
| 230 void ShutdownSession(); | 250 void ShutdownSession(); |
| 231 void OnOptInPreferenceChanged(); | 251 void OnOptInPreferenceChanged(); |
| 232 void OnAndroidManagementPassed(); | 252 void OnAndroidManagementPassed(); |
| 233 void OnArcDataRemoved(bool success); | 253 void OnArcDataRemoved(bool success); |
| 234 void OnArcSignInTimeout(); | 254 void OnArcSignInTimeout(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 253 void OnSessionStopped(StopReason reason) override; | 273 void OnSessionStopped(StopReason reason) override; |
| 254 | 274 |
| 255 std::unique_ptr<ArcSessionRunner> arc_session_runner_; | 275 std::unique_ptr<ArcSessionRunner> arc_session_runner_; |
| 256 | 276 |
| 257 // Unowned pointer. Keeps current profile. | 277 // Unowned pointer. Keeps current profile. |
| 258 Profile* profile_ = nullptr; | 278 Profile* profile_ = nullptr; |
| 259 | 279 |
| 260 // Registrar used to monitor ARC enabled state. | 280 // Registrar used to monitor ARC enabled state. |
| 261 PrefChangeRegistrar pref_change_registrar_; | 281 PrefChangeRegistrar pref_change_registrar_; |
| 262 | 282 |
| 283 // Whether ArcSessionManager is requested to enable (starting to run ARC |
| 284 // instance) or not. |
| 285 bool enable_requested_ = false; |
| 286 |
| 287 // Internal state machine. See also State enum class. |
| 263 State state_ = State::NOT_INITIALIZED; | 288 State state_ = State::NOT_INITIALIZED; |
| 264 base::ObserverList<Observer> observer_list_; | 289 base::ObserverList<Observer> observer_list_; |
| 265 base::ObserverList<ArcSessionObserver> arc_session_observer_list_; | 290 base::ObserverList<ArcSessionObserver> arc_session_observer_list_; |
| 266 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 291 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| 267 bool reenable_arc_ = false; | 292 bool reenable_arc_ = false; |
| 268 bool provisioning_reported_ = false; | 293 bool provisioning_reported_ = false; |
| 269 base::OneShotTimer arc_sign_in_timer_; | 294 base::OneShotTimer arc_sign_in_timer_; |
| 270 | 295 |
| 271 std::unique_ptr<ArcSupportHost> support_host_; | 296 std::unique_ptr<ArcSupportHost> support_host_; |
| 272 | 297 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 287 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); | 312 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); |
| 288 }; | 313 }; |
| 289 | 314 |
| 290 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 315 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 291 std::ostream& operator<<(std::ostream& os, | 316 std::ostream& operator<<(std::ostream& os, |
| 292 const ArcSessionManager::State& state); | 317 const ArcSessionManager::State& state); |
| 293 | 318 |
| 294 } // namespace arc | 319 } // namespace arc |
| 295 | 320 |
| 296 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ | 321 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ |
| OLD | NEW |