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

Side by Side Diff: chrome/browser/chromeos/tether/tether_service.h

Issue 2900903002: Create a FakeTetherService, which stubs out TetherService for development. (Closed)
Patch Set: Fix TetherService tests. Created 3 years, 6 months 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 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/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "chromeos/dbus/power_manager_client.h" 13 #include "chromeos/dbus/power_manager_client.h"
13 #include "chromeos/dbus/session_manager_client.h" 14 #include "chromeos/dbus/session_manager_client.h"
14 #include "chromeos/network/network_state_handler.h" 15 #include "chromeos/network/network_state_handler.h"
15 #include "chromeos/network/network_state_handler_observer.h" 16 #include "chromeos/network/network_state_handler_observer.h"
16 #include "components/cryptauth/cryptauth_device_manager.h" 17 #include "components/cryptauth/cryptauth_device_manager.h"
17 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
18 #include "components/prefs/pref_change_registrar.h" 19 #include "components/prefs/pref_change_registrar.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
(...skipping 17 matching lines...) Expand all
37 chromeos::SessionManagerClient* session_manager_client, 38 chromeos::SessionManagerClient* session_manager_client,
38 cryptauth::CryptAuthService* cryptauth_service, 39 cryptauth::CryptAuthService* cryptauth_service,
39 chromeos::NetworkStateHandler* network_state_handler); 40 chromeos::NetworkStateHandler* network_state_handler);
40 ~TetherService() override; 41 ~TetherService() override;
41 42
42 // Gets TetherService instance. 43 // Gets TetherService instance.
43 static TetherService* Get(Profile* profile); 44 static TetherService* Get(Profile* profile);
44 45
45 static void RegisterProfilePrefs(PrefRegistrySimple* registry); 46 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
46 47
48 // Whether the Tether feature has been enabled via a chrome://about or
49 // command line flag.
50 static bool IsFeatureFlagEnabled();
51
47 // Attempt to start the Tether module. Only succeeds if all conditions to 52 // Attempt to start the Tether module. Only succeeds if all conditions to
48 // reach chromeos::NetworkStateHandler::TechnologyState::ENABLED are reached. 53 // reach chromeos::NetworkStateHandler::TechnologyState::ENABLED are reached.
49 // Should only be called once a user is logged in. 54 // Should only be called once a user is logged in.
50 void StartTetherIfEnabled(); 55 virtual void StartTetherIfEnabled();
51 56
52 // Stop the Tether module. 57 // Stop the Tether module.
53 void StopTether(); 58 virtual void StopTether();
54 59
55 protected: 60 protected:
56 // KeyedService: 61 // KeyedService:
57 void Shutdown() override; 62 void Shutdown() override;
58 63
59 // chromeos::PowerManagerClient::Observer: 64 // chromeos::PowerManagerClient::Observer:
60 void SuspendImminent() override; 65 void SuspendImminent() override;
61 void SuspendDone(const base::TimeDelta& sleep_duration) override; 66 void SuspendDone(const base::TimeDelta& sleep_duration) override;
62 67
63 // chromeos::SessionManagerClient::Observer: 68 // chromeos::SessionManagerClient::Observer:
64 void ScreenIsLocked() override; 69 void ScreenIsLocked() override;
65 void ScreenIsUnlocked() override; 70 void ScreenIsUnlocked() override;
66 71
67 // cryptauth::CryptAuthDeviceManager::Observer 72 // cryptauth::CryptAuthDeviceManager::Observer
68 void OnSyncFinished(cryptauth::CryptAuthDeviceManager::SyncResult sync_result, 73 void OnSyncFinished(cryptauth::CryptAuthDeviceManager::SyncResult sync_result,
69 cryptauth::CryptAuthDeviceManager::DeviceChangeResult 74 cryptauth::CryptAuthDeviceManager::DeviceChangeResult
70 device_change_result) override; 75 device_change_result) override;
71 76
72 // device::BluetoothAdapter::Observer: 77 // device::BluetoothAdapter::Observer:
73 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, 78 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
74 bool powered) override; 79 bool powered) override;
75 80
76 // chromeos::NetworkStateHandlerObserver: 81 // chromeos::NetworkStateHandlerObserver:
77 void DeviceListChanged() override; 82 void DeviceListChanged() override;
78 83
79 // Callback when the controlling pref changes. 84 // Callback when the controlling pref changes.
80 void OnPrefsChanged(); 85 void OnPrefsChanged();
81 86
87 // Whether Tether hosts are available.
88 virtual bool HasSyncedTetherHosts() const;
89
82 virtual void UpdateTetherTechnologyState(); 90 virtual void UpdateTetherTechnologyState();
91 chromeos::NetworkStateHandler::TechnologyState GetTetherTechnologyState();
92
93 chromeos::NetworkStateHandler* network_state_handler() {
94 return network_state_handler_;
95 }
83 96
84 private: 97 private:
85 friend class TetherServiceTest; 98 friend class TetherServiceTest;
86 99 FRIEND_TEST_ALL_PREFIXES(TetherServiceTest, TestFeatureFlagEnabled);
87 chromeos::NetworkStateHandler::TechnologyState GetTetherTechnologyState();
88 100
89 void OnBluetoothAdapterFetched( 101 void OnBluetoothAdapterFetched(
90 scoped_refptr<device::BluetoothAdapter> adapter); 102 scoped_refptr<device::BluetoothAdapter> adapter);
91 103
92 bool IsBluetoothAvailable() const; 104 bool IsBluetoothAvailable() const;
93 105
94 // Whether Tether hosts are available.
95 bool HasSyncedTetherHosts() const;
96
97 // Whether the Tether feature has been enabled via an about or command line
98 // flag.
99 bool IsFeatureFlagEnabled() const;
100
101 // Whether Tether is allowed to be used. If the controlling preference 106 // Whether Tether is allowed to be used. If the controlling preference
102 // is set (from policy), this returns the preference value. Otherwise, it is 107 // is set (from policy), this returns the preference value. Otherwise, it is
103 // permitted if the flag is enabled. 108 // permitted if the flag is enabled.
104 bool IsAllowedByPolicy() const; 109 bool IsAllowedByPolicy() const;
105 110
106 // Whether Tether is enabled. 111 // Whether Tether is enabled.
107 bool IsEnabledbyPreference() const; 112 bool IsEnabledbyPreference() const;
108 113
109 // Whether the service has been shut down. 114 // Whether the service has been shut down.
110 bool shut_down_ = false; 115 bool shut_down_ = false;
(...skipping 10 matching lines...) Expand all
121 126
122 PrefChangeRegistrar registrar_; 127 PrefChangeRegistrar registrar_;
123 scoped_refptr<device::BluetoothAdapter> adapter_; 128 scoped_refptr<device::BluetoothAdapter> adapter_;
124 129
125 base::WeakPtrFactory<TetherService> weak_ptr_factory_; 130 base::WeakPtrFactory<TetherService> weak_ptr_factory_;
126 131
127 DISALLOW_COPY_AND_ASSIGN(TetherService); 132 DISALLOW_COPY_AND_ASSIGN(TetherService);
128 }; 133 };
129 134
130 #endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ 135 #endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/tether/fake_tether_service.cc ('k') | chrome/browser/chromeos/tether/tether_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698