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