Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_TETHER_TETHER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chromeos/dbus/power_manager_client.h" | 13 #include "chromeos/dbus/power_manager_client.h" |
| 14 #include "chromeos/dbus/session_manager_client.h" | 14 #include "chromeos/dbus/session_manager_client.h" |
| 15 #include "chromeos/network/network_state_handler.h" | 15 #include "chromeos/network/network_state_handler.h" |
| 16 #include "chromeos/network/network_state_handler_observer.h" | 16 #include "chromeos/network/network_state_handler_observer.h" |
| 17 #include "components/cryptauth/cryptauth_device_manager.h" | 17 #include "components/cryptauth/cryptauth_device_manager.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "components/prefs/pref_change_registrar.h" | 19 #include "components/prefs/pref_change_registrar.h" |
| 20 #include "device/bluetooth/bluetooth_adapter.h" | 20 #include "device/bluetooth/bluetooth_adapter.h" |
| 21 | 21 |
| 22 namespace chromeos { | |
| 23 class NetworkStateHandler; | |
| 24 class ManagedNetworkConfigurationHandler; | |
| 25 class NetworkConnect; | |
| 26 class NetworkConnectionHandler; | |
| 27 namespace tether { | |
| 28 class NotificationPresenter; | |
| 29 } // namespace tether | |
| 30 } // namespace chromeos | |
| 31 | |
| 22 namespace cryptauth { | 32 namespace cryptauth { |
| 23 class CryptAuthService; | 33 class CryptAuthService; |
| 24 } // cryptauth | 34 } // namespace cryptauth |
| 25 | 35 |
| 26 class PrefRegistrySimple; | 36 class PrefRegistrySimple; |
| 27 class Profile; | 37 class Profile; |
| 38 class ProfileOAuth2TokenService; | |
| 28 | 39 |
| 29 class TetherService : public KeyedService, | 40 class TetherService : public KeyedService, |
| 30 public chromeos::PowerManagerClient::Observer, | 41 public chromeos::PowerManagerClient::Observer, |
| 31 public chromeos::SessionManagerClient::Observer, | 42 public chromeos::SessionManagerClient::Observer, |
| 32 public cryptauth::CryptAuthDeviceManager::Observer, | 43 public cryptauth::CryptAuthDeviceManager::Observer, |
| 33 public device::BluetoothAdapter::Observer, | 44 public device::BluetoothAdapter::Observer, |
| 34 public chromeos::NetworkStateHandlerObserver { | 45 public chromeos::NetworkStateHandlerObserver { |
| 35 public: | 46 public: |
| 36 TetherService(Profile* profile, | 47 TetherService(Profile* profile, |
| 37 chromeos::PowerManagerClient* power_manager_client, | 48 chromeos::PowerManagerClient* power_manager_client, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 50 static bool IsFeatureFlagEnabled(); | 61 static bool IsFeatureFlagEnabled(); |
| 51 | 62 |
| 52 // Attempt to start the Tether module. Only succeeds if all conditions to | 63 // Attempt to start the Tether module. Only succeeds if all conditions to |
| 53 // reach chromeos::NetworkStateHandler::TechnologyState::ENABLED are reached. | 64 // reach chromeos::NetworkStateHandler::TechnologyState::ENABLED are reached. |
| 54 // Should only be called once a user is logged in. | 65 // Should only be called once a user is logged in. |
| 55 virtual void StartTetherIfEnabled(); | 66 virtual void StartTetherIfEnabled(); |
| 56 | 67 |
| 57 // Stop the Tether module. | 68 // Stop the Tether module. |
| 58 virtual void StopTether(); | 69 virtual void StopTether(); |
| 59 | 70 |
| 71 class InitializerDelegate { | |
|
Ryan Hansberry
2017/06/28 17:02:40
Please add a comment that this is a necessary inst
Kyle Horimoto
2017/06/28 21:57:48
Done.
| |
| 72 public: | |
| 73 virtual void InitializeTether( | |
| 74 cryptauth::CryptAuthService* cryptauth_service, | |
| 75 std::unique_ptr<chromeos::tether::NotificationPresenter> | |
| 76 notification_presenter, | |
| 77 PrefService* pref_service, | |
| 78 ProfileOAuth2TokenService* token_service, | |
| 79 chromeos::NetworkStateHandler* network_state_handler, | |
| 80 chromeos::ManagedNetworkConfigurationHandler* | |
| 81 managed_network_configuration_handler, | |
| 82 chromeos::NetworkConnect* network_connect, | |
| 83 chromeos::NetworkConnectionHandler* network_connection_handler); | |
| 84 virtual void ShutdownTether(); | |
| 85 }; | |
| 86 | |
| 60 protected: | 87 protected: |
| 61 // KeyedService: | 88 // KeyedService: |
| 62 void Shutdown() override; | 89 void Shutdown() override; |
| 63 | 90 |
| 64 // chromeos::PowerManagerClient::Observer: | 91 // chromeos::PowerManagerClient::Observer: |
| 65 void SuspendImminent() override; | 92 void SuspendImminent() override; |
| 66 void SuspendDone(const base::TimeDelta& sleep_duration) override; | 93 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 67 | 94 |
| 68 // chromeos::SessionManagerClient::Observer: | 95 // chromeos::SessionManagerClient::Observer: |
| 69 void ScreenIsLocked() override; | 96 void ScreenIsLocked() override; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 bool IsCellularAvailableButNotEnabled() const; | 133 bool IsCellularAvailableButNotEnabled() const; |
| 107 | 134 |
| 108 // Whether Tether is allowed to be used. If the controlling preference | 135 // Whether Tether is allowed to be used. If the controlling preference |
| 109 // is set (from policy), this returns the preference value. Otherwise, it is | 136 // is set (from policy), this returns the preference value. Otherwise, it is |
| 110 // permitted if the flag is enabled. | 137 // permitted if the flag is enabled. |
| 111 bool IsAllowedByPolicy() const; | 138 bool IsAllowedByPolicy() const; |
| 112 | 139 |
| 113 // Whether Tether is enabled. | 140 // Whether Tether is enabled. |
| 114 bool IsEnabledbyPreference() const; | 141 bool IsEnabledbyPreference() const; |
| 115 | 142 |
| 143 void SetInitializerDelegateForTest( | |
| 144 std::unique_ptr<InitializerDelegate> initializer_delegate); | |
| 145 | |
| 116 // Whether the service has been shut down. | 146 // Whether the service has been shut down. |
| 117 bool shut_down_ = false; | 147 bool shut_down_ = false; |
| 118 | 148 |
| 119 // Whether the device and service have been suspended (e.g. the laptop lid | 149 // Whether the device and service have been suspended (e.g. the laptop lid |
| 120 // was closed). | 150 // was closed). |
| 121 bool suspended_ = false; | 151 bool suspended_ = false; |
| 122 | 152 |
| 123 Profile* profile_; | 153 Profile* profile_; |
| 124 chromeos::PowerManagerClient* power_manager_client_; | 154 chromeos::PowerManagerClient* power_manager_client_; |
| 125 chromeos::SessionManagerClient* session_manager_client_; | 155 chromeos::SessionManagerClient* session_manager_client_; |
| 126 cryptauth::CryptAuthService* cryptauth_service_; | 156 cryptauth::CryptAuthService* cryptauth_service_; |
| 127 chromeos::NetworkStateHandler* network_state_handler_; | 157 chromeos::NetworkStateHandler* network_state_handler_; |
| 158 std::unique_ptr<InitializerDelegate> initializer_delegate_; | |
| 128 | 159 |
| 129 PrefChangeRegistrar registrar_; | 160 PrefChangeRegistrar registrar_; |
| 130 scoped_refptr<device::BluetoothAdapter> adapter_; | 161 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 131 | 162 |
| 132 base::WeakPtrFactory<TetherService> weak_ptr_factory_; | 163 base::WeakPtrFactory<TetherService> weak_ptr_factory_; |
| 133 | 164 |
| 134 DISALLOW_COPY_AND_ASSIGN(TetherService); | 165 DISALLOW_COPY_AND_ASSIGN(TetherService); |
| 135 }; | 166 }; |
| 136 | 167 |
| 137 #endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ | 168 #endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ |
| OLD | NEW |