| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | |
| 6 #define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | |
| 14 | |
| 15 namespace content { | |
| 16 class BrowserContext; | |
| 17 } | |
| 18 | |
| 19 namespace wifi_sync { | |
| 20 | |
| 21 class WifiConfigDelegate; | |
| 22 class WifiCredentialSyncableService; | |
| 23 | |
| 24 // Singleton that owns all WifiCredentialSyncableServices and | |
| 25 // associates them with Profiles. Listens for the Profile's | |
| 26 // destruction notification and cleans up the associated | |
| 27 // WifiCredentialSyncableServices. | |
| 28 class WifiCredentialSyncableServiceFactory | |
| 29 : public BrowserContextKeyedServiceFactory { | |
| 30 public: | |
| 31 // Returns the SyncableService for |browser_context|, creating the | |
| 32 // SyncableService if one does not already exist. | |
| 33 static WifiCredentialSyncableService* GetForBrowserContext( | |
| 34 content::BrowserContext* browser_context); | |
| 35 | |
| 36 // Returns the singleton instance. | |
| 37 static WifiCredentialSyncableServiceFactory* GetInstance(); | |
| 38 | |
| 39 #if defined(OS_CHROMEOS) | |
| 40 void set_ignore_login_state_for_test(bool new_value) { | |
| 41 ignore_login_state_for_test_ = new_value; | |
| 42 } | |
| 43 #endif | |
| 44 | |
| 45 private: | |
| 46 friend struct base::DefaultSingletonTraits< | |
| 47 WifiCredentialSyncableServiceFactory>; | |
| 48 | |
| 49 WifiCredentialSyncableServiceFactory(); | |
| 50 ~WifiCredentialSyncableServiceFactory() override; | |
| 51 | |
| 52 // BrowserContextKeyedServiceFactory implementation. | |
| 53 KeyedService* BuildServiceInstanceFor( | |
| 54 content::BrowserContext* context) const override; | |
| 55 | |
| 56 #if defined(OS_CHROMEOS) | |
| 57 // Returns a scoped pointer to a WifiConfigDelegate, which can be | |
| 58 // used to configure the ChromeOS Wi-Fi settings associated with | |
| 59 // |context|. | |
| 60 std::unique_ptr<WifiConfigDelegate> BuildWifiConfigDelegateChromeOs( | |
| 61 content::BrowserContext* context) const; | |
| 62 #endif | |
| 63 | |
| 64 #if defined(OS_CHROMEOS) | |
| 65 // Whether or not we should use LoginState to associate a new | |
| 66 // SyncableService with a Shill profile. Should be set to true in | |
| 67 // sync integration tests, where it is not possible to control | |
| 68 // LoginState at the time SyncableServices are constructed. | |
| 69 bool ignore_login_state_for_test_ = false; | |
| 70 #endif | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableServiceFactory); | |
| 73 }; | |
| 74 | |
| 75 } // namespace wifi_sync | |
| 76 | |
| 77 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_ | |
| OLD | NEW |