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

Unified Diff: chrome/browser/chromeos/tether/tether_service.cc

Issue 2900903002: Create a FakeTetherService, which stubs out TetherService for development. (Closed)
Patch Set: Fix TetherService tests. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/tether/tether_service.cc
diff --git a/chrome/browser/chromeos/tether/tether_service.cc b/chrome/browser/chromeos/tether/tether_service.cc
index e0dd94fb4b1fd24d64c816e0c5b27eda2f492663..797e978e9493975084f819dd189998e74be0db0e 100644
--- a/chrome/browser/chromeos/tether/tether_service.cc
+++ b/chrome/browser/chromeos/tether/tether_service.cc
@@ -26,7 +26,10 @@
// static
TetherService* TetherService::Get(Profile* profile) {
- return TetherServiceFactory::GetForBrowserContext(profile);
+ if (IsFeatureFlagEnabled())
+ return TetherServiceFactory::GetForBrowserContext(profile);
+
+ return nullptr;
}
// static
@@ -36,6 +39,12 @@ void TetherService::RegisterProfilePrefs(PrefRegistrySimple* registry) {
chromeos::tether::Initializer::RegisterProfilePrefs(registry);
}
+// static
+bool TetherService::IsFeatureFlagEnabled() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableTether);
+}
+
TetherService::TetherService(
Profile* profile,
chromeos::PowerManagerClient* power_manager_client,
@@ -176,6 +185,12 @@ void TetherService::OnPrefsChanged() {
UpdateTetherTechnologyState();
}
+bool TetherService::HasSyncedTetherHosts() const {
+ return !cryptauth_service_->GetCryptAuthDeviceManager()
+ ->GetTetherHosts()
+ .empty();
+}
+
void TetherService::UpdateTetherTechnologyState() {
chromeos::NetworkStateHandler::TechnologyState tether_technology_state =
GetTetherTechnologyState();
@@ -193,7 +208,7 @@ void TetherService::UpdateTetherTechnologyState() {
chromeos::NetworkStateHandler::TechnologyState
TetherService::GetTetherTechnologyState() {
if (shut_down_ || suspended_ || session_manager_client_->IsScreenLocked() ||
- !IsFeatureFlagEnabled() || !HasSyncedTetherHosts()) {
+ !HasSyncedTetherHosts()) {
return chromeos::NetworkStateHandler::TechnologyState::
TECHNOLOGY_UNAVAILABLE;
} else if (!IsAllowedByPolicy()) {
@@ -220,17 +235,6 @@ void TetherService::OnBluetoothAdapterFetched(
UpdateTetherTechnologyState();
}
-bool TetherService::HasSyncedTetherHosts() const {
- return !cryptauth_service_->GetCryptAuthDeviceManager()
- ->GetTetherHosts()
- .empty();
-}
-
-bool TetherService::IsFeatureFlagEnabled() const {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableTether);
-}
-
bool TetherService::IsBluetoothAvailable() const {
return adapter_.get() && adapter_->IsPresent() && adapter_->IsPowered();
}
« no previous file with comments | « chrome/browser/chromeos/tether/tether_service.h ('k') | chrome/browser/chromeos/tether/tether_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698