OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
15 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche
r.h" | 15 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche
r.h" |
16 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" | 16 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" |
17 #include "chrome/browser/extensions/chrome_extension_function.h" | 17 #include "chrome/browser/extensions/chrome_extension_function.h" |
18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
21 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
22 #include "google_apis/gaia/oauth2_token_service.h" | 22 #include "google_apis/gaia/oauth2_token_service.h" |
23 | 23 |
24 class Profile; | 24 class Profile; |
25 | 25 |
| 26 namespace invalidation { |
| 27 class InvalidationAuthProvider; |
| 28 } |
| 29 |
26 namespace extensions { | 30 namespace extensions { |
27 | 31 |
| 32 class ObfuscatedGaiaIdFetcher; |
28 class PushMessagingInvalidationMapper; | 33 class PushMessagingInvalidationMapper; |
29 class ObfuscatedGaiaIdFetcher; | |
30 | 34 |
31 // Observes a single InvalidationHandler and generates onMessage events. | 35 // Observes a single InvalidationHandler and generates onMessage events. |
32 class PushMessagingEventRouter | 36 class PushMessagingEventRouter |
33 : public PushMessagingInvalidationHandlerDelegate { | 37 : public PushMessagingInvalidationHandlerDelegate { |
34 public: | 38 public: |
35 explicit PushMessagingEventRouter(Profile* profile); | 39 explicit PushMessagingEventRouter(Profile* profile); |
36 virtual ~PushMessagingEventRouter(); | 40 virtual ~PushMessagingEventRouter(); |
37 | 41 |
38 // For testing purposes. | 42 // For testing purposes. |
39 void TriggerMessageForTest(const std::string& extension_id, | 43 void TriggerMessageForTest(const std::string& extension_id, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // OAuth2TokenService::Consumer implementation. | 90 // OAuth2TokenService::Consumer implementation. |
87 virtual void OnGetTokenSuccess( | 91 virtual void OnGetTokenSuccess( |
88 const OAuth2TokenService::Request* request, | 92 const OAuth2TokenService::Request* request, |
89 const std::string& access_token, | 93 const std::string& access_token, |
90 const base::Time& expiration_time) OVERRIDE; | 94 const base::Time& expiration_time) OVERRIDE; |
91 virtual void OnGetTokenFailure( | 95 virtual void OnGetTokenFailure( |
92 const OAuth2TokenService::Request* request, | 96 const OAuth2TokenService::Request* request, |
93 const GoogleServiceAuthError& error) OVERRIDE; | 97 const GoogleServiceAuthError& error) OVERRIDE; |
94 | 98 |
95 // Check if the user is signed into chrome. | 99 // Check if the user is signed into chrome. |
96 bool IsUserLoggedIn() const; | 100 bool IsUserLoggedIn(); |
97 | 101 |
98 // ObfuscatedGiaiaIdFetcher::Delegate implementation. | 102 // ObfuscatedGiaiaIdFetcher::Delegate implementation. |
99 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) | 103 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) |
100 OVERRIDE; | 104 OVERRIDE; |
101 virtual void OnObfuscatedGaiaIdFetchFailure( | 105 virtual void OnObfuscatedGaiaIdFetchFailure( |
102 const GoogleServiceAuthError& error) OVERRIDE; | 106 const GoogleServiceAuthError& error) OVERRIDE; |
| 107 |
| 108 // Convenience helper to get the invalidation auth provider. |
| 109 invalidation::InvalidationAuthProvider* GetInvalidationAuthProvider(); |
| 110 |
103 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; | 111 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; |
104 bool interactive_; | 112 bool interactive_; |
105 scoped_ptr<OAuth2TokenService::Request> fetcher_access_token_request_; | 113 scoped_ptr<OAuth2TokenService::Request> fetcher_access_token_request_; |
106 | 114 |
107 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); | 115 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); |
108 }; | 116 }; |
109 | 117 |
110 class PushMessagingAPI : public ProfileKeyedAPI, | 118 class PushMessagingAPI : public ProfileKeyedAPI, |
111 public content::NotificationObserver { | 119 public content::NotificationObserver { |
112 public: | 120 public: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 164 |
157 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI); | 165 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI); |
158 }; | 166 }; |
159 | 167 |
160 template <> | 168 template <> |
161 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies(); | 169 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies(); |
162 | 170 |
163 } // namespace extensions | 171 } // namespace extensions |
164 | 172 |
165 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 173 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
OLD | NEW |