Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 // relationship with |enable_requested_|. | 78 // relationship with |enable_requested_|. |
| 79 enum class State { | 79 enum class State { |
| 80 NOT_INITIALIZED, | 80 NOT_INITIALIZED, |
| 81 STOPPED, | 81 STOPPED, |
| 82 SHOWING_TERMS_OF_SERVICE, | 82 SHOWING_TERMS_OF_SERVICE, |
| 83 CHECKING_ANDROID_MANAGEMENT, | 83 CHECKING_ANDROID_MANAGEMENT, |
| 84 REMOVING_DATA_DIR, | 84 REMOVING_DATA_DIR, |
| 85 ACTIVE, | 85 ACTIVE, |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class Observer { | 88 class Observer { |
|
Yusuke Sato
2017/02/28 21:07:17
nit: Probably it's a good idea to have a short com
hidehiko
2017/03/01 09:10:04
Done.
| |
| 89 public: | 89 public: |
| 90 using StopReason = ArcSessionObserver::StopReason; | |
| 91 | |
| 90 virtual ~Observer() = default; | 92 virtual ~Observer() = default; |
|
Yusuke Sato
2017/02/28 21:07:16
nit: (while you're at it) isn't it better to make
hidehiko
2017/03/01 09:10:04
For that purpose, protected ctor looks more straig
hidehiko
2017/03/01 11:19:03
FYI: Found a recent discussion.
https://groups.goo
| |
| 91 | 93 |
| 92 // Called to notify that whether Google Play Store is enabled or not, which | 94 // Called to notify that whether Google Play Store is enabled or not, which |
| 93 // is represented by "arc.enabled" preference, is updated. | 95 // is represented by "arc.enabled" preference, is updated. |
| 94 virtual void OnArcPlayStoreEnabledChanged(bool enabled) {} | 96 virtual void OnArcPlayStoreEnabledChanged(bool enabled) {} |
| 95 | 97 |
| 96 // Called to notify that ARC has been initialized successfully. | 98 // Called to notify that ARC has been initialized successfully. |
| 97 virtual void OnArcInitialStart() {} | 99 virtual void OnArcInitialStart() {} |
| 98 | 100 |
| 101 // Called when ARC session is stopped, and is not being restarted | |
| 102 // automatically. | |
| 103 virtual void OnArcSessionStopped(StopReason stop_reason) {} | |
| 104 | |
| 99 // Called to notify that Android data has been removed. Used in | 105 // Called to notify that Android data has been removed. Used in |
| 100 // browser_tests | 106 // browser_tests |
| 101 virtual void OnArcDataRemoved() {} | 107 virtual void OnArcDataRemoved() {} |
| 102 }; | 108 }; |
| 103 | 109 |
| 104 explicit ArcSessionManager( | 110 explicit ArcSessionManager( |
| 105 std::unique_ptr<ArcSessionRunner> arc_session_runner); | 111 std::unique_ptr<ArcSessionRunner> arc_session_runner); |
| 106 ~ArcSessionManager() override; | 112 ~ArcSessionManager() override; |
| 107 | 113 |
| 108 static ArcSessionManager* Get(); | 114 static ArcSessionManager* Get(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 126 | 132 |
| 127 Profile* profile() { return profile_; } | 133 Profile* profile() { return profile_; } |
| 128 const Profile* profile() const { return profile_; } | 134 const Profile* profile() const { return profile_; } |
| 129 | 135 |
| 130 State state() const { return state_; } | 136 State state() const { return state_; } |
| 131 | 137 |
| 132 // Adds or removes observers. | 138 // Adds or removes observers. |
| 133 void AddObserver(Observer* observer); | 139 void AddObserver(Observer* observer); |
| 134 void RemoveObserver(Observer* observer); | 140 void RemoveObserver(Observer* observer); |
| 135 | 141 |
| 136 // Adds or removes ArcSessionObservers. | |
|
Yusuke Sato
2017/02/28 21:07:16
nice.
hidehiko
2017/03/01 09:10:04
:-)
| |
| 137 // TODO(hidehiko): The observer should be migrated into | |
| 138 // ArcSessionManager::Observer. | |
| 139 void AddSessionObserver(ArcSessionObserver* observer); | |
| 140 void RemoveSessionObserver(ArcSessionObserver* observer); | |
| 141 | |
| 142 // Returns true if ARC instance is running/stopped, respectively. | 142 // Returns true if ARC instance is running/stopped, respectively. |
| 143 // See ArcSessionRunner::IsRunning()/IsStopped() for details. | 143 // See ArcSessionRunner::IsRunning()/IsStopped() for details. |
| 144 bool IsSessionRunning() const; | 144 bool IsSessionRunning() const; |
| 145 bool IsSessionStopped() const; | 145 bool IsSessionStopped() const; |
| 146 | 146 |
| 147 // Called from ARC support platform app when user cancels signing. | 147 // Called from ARC support platform app when user cancels signing. |
| 148 void CancelAuthCode(); | 148 void CancelAuthCode(); |
| 149 | 149 |
| 150 // Requests to enable ARC session. This starts ARC instance, or maybe starts | 150 // Requests to enable ARC session. This starts ARC instance, or maybe starts |
| 151 // Terms Of Service negotiation if they haven't been accepted yet. | 151 // Terms Of Service negotiation if they haven't been accepted yet. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 // re-auth flow. | 245 // re-auth flow. |
| 246 void OnAndroidManagementChecked( | 246 void OnAndroidManagementChecked( |
| 247 policy::AndroidManagementClient::Result result); | 247 policy::AndroidManagementClient::Result result); |
| 248 | 248 |
| 249 // Called when the background Android management check is done. It is | 249 // Called when the background Android management check is done. It is |
| 250 // triggered when the second or later ARC boot timing. | 250 // triggered when the second or later ARC boot timing. |
| 251 void OnBackgroundAndroidManagementChecked( | 251 void OnBackgroundAndroidManagementChecked( |
| 252 policy::AndroidManagementClient::Result result); | 252 policy::AndroidManagementClient::Result result); |
| 253 | 253 |
| 254 // ArcSessionObserver: | 254 // ArcSessionObserver: |
| 255 void OnSessionReady() override; | 255 void OnSessionStopped(StopReason reason, bool restarting) override; |
| 256 void OnSessionStopped(StopReason reason) override; | |
| 257 | 256 |
| 258 std::unique_ptr<ArcSessionRunner> arc_session_runner_; | 257 std::unique_ptr<ArcSessionRunner> arc_session_runner_; |
| 259 | 258 |
| 260 // Unowned pointer. Keeps current profile. | 259 // Unowned pointer. Keeps current profile. |
| 261 Profile* profile_ = nullptr; | 260 Profile* profile_ = nullptr; |
| 262 | 261 |
| 263 // Registrar used to monitor ARC enabled state. | 262 // Registrar used to monitor ARC enabled state. |
| 264 PrefChangeRegistrar pref_change_registrar_; | 263 PrefChangeRegistrar pref_change_registrar_; |
| 265 | 264 |
| 266 // Whether ArcSessionManager is requested to enable (starting to run ARC | 265 // Whether ArcSessionManager is requested to enable (starting to run ARC |
| 267 // instance) or not. | 266 // instance) or not. |
| 268 bool enable_requested_ = false; | 267 bool enable_requested_ = false; |
| 269 | 268 |
| 270 // Internal state machine. See also State enum class. | 269 // Internal state machine. See also State enum class. |
| 271 State state_ = State::NOT_INITIALIZED; | 270 State state_ = State::NOT_INITIALIZED; |
| 272 base::ObserverList<Observer> observer_list_; | 271 base::ObserverList<Observer> observer_list_; |
| 273 base::ObserverList<ArcSessionObserver> arc_session_observer_list_; | |
| 274 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 272 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| 275 bool reenable_arc_ = false; | 273 bool reenable_arc_ = false; |
| 276 bool provisioning_reported_ = false; | 274 bool provisioning_reported_ = false; |
| 277 base::OneShotTimer arc_sign_in_timer_; | 275 base::OneShotTimer arc_sign_in_timer_; |
| 278 | 276 |
| 279 std::unique_ptr<ArcSupportHost> support_host_; | 277 std::unique_ptr<ArcSupportHost> support_host_; |
| 280 | 278 |
| 281 std::unique_ptr<ArcTermsOfServiceNegotiator> terms_of_service_negotiator_; | 279 std::unique_ptr<ArcTermsOfServiceNegotiator> terms_of_service_negotiator_; |
| 282 | 280 |
| 283 std::unique_ptr<ArcAuthContext> context_; | 281 std::unique_ptr<ArcAuthContext> context_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 295 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); | 293 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); |
| 296 }; | 294 }; |
| 297 | 295 |
| 298 // Outputs the stringified |state| to |os|. This is only for logging purposes. | 296 // Outputs the stringified |state| to |os|. This is only for logging purposes. |
| 299 std::ostream& operator<<(std::ostream& os, | 297 std::ostream& operator<<(std::ostream& os, |
| 300 const ArcSessionManager::State& state); | 298 const ArcSessionManager::State& state); |
| 301 | 299 |
| 302 } // namespace arc | 300 } // namespace arc |
| 303 | 301 |
| 304 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ | 302 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ |
| OLD | NEW |