wifi_sync: allow WifiCredentialSyncableServiceFactory to ignore LoginState
[chromium-blink-merge.git] / components / wifi_sync / wifi_credential_syncable_service_factory.h
blobbe5b6c506a21fe68cd47f44c6e88857e66f04d2e
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"
13 namespace content {
14 class BrowserContext;
17 namespace wifi_sync {
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 {
28 public:
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;
41 #endif
43 private:
44 friend struct DefaultSingletonTraits<WifiCredentialSyncableServiceFactory>;
46 WifiCredentialSyncableServiceFactory();
47 ~WifiCredentialSyncableServiceFactory() override;
49 // BrowserContextKeyedServiceFactory implementation.
50 KeyedService* BuildServiceInstanceFor(
51 content::BrowserContext* context) const override;
53 #if defined(OS_CHROMEOS)
54 // Returns a scoped pointer to a WifiConfigDelegate, which can be
55 // used to configure the ChromeOS Wi-Fi settings associated with
56 // |context|.
57 scoped_ptr<WifiConfigDelegate> BuildWifiConfigDelegateChromeOs(
58 content::BrowserContext* context) const;
59 #endif
61 #if defined(OS_CHROMEOS)
62 // Whether or not we should use LoginState to associate a new
63 // SyncableService with a Shill profile. Should be set to true in
64 // sync integration tests, where it is not possible to control
65 // LoginState at the time SyncableServices are constructed.
66 bool ignore_login_state_for_test_ = false;
67 #endif
69 DISALLOW_COPY_AND_ASSIGN(WifiCredentialSyncableServiceFactory);
72 } // namespace wifi_sync
74 #endif // COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_FACTORY_H_