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 #include "chrome/browser/chromeos/tether/tether_service_factory.h" | 5 #include "chrome/browser/chromeos/tether/tether_service_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | |
7 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/strings/string_number_conversions.h" | |
10 #include "chrome/browser/chromeos/tether/fake_tether_service.h" | |
8 #include "chrome/browser/cryptauth/chrome_cryptauth_service_factory.h" | 11 #include "chrome/browser/cryptauth/chrome_cryptauth_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "chromeos/chromeos_switches.h" | |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "chromeos/network/network_handler.h" | 16 #include "chromeos/network/network_handler.h" |
13 #include "chromeos/network/network_state_handler.h" | 17 #include "chromeos/network/network_state_handler.h" |
14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
15 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
16 | 20 |
17 // static | 21 // static |
18 TetherServiceFactory* TetherServiceFactory::GetInstance() { | 22 TetherServiceFactory* TetherServiceFactory::GetInstance() { |
19 return base::Singleton<TetherServiceFactory>::get(); | 23 return base::Singleton<TetherServiceFactory>::get(); |
20 } | 24 } |
(...skipping 12 matching lines...) Expand all Loading... | |
33 BrowserContextDependencyManager::GetInstance()) { | 37 BrowserContextDependencyManager::GetInstance()) { |
34 DependsOn(ChromeCryptAuthServiceFactory::GetInstance()); | 38 DependsOn(ChromeCryptAuthServiceFactory::GetInstance()); |
35 } | 39 } |
36 | 40 |
37 TetherServiceFactory::~TetherServiceFactory() {} | 41 TetherServiceFactory::~TetherServiceFactory() {} |
38 | 42 |
39 KeyedService* TetherServiceFactory::BuildServiceInstanceFor( | 43 KeyedService* TetherServiceFactory::BuildServiceInstanceFor( |
40 content::BrowserContext* context) const { | 44 content::BrowserContext* context) const { |
41 DCHECK(chromeos::NetworkHandler::IsInitialized()); | 45 DCHECK(chromeos::NetworkHandler::IsInitialized()); |
42 | 46 |
43 return new TetherService( | 47 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
44 Profile::FromBrowserContext(context), | 48 if (command_line->HasSwitch(chromeos::switches::kTetherStub)) { |
45 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(), | 49 int num_tether_networks = 0; |
46 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 50 base::StringToInt( |
47 ChromeCryptAuthServiceFactory::GetForBrowserContext( | 51 command_line->GetSwitchValueASCII(chromeos::switches::kTetherStub), |
48 Profile::FromBrowserContext(context)), | 52 &num_tether_networks); |
49 chromeos::NetworkHandler::Get()->network_state_handler()); | 53 |
54 return new FakeTetherService( | |
55 num_tether_networks, Profile::FromBrowserContext(context), | |
56 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(), | |
57 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | |
58 ChromeCryptAuthServiceFactory::GetForBrowserContext( | |
59 Profile::FromBrowserContext(context)), | |
60 chromeos::NetworkHandler::Get()->network_state_handler()); | |
61 } else { | |
stevenjb
2017/05/23 22:24:33
no else
Ryan Hansberry
2017/05/23 22:53:12
Done.
| |
62 return new TetherService( | |
63 Profile::FromBrowserContext(context), | |
64 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(), | |
65 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | |
66 ChromeCryptAuthServiceFactory::GetForBrowserContext( | |
67 Profile::FromBrowserContext(context)), | |
68 chromeos::NetworkHandler::Get()->network_state_handler()); | |
69 } | |
50 } | 70 } |
51 | 71 |
52 void TetherServiceFactory::RegisterProfilePrefs( | 72 void TetherServiceFactory::RegisterProfilePrefs( |
53 user_prefs::PrefRegistrySyncable* registry) { | 73 user_prefs::PrefRegistrySyncable* registry) { |
54 TetherService::RegisterProfilePrefs(registry); | 74 TetherService::RegisterProfilePrefs(registry); |
55 } | 75 } |
OLD | NEW |