OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | 5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ |
6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | 6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 13 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
11 | 14 |
12 namespace content { | 15 namespace content { |
13 class BrowserContext; | 16 class BrowserContext; |
14 } | 17 } |
15 | 18 |
16 namespace wifi_sync { | 19 namespace wifi_sync { |
17 | 20 |
| 21 class WifiConfigDelegate; |
18 class WifiCredentialSyncableService; | 22 class WifiCredentialSyncableService; |
19 | 23 |
20 // Singleton that owns all WifiCredentialSyncableServices and | 24 // Singleton that owns all WifiCredentialSyncableServices and |
21 // associates them with Profiles. Listens for the Profile's | 25 // associates them with Profiles. Listens for the Profile's |
22 // destruction notification and cleans up the associated | 26 // destruction notification and cleans up the associated |
23 // WifiCredentialSyncableServices. | 27 // WifiCredentialSyncableServices. |
24 class WifiCredentialSyncableServiceFactory | 28 class WifiCredentialSyncableServiceFactory |
25 : public BrowserContextKeyedServiceFactory { | 29 : public BrowserContextKeyedServiceFactory { |
26 public: | 30 public: |
27 // Returns the SyncableService for |browser_context|, creating the | 31 // Returns the SyncableService for |browser_context|, creating the |
28 // SyncableService if one does not already exist. | 32 // SyncableService if one does not already exist. |
29 static WifiCredentialSyncableService* GetForBrowserContext( | 33 static WifiCredentialSyncableService* GetForBrowserContext( |
30 content::BrowserContext* browser_context); | 34 content::BrowserContext* browser_context); |
31 | 35 |
32 // Returns the singleton instance. As this class has no public | 36 // Returns the singleton instance. |
33 // instance methods, this function is not generally useful for | |
34 // external callers. This function is public only so that the | |
35 // Singleton template can reference it. | |
36 static WifiCredentialSyncableServiceFactory* GetInstance(); | 37 static WifiCredentialSyncableServiceFactory* GetInstance(); |
37 | 38 |
| 39 #if defined(OS_CHROMEOS) |
| 40 // Configures the factory to ignore chromeos::LoginState when |
| 41 // associating a new SyncableService with a Shill profile. Intended |
| 42 // for use in sync integration tests, where it is not possible to |
| 43 // control LoginState at the time SyncableServices are constructed. |
| 44 void IgnoreLoginStateForTest(); |
| 45 #endif |
| 46 |
38 private: | 47 private: |
39 friend struct DefaultSingletonTraits<WifiCredentialSyncableServiceFactory>; | 48 friend struct DefaultSingletonTraits<WifiCredentialSyncableServiceFactory>; |
40 | 49 |
41 WifiCredentialSyncableServiceFactory(); | 50 WifiCredentialSyncableServiceFactory(); |
42 ~WifiCredentialSyncableServiceFactory() override; | 51 ~WifiCredentialSyncableServiceFactory() override; |
43 | 52 |
44 // BrowserContextKeyedServiceFactory implementation. | 53 // BrowserContextKeyedServiceFactory implementation. |
45 KeyedService* BuildServiceInstanceFor( | 54 KeyedService* BuildServiceInstanceFor( |
46 content::BrowserContext* context) const override; | 55 content::BrowserContext* context) const override; |
47 | 56 |
| 57 // Returns a scoped pointer to a WifiConfigDelegate, which can be |
| 58 // used to configure the platform-specific Wi-Fi settings associated |
| 59 // with |context|. |
| 60 scoped_ptr<WifiConfigDelegate> BuildWifiConfigDelegate( |
| 61 content::BrowserContext* context) const; |
| 62 // ChromeOS-specific code used by BuildWifiConfigDelegate. |
| 63 scoped_ptr<WifiConfigDelegate> BuildWifiConfigDelegateChromeOs( |
| 64 content::BrowserContext* context) const; |
| 65 // Returns the name of the Shill profile associated with |context|. |
| 66 std::string GetShillProfile(content::BrowserContext* context) const; |
| 67 |
| 68 bool use_login_state_chrome_os_; |
| 69 |
48 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableServiceFactory); | 70 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableServiceFactory); |
49 }; | 71 }; |
50 | 72 |
51 } // namespace wifi_sync | 73 } // namespace wifi_sync |
52 | 74 |
53 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | 75 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ |
OLD | NEW |