| 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/push_messaging/obfuscated_gaia_id_fetche
r.h" | 14 #include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetche
r.h" |
| 15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" | 15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" |
| 16 #include "chrome/browser/extensions/chrome_extension_function.h" | 16 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 17 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 17 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "extensions/browser/browser_context_keyed_api_factory.h" | 20 #include "extensions/browser/browser_context_keyed_api_factory.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 content { | 26 namespace content { |
| 27 class BrowserContext; | 27 class BrowserContext; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace invalidation { | |
| 31 class InvalidationAuthProvider; | |
| 32 } | |
| 33 | |
| 34 namespace extensions { | 30 namespace extensions { |
| 35 | 31 |
| 36 class PushMessagingInvalidationMapper; | 32 class PushMessagingInvalidationMapper; |
| 37 | 33 |
| 38 // Observes a single InvalidationHandler and generates onMessage events. | 34 // Observes a single InvalidationHandler and generates onMessage events. |
| 39 class PushMessagingEventRouter | 35 class PushMessagingEventRouter |
| 40 : public PushMessagingInvalidationHandlerDelegate { | 36 : public PushMessagingInvalidationHandlerDelegate { |
| 41 public: | 37 public: |
| 42 explicit PushMessagingEventRouter(Profile* profile); | 38 explicit PushMessagingEventRouter(Profile* profile); |
| 43 virtual ~PushMessagingEventRouter(); | 39 virtual ~PushMessagingEventRouter(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 88 |
| 93 // OAuth2TokenService::Consumer implementation. | 89 // OAuth2TokenService::Consumer implementation. |
| 94 virtual void OnGetTokenSuccess( | 90 virtual void OnGetTokenSuccess( |
| 95 const OAuth2TokenService::Request* request, | 91 const OAuth2TokenService::Request* request, |
| 96 const std::string& access_token, | 92 const std::string& access_token, |
| 97 const base::Time& expiration_time) OVERRIDE; | 93 const base::Time& expiration_time) OVERRIDE; |
| 98 virtual void OnGetTokenFailure( | 94 virtual void OnGetTokenFailure( |
| 99 const OAuth2TokenService::Request* request, | 95 const OAuth2TokenService::Request* request, |
| 100 const GoogleServiceAuthError& error) OVERRIDE; | 96 const GoogleServiceAuthError& error) OVERRIDE; |
| 101 | 97 |
| 102 // Check if the user is signed into chrome. | |
| 103 bool IsUserLoggedIn(); | |
| 104 | |
| 105 // ObfuscatedGiaiaIdFetcher::Delegate implementation. | 98 // ObfuscatedGiaiaIdFetcher::Delegate implementation. |
| 106 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) | 99 virtual void OnObfuscatedGaiaIdFetchSuccess(const std::string& gaia_id) |
| 107 OVERRIDE; | 100 OVERRIDE; |
| 108 virtual void OnObfuscatedGaiaIdFetchFailure( | 101 virtual void OnObfuscatedGaiaIdFetchFailure( |
| 109 const GoogleServiceAuthError& error) OVERRIDE; | 102 const GoogleServiceAuthError& error) OVERRIDE; |
| 110 | 103 |
| 111 // Convenience helper to get the invalidation auth provider. | |
| 112 invalidation::InvalidationAuthProvider* GetInvalidationAuthProvider(); | |
| 113 | |
| 114 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; | 104 scoped_ptr<ObfuscatedGaiaIdFetcher> fetcher_; |
| 115 bool interactive_; | 105 bool interactive_; |
| 116 scoped_ptr<OAuth2TokenService::Request> fetcher_access_token_request_; | 106 scoped_ptr<OAuth2TokenService::Request> fetcher_access_token_request_; |
| 117 | 107 |
| 118 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); | 108 DISALLOW_COPY_AND_ASSIGN(PushMessagingGetChannelIdFunction); |
| 119 }; | 109 }; |
| 120 | 110 |
| 121 class PushMessagingAPI : public BrowserContextKeyedAPI, | 111 class PushMessagingAPI : public BrowserContextKeyedAPI, |
| 122 public content::NotificationObserver { | 112 public content::NotificationObserver { |
| 123 public: | 113 public: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI); | 158 DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI); |
| 169 }; | 159 }; |
| 170 | 160 |
| 171 template <> | 161 template <> |
| 172 void BrowserContextKeyedAPIFactory< | 162 void BrowserContextKeyedAPIFactory< |
| 173 PushMessagingAPI>::DeclareFactoryDependencies(); | 163 PushMessagingAPI>::DeclareFactoryDependencies(); |
| 174 | 164 |
| 175 } // namespace extensions | 165 } // namespace extensions |
| 176 | 166 |
| 177 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ | 167 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_API_H__ |
| OLD | NEW |