Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / services / gcm / gcm_profile_service.h
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.
4
5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
7
8 #include <string>
9
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"
15
16 class Profile;
17
18 namespace user_prefs {
19 class PrefRegistrySyncable;
20 }
21
22 namespace gcm {
23
24 // A specialization of GCMService that is tied to a Profile.
25 class GCMProfileService : public GCMService, public KeyedService {
26  public:
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.
31     ALWAYS_ENABLED,
32     // GCM is only enabled for apps. GCMClient will start to load and connect
33     // with GCM only when GCM API is used.
34     ENABLED_FOR_APPS,
35     // GCM is always disabled. GCMClient will never load and connect with GCM.
36     ALWAYS_DISABLED
37   };
38
39   // Returns the GCM enabled state.
40   static GCMEnabledState GetGCMEnabledState(Profile* profile);
41
42   // Returns text representation of a GCMEnabledState enum entry.
43   static std::string GetGCMEnabledStateString(GCMEnabledState state);
44
45   // Register profile-specific prefs for GCM.
46   static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
47
48   explicit GCMProfileService(Profile* profile);
49   virtual ~GCMProfileService();
50
51   // KeyedService:
52   virtual void Shutdown() OVERRIDE;
53
54   // Returns the user name if the profile is signed in.
55   std::string SignedInUserName() const;
56
57  protected:
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;
63
64  private:
65   // The profile which owns this object.
66   Profile* profile_;
67
68   DISALLOW_COPY_AND_ASSIGN(GCMProfileService);
69 };
70
71 }  // namespace gcm
72
73 #endif  // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_