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 #if defined(OS_CHROMEOS) | |
58 // Returns a scoped pointer to a WifiConfigDelegate, which can be | |
59 // used to configure the ChromeOS Wi-Fi settings associated with | |
60 // |context|. | |
61 scoped_ptr<WifiConfigDelegate> BuildWifiConfigDelegateChromeOs( | |
62 content::BrowserContext* context) const; | |
63 // Returns the ChromeOS user-ID hash for |context|. | |
64 std::string GetUserHash(content::BrowserContext* context) const; | |
stevenjb
2015/01/28 21:12:20
This could be file local if you pass it the 'use l
mukesh agrawal
2015/01/28 22:26:27
Done.
| |
65 #endif | |
66 | |
67 // Whether or not we should use LoginState to determine the user-ID | |
68 // hash on ChromeOS. | |
69 bool use_login_state_chrome_os_; | |
stevenjb
2015/01/28 21:12:20
This should also be #if OS_CHROMEOS. Also, slight
mukesh agrawal
2015/01/28 22:26:27
Done.
| |
70 | |
48 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableServiceFactory); | 71 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableServiceFactory); |
49 }; | 72 }; |
50 | 73 |
51 } // namespace wifi_sync | 74 } // namespace wifi_sync |
52 | 75 |
53 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | 76 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ |
OLD | NEW |