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