1 // Copyright (c) 2013 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_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/services/gcm/push_messaging_service_impl.h"
14 #include "components/keyed_service/core/keyed_service.h"
18 namespace user_prefs
{
19 class PrefRegistrySyncable
;
24 class GCMClientFactory
;
27 #if defined(OS_CHROMEOS)
28 class GCMConnectionObserver
;
31 // Providing GCM service, via GCMDriver, to a profile.
32 class GCMProfileService
: public KeyedService
{
34 // Returns whether GCM is enabled for |profile|.
35 static bool IsGCMEnabled(Profile
* profile
);
37 // Register profile-specific prefs for GCM.
38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
40 #if defined(OS_ANDROID)
41 explicit GCMProfileService(Profile
* profile
);
43 GCMProfileService(Profile
* profile
,
44 scoped_ptr
<GCMClientFactory
> gcm_client_factory
);
46 ~GCMProfileService() override
;
49 void Shutdown() override
;
51 // For testing purpose.
52 void SetDriverForTesting(GCMDriver
* driver
);
54 GCMDriver
* driver() const { return driver_
.get(); }
56 content::PushMessagingService
* push_messaging_service() {
57 return &push_messaging_service_
;
61 // Used for constructing fake GCMProfileService for testing purpose.
65 // The profile which owns this object.
68 scoped_ptr
<GCMDriver
> driver_
;
70 // Implementation of content::PushMessagingService using GCMProfileService.
71 PushMessagingServiceImpl push_messaging_service_
;
73 // Used for both account tracker and GCM.UserSignedIn UMA.
74 #if !defined(OS_ANDROID)
75 class IdentityObserver
;
76 scoped_ptr
<IdentityObserver
> identity_observer_
;
79 DISALLOW_COPY_AND_ASSIGN(GCMProfileService
);
84 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_