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/gcm_service.h"
14 #include "components/keyed_service/core/keyed_service.h"
18 namespace user_prefs {
19 class PrefRegistrySyncable;
24 // A specialization of GCMService that is tied to a Profile.
25 class GCMProfileService : public GCMService, public KeyedService {
27 // Any change made to this enum should have corresponding change in the
28 // GetGCMEnabledStateString(...) function.
29 enum GCMEnabledState {
30 // GCM is always enabled. GCMClient will always load and connect with GCM.
32 // GCM is only enabled for apps. GCMClient will start to load and connect
33 // with GCM only when GCM API is used.
35 // GCM is always disabled. GCMClient will never load and connect with GCM.
39 // Returns the GCM enabled state.
40 static GCMEnabledState GetGCMEnabledState(Profile* profile);
42 // Returns text representation of a GCMEnabledState enum entry.
43 static std::string GetGCMEnabledStateString(GCMEnabledState state);
45 // Register profile-specific prefs for GCM.
46 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
48 explicit GCMProfileService(Profile* profile);
49 virtual ~GCMProfileService();
52 virtual void Shutdown() OVERRIDE;
54 // Returns the user name if the profile is signed in.
55 std::string SignedInUserName() const;
58 // Overridden from GCMService:
59 virtual bool ShouldStartAutomatically() const OVERRIDE;
60 virtual base::FilePath GetStorePath() const OVERRIDE;
61 virtual scoped_refptr<net::URLRequestContextGetter>
62 GetURLRequestContextGetter() const OVERRIDE;
65 // The profile which owns this object.
68 DISALLOW_COPY_AND_ASSIGN(GCMProfileService);
73 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_