Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service.h

Issue 330733002: Move IdentityProvider usage from GCMDriverDesktop to GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 // TODO(jianli): include needed for obsolete methods that are going to be 13 // TODO(jianli): include needed for obsolete methods that are going to be
14 // removed soon. 14 // removed soon.
15 #include "components/gcm_driver/gcm_driver.h" 15 #include "components/gcm_driver/gcm_driver.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 17
18 #if !defined(OS_ANDROID)
19 #include "google_apis/gaia/identity_provider.h"
20 #endif
21
18 class Profile; 22 class Profile;
19 23
20 namespace user_prefs { 24 namespace user_prefs {
21 class PrefRegistrySyncable; 25 class PrefRegistrySyncable;
22 } 26 }
23 27
24 namespace gcm { 28 namespace gcm {
25 29
26 class GCMClientFactory; 30 class GCMClientFactory;
27 class GCMDriver; 31 class GCMDriver;
28 32
29 // Providing GCM service, via GCMDriver, to a profile. 33 // Providing GCM service, via GCMDriver, to a profile.
34 #if defined(OS_ANDROID)
30 class GCMProfileService : public KeyedService { 35 class GCMProfileService : public KeyedService {
36 #else
37 class GCMProfileService : public KeyedService,
38 public IdentityProvider::Observer {
39 #endif
31 public: 40 public:
32 // Returns whether GCM is enabled for |profile|. 41 // Returns whether GCM is enabled for |profile|.
33 static bool IsGCMEnabled(Profile* profile); 42 static bool IsGCMEnabled(Profile* profile);
34 43
35 // Register profile-specific prefs for GCM. 44 // Register profile-specific prefs for GCM.
36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 45 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
37 46
38 #if defined(OS_ANDROID) 47 #if defined(OS_ANDROID)
39 explicit GCMProfileService(Profile* profile); 48 explicit GCMProfileService(Profile* profile);
40 #else 49 #else
41 GCMProfileService(Profile* profile, 50 GCMProfileService(Profile* profile,
42 scoped_ptr<GCMClientFactory> gcm_client_factory); 51 scoped_ptr<GCMClientFactory> gcm_client_factory);
43 #endif 52 #endif
44 virtual ~GCMProfileService(); 53 virtual ~GCMProfileService();
45 54
46 // TODO(jianli): obsolete methods that are going to be removed soon. 55 // TODO(jianli): obsolete methods that are going to be removed soon.
47 void AddAppHandler(const std::string& app_id, GCMAppHandler* handler); 56 void AddAppHandler(const std::string& app_id, GCMAppHandler* handler);
48 void RemoveAppHandler(const std::string& app_id); 57 void RemoveAppHandler(const std::string& app_id);
49 void Register(const std::string& app_id, 58 void Register(const std::string& app_id,
50 const std::vector<std::string>& sender_ids, 59 const std::vector<std::string>& sender_ids,
51 const GCMDriver::RegisterCallback& callback); 60 const GCMDriver::RegisterCallback& callback);
52 61
53 // KeyedService: 62 // KeyedService:
54 virtual void Shutdown() OVERRIDE; 63 virtual void Shutdown() OVERRIDE;
55 64
65 // IdentityProvider::Observer:
bartfab (slow) 2014/06/13 11:27:21 Nit: Move the comment inside the #if. It is only a
jianli 2014/06/13 18:04:48 Done.
66 #if !defined(OS_ANDROID)
67 virtual void OnActiveAccountLogin() OVERRIDE;
68 virtual void OnActiveAccountLogout() OVERRIDE;
69 #endif
70
71 // Returns the user name if the profile is signed in. Empty string otherwise.
bartfab (slow) 2014/06/13 11:27:21 nit: s/. Emtpy/ or an empty/
jianli 2014/06/13 18:04:48 Done.
72 std::string SignedInUserName() const;
73
56 // For testing purpose. 74 // For testing purpose.
57 void SetDriverForTesting(GCMDriver* driver); 75 void SetDriverForTesting(GCMDriver* driver);
58 76
59 GCMDriver* driver() const { return driver_.get(); } 77 GCMDriver* driver() const { return driver_.get(); }
60 78
61 protected: 79 protected:
62 // Used for constructing fake GCMProfileService for testing purpose. 80 // Used for constructing fake GCMProfileService for testing purpose.
63 GCMProfileService(); 81 GCMProfileService();
64 82
65 private: 83 private:
66 // The profile which owns this object. 84 // The profile which owns this object.
67 Profile* profile_; 85 Profile* profile_;
68 86
69 scoped_ptr<GCMDriver> driver_; 87 scoped_ptr<GCMDriver> driver_;
70 88
89 #if !defined(OS_ANDROID)
90 scoped_ptr<IdentityProvider> identity_provider_;
91
92 // The account ID that this service is responsible for. Empty when the service
93 // is not running.
94 std::string account_id_;
95 #endif
96
71 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); 97 DISALLOW_COPY_AND_ASSIGN(GCMProfileService);
72 }; 98 };
73 99
74 } // namespace gcm 100 } // namespace gcm
75 101
76 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ 102 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698