Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / invalidation / profile_invalidation_provider_factory.h
blobf40532d3449e3e358ba593387bedd59ba86dcd9c
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 CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_
6 #define CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/singleton.h"
10 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
12 namespace policy {
13 class AffiliatedInvalidationServiceProviderImplTest;
16 namespace user_prefs {
17 class PrefRegistrySyncable;
20 namespace syncer {
21 class Invalidator;
24 class Profile;
26 namespace invalidation {
28 class ProfileInvalidationProvider;
30 // A BrowserContextKeyedServiceFactory to construct InvalidationServices wrapped
31 // in ProfileInvalidationProviders. The implementation of InvalidationService
32 // may be completely different on different platforms; this class should help to
33 // hide this complexity. It also exposes some factory methods that are useful
34 // for setting up tests that rely on invalidations.
35 class ProfileInvalidationProviderFactory
36 : public BrowserContextKeyedServiceFactory {
37 public:
38 // Returns the ProfileInvalidationProvider for the given |profile|, lazily
39 // creating one first if required. If |profile| does not support invalidation
40 // (Chrome OS login profile, Chrome OS guest), returns NULL instead.
41 static ProfileInvalidationProvider* GetForProfile(Profile* profile);
43 static ProfileInvalidationProviderFactory* GetInstance();
45 // Switches service creation to go through |testing_factory| for all browser
46 // contexts.
47 void RegisterTestingFactory(TestingFactoryFunction testing_factory);
49 private:
50 friend class ProfileInvalidationProviderFactoryTestBase;
51 friend class policy::AffiliatedInvalidationServiceProviderImplTest;
52 friend struct base::DefaultSingletonTraits<
53 ProfileInvalidationProviderFactory>;
55 ProfileInvalidationProviderFactory();
56 ~ProfileInvalidationProviderFactory() override;
58 // BrowserContextKeyedServiceFactory:
59 KeyedService* BuildServiceInstanceFor(
60 content::BrowserContext* context) const override;
61 void RegisterProfilePrefs(
62 user_prefs::PrefRegistrySyncable* registry) override;
64 TestingFactoryFunction testing_factory_;
66 DISALLOW_COPY_AND_ASSIGN(ProfileInvalidationProviderFactory);
69 } // namespace invalidation
71 #endif // CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_